@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | * @param Exception $exception |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - protected function transformException(Exception $exception) |
|
36 | + protected function transformException( Exception $exception ) |
|
37 | 37 | { |
38 | - if (Request::capture()->wantsJson()) { |
|
39 | - $this->transformAuthException($exception); |
|
40 | - $this->transformEloquentException($exception); |
|
41 | - $this->transformValidationException($exception); |
|
38 | + if ( Request::capture()->wantsJson() ) { |
|
39 | + $this->transformAuthException( $exception ); |
|
40 | + $this->transformEloquentException( $exception ); |
|
41 | + $this->transformValidationException( $exception ); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | * @throws UnauthenticatedException |
51 | 51 | * @throws UnauthorizedException |
52 | 52 | */ |
53 | - protected function transformAuthException(Exception $exception) |
|
53 | + protected function transformAuthException( Exception $exception ) |
|
54 | 54 | { |
55 | - if ($exception instanceof AuthenticationException) { |
|
55 | + if ( $exception instanceof AuthenticationException ) { |
|
56 | 56 | throw new UnauthenticatedException(); |
57 | 57 | } |
58 | 58 | |
59 | - if ($exception instanceof AuthorizationException) { |
|
59 | + if ( $exception instanceof AuthorizationException ) { |
|
60 | 60 | throw new UnauthorizedException(); |
61 | 61 | } |
62 | 62 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | * @throws ResourceNotFoundException |
70 | 70 | * @throws RelationNotFoundException |
71 | 71 | */ |
72 | - protected function transformEloquentException(Exception $exception) |
|
72 | + protected function transformEloquentException( Exception $exception ) |
|
73 | 73 | { |
74 | - if ($exception instanceof ModelNotFoundException) { |
|
74 | + if ( $exception instanceof ModelNotFoundException ) { |
|
75 | 75 | throw new ResourceNotFoundException(); |
76 | 76 | } |
77 | 77 | |
78 | - if ($exception instanceof EloquentRelationNotFoundException) { |
|
78 | + if ( $exception instanceof EloquentRelationNotFoundException ) { |
|
79 | 79 | throw new RelationNotFoundException(); |
80 | 80 | } |
81 | 81 | } |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * @return void |
88 | 88 | * @throws ValidationFailedException |
89 | 89 | */ |
90 | - protected function transformValidationException(Exception $exception) |
|
90 | + protected function transformValidationException( Exception $exception ) |
|
91 | 91 | { |
92 | - if ($exception instanceof ValidationException) { |
|
93 | - throw new ValidationFailedException($exception->validator); |
|
92 | + if ( $exception instanceof ValidationException ) { |
|
93 | + throw new ValidationFailedException( $exception->validator ); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | * @param ApiException $exception |
101 | 101 | * @return JsonResponse |
102 | 102 | */ |
103 | - protected function renderApiError(ApiException $exception):JsonResponse |
|
103 | + protected function renderApiError( ApiException $exception ):JsonResponse |
|
104 | 104 | { |
105 | - return app('responder.error') |
|
106 | - ->setError($exception->getErrorCode(), $exception->getMessage()) |
|
107 | - ->addData($exception->getData() ?: []) |
|
108 | - ->respond($exception->getStatusCode()); |
|
105 | + return app( 'responder.error' ) |
|
106 | + ->setError( $exception->getErrorCode(), $exception->getMessage() ) |
|
107 | + ->addData( $exception->getData() ?: [ ] ) |
|
108 | + ->respond( $exception->getStatusCode() ); |
|
109 | 109 | } |
110 | 110 | } |