@@ -33,14 +33,14 @@ 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 | 38 | $request = Request::capture(); |
39 | 39 | |
40 | - if ($request->wantsJson()) { |
|
41 | - $this->transformAuthException($exception); |
|
42 | - $this->transformEloquentException($exception); |
|
43 | - $this->transformValidationException($exception); |
|
40 | + if ( $request->wantsJson() ) { |
|
41 | + $this->transformAuthException( $exception ); |
|
42 | + $this->transformEloquentException( $exception ); |
|
43 | + $this->transformValidationException( $exception ); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * @throws UnauthenticatedException |
53 | 53 | * @throws UnauthorizedException |
54 | 54 | */ |
55 | - protected function transformAuthException(Exception $exception) |
|
55 | + protected function transformAuthException( Exception $exception ) |
|
56 | 56 | { |
57 | - if ($exception instanceof AuthenticationException) { |
|
57 | + if ( $exception instanceof AuthenticationException ) { |
|
58 | 58 | throw new UnauthenticatedException(); |
59 | 59 | } |
60 | 60 | |
61 | - if ($exception instanceof AuthorizationException) { |
|
61 | + if ( $exception instanceof AuthorizationException ) { |
|
62 | 62 | throw new UnauthorizedException(); |
63 | 63 | } |
64 | 64 | } |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | * @throws ResourceNotFoundException |
72 | 72 | * @throws RelationNotFoundException |
73 | 73 | */ |
74 | - protected function transformEloquentException(Exception $exception) |
|
74 | + protected function transformEloquentException( Exception $exception ) |
|
75 | 75 | { |
76 | - if ($exception instanceof ModelNotFoundException) { |
|
76 | + if ( $exception instanceof ModelNotFoundException ) { |
|
77 | 77 | throw new ResourceNotFoundException(); |
78 | 78 | } |
79 | 79 | |
80 | - if ($exception instanceof RelationNotFoundException) { |
|
80 | + if ( $exception instanceof RelationNotFoundException ) { |
|
81 | 81 | throw new RelationNotFoundException(); |
82 | 82 | } |
83 | 83 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | * @throws ValidationFailedException |
91 | 91 | */ |
92 | - protected function transformValidationException(Exception $exception) |
|
92 | + protected function transformValidationException( Exception $exception ) |
|
93 | 93 | { |
94 | - if ($exception instanceof ValidationException) { |
|
95 | - throw new ValidationFailedException($exception->validator); |
|
94 | + if ( $exception instanceof ValidationException ) { |
|
95 | + throw new ValidationFailedException( $exception->validator ); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @param ApiException $exception |
103 | 103 | * @return JsonResponse |
104 | 104 | */ |
105 | - protected function renderApiError(ApiException $exception):JsonResponse |
|
105 | + protected function renderApiError( ApiException $exception ):JsonResponse |
|
106 | 106 | { |
107 | - return app('responder.error') |
|
108 | - ->setError($exception->getErrorCode(), $exception->getMessage()) |
|
109 | - ->addData($exception->getData() ?: []) |
|
110 | - ->respond($exception->getStatusCode()); |
|
107 | + return app( 'responder.error' ) |
|
108 | + ->setError( $exception->getErrorCode(), $exception->getMessage() ) |
|
109 | + ->addData( $exception->getData() ?: [ ] ) |
|
110 | + ->respond( $exception->getStatusCode() ); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | \ No newline at end of file |