Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed create prefix #2

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Model/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@
*/
final class Error extends AbstractError
{
public static function createError(string $title, int $httpCode): self
public static function error(string $title, int $httpCode): self
{
return new self($title, $httpCode);
}

public static function createServerError(string $title = 'Internal server error'): self
public static function serverError(string $title = 'Internal server error'): self
{
return new self($title, 500);
}

public static function createForbidden(string $title = 'Forbidden'): self
public static function forbidden(string $title = 'Forbidden'): self
{
return new self($title, 403);
}

public static function createNotFound(string $title = 'Not Found'): self
public static function notFound(string $title = 'Not Found'): self
{
return new self($title, 404);
}

public static function createUnauthorized(string $title = 'Unauthorized'): self
public static function unauthorized(string $title = 'Unauthorized'): self
{
return new self($title, 401);
}

public static function createInvalid(string $title = 'Bad Request'): self
public static function invalid(string $title = 'Bad Request'): self
{
return new self($title, 400);
}
Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/Model/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
class ErrorTest extends TestCase
{
public function testCreateError(): void
public function testError(): void
{
$error = Error::createError('someTitle', 400);
$error = Error::error('someTitle', 400);
self::assertEquals(
[
'status' => 400,
Expand All @@ -24,9 +24,9 @@ public function testCreateError(): void
);
}

public function testCreateServerError(): void
public function testServerError(): void
{
$error = Error::createServerError('someTitle');
$error = Error::serverError('someTitle');
self::assertEquals(
[
'status' => 500,
Expand All @@ -36,9 +36,9 @@ public function testCreateServerError(): void
);
}

public function testCreateForbidden(): void
public function testForbidden(): void
{
$error = Error::createForbidden('someTitle');
$error = Error::forbidden('someTitle');
self::assertEquals(
[
'status' => 403,
Expand All @@ -48,9 +48,9 @@ public function testCreateForbidden(): void
);
}

public function testCreateNotFound(): void
public function testNotFound(): void
{
$error = Error::createNotFound('someTitle');
$error = Error::notFound('someTitle');
self::assertEquals(
[
'status' => 404,
Expand All @@ -60,9 +60,9 @@ public function testCreateNotFound(): void
);
}

public function testCreateUnauthorized(): void
public function testUnauthorized(): void
{
$error = Error::createUnauthorized('someTitle');
$error = Error::unauthorized('someTitle');
self::assertEquals(
[
'status' => 401,
Expand All @@ -72,9 +72,9 @@ public function testCreateUnauthorized(): void
);
}

public function testCreateInvalid(): void
public function testInvalid(): void
{
$error = Error::createInvalid('someTitle');
$error = Error::invalid('someTitle');
self::assertEquals(
[
'status' => 400,
Expand Down