@@ -6,8 +6,6 @@ |
||
6 | 6 | use Flugg\Responder\Exceptions\InvalidSerializerException; |
7 | 7 | use Flugg\Responder\Exceptions\InvalidTransformerException; |
8 | 8 | use Flugg\Responder\ResourceFactory; |
9 | -use Flugg\Responder\ResourceResolver; |
|
10 | -use Flugg\Responder\Transformation; |
|
11 | 9 | use Flugg\Responder\Transformer; |
12 | 10 | use Illuminate\Contracts\Routing\ResponseFactory; |
13 | 11 | use Illuminate\Database\Eloquent\Model; |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | * @param Exception $exception |
32 | 32 | * @return void |
33 | 33 | */ |
34 | - protected function transformException(Exception $exception) |
|
34 | + protected function transformException( Exception $exception ) |
|
35 | 35 | { |
36 | - $this->transformAuthException($exception); |
|
37 | - $this->transformEloquentException($exception); |
|
38 | - $this->transformValidationException($exception); |
|
36 | + $this->transformAuthException( $exception ); |
|
37 | + $this->transformEloquentException( $exception ); |
|
38 | + $this->transformValidationException( $exception ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * @throws UnauthenticatedException |
47 | 47 | * @throws UnauthorizedException |
48 | 48 | */ |
49 | - protected function transformAuthException(Exception $exception) |
|
49 | + protected function transformAuthException( Exception $exception ) |
|
50 | 50 | { |
51 | - if ($exception instanceof AuthenticationException) { |
|
51 | + if ( $exception instanceof AuthenticationException ) { |
|
52 | 52 | throw new UnauthenticatedException(); |
53 | 53 | } |
54 | 54 | |
55 | - if ($exception instanceof AuthorizationException) { |
|
55 | + if ( $exception instanceof AuthorizationException ) { |
|
56 | 56 | throw new UnauthorizedException(); |
57 | 57 | } |
58 | 58 | } |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * @throws ResourceNotFoundException |
66 | 66 | * @throws RelationNotFoundException |
67 | 67 | */ |
68 | - protected function transformEloquentException(Exception $exception) |
|
68 | + protected function transformEloquentException( Exception $exception ) |
|
69 | 69 | { |
70 | - if ($exception instanceof ModelNotFoundException) { |
|
70 | + if ( $exception instanceof ModelNotFoundException ) { |
|
71 | 71 | throw new ResourceNotFoundException(); |
72 | 72 | } |
73 | 73 | |
74 | - if ($exception instanceof RelationNotFoundException) { |
|
74 | + if ( $exception instanceof RelationNotFoundException ) { |
|
75 | 75 | throw new RelationNotFoundException(); |
76 | 76 | } |
77 | 77 | } |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @return void |
84 | 84 | * @throws ValidationFailedException |
85 | 85 | */ |
86 | - protected function transformValidationException(Exception $exception) |
|
86 | + protected function transformValidationException( Exception $exception ) |
|
87 | 87 | { |
88 | - if ($exception instanceof ValidationException) { |
|
89 | - throw new ValidationFailedException($exception->validator); |
|
88 | + if ( $exception instanceof ValidationException ) { |
|
89 | + throw new ValidationFailedException( $exception->validator ); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @param ApiException $exception |
97 | 97 | * @return JsonResponse |
98 | 98 | */ |
99 | - protected function renderApiError(ApiException $exception):JsonResponse |
|
99 | + protected function renderApiError( ApiException $exception ):JsonResponse |
|
100 | 100 | { |
101 | - return app('responder.error') |
|
102 | - ->setError($exception->getErrorCode(), $exception->getMessage()) |
|
103 | - ->addData($exception->getData() ?: []) |
|
104 | - ->respond($exception->getStatusCode()); |
|
101 | + return app( 'responder.error' ) |
|
102 | + ->setError( $exception->getErrorCode(), $exception->getMessage() ) |
|
103 | + ->addData( $exception->getData() ?: [ ] ) |
|
104 | + ->respond( $exception->getStatusCode() ); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | \ No newline at end of file |