@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param Validator $validator |
41 | 41 | */ |
42 | - public function __construct(Validator $validator) |
|
42 | + public function __construct( Validator $validator ) |
|
43 | 43 | { |
44 | 44 | $this->validator = $validator; |
45 | 45 | |
@@ -53,6 +53,6 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getData() |
55 | 55 | { |
56 | - return ['fields' => $this->validator->getMessageBag()->toArray()]; |
|
56 | + return [ 'fields' => $this->validator->getMessageBag()->toArray() ]; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | \ No newline at end of file |
@@ -34,9 +34,9 @@ |
||
34 | 34 | * |
35 | 35 | * @param mixed $message |
36 | 36 | */ |
37 | - public function __construct($message = null) |
|
37 | + public function __construct( $message = null ) |
|
38 | 38 | { |
39 | - parent::__construct($this->statusCode, $message); |
|
39 | + parent::__construct( $this->statusCode, $message ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -17,14 +17,14 @@ |
||
17 | 17 | * @param Exception $exception |
18 | 18 | * @return \Illuminate\Http\Response |
19 | 19 | */ |
20 | - public function render($request, Exception $exception) |
|
20 | + public function render( $request, Exception $exception ) |
|
21 | 21 | { |
22 | - $this->transformException($exception); |
|
22 | + $this->transformException( $exception ); |
|
23 | 23 | |
24 | - if ($exception instanceof ApiException) { |
|
25 | - return $this->renderApiError($exception); |
|
24 | + if ( $exception instanceof ApiException ) { |
|
25 | + return $this->renderApiError( $exception ); |
|
26 | 26 | } |
27 | 27 | |
28 | - return parent::render($request, $exception); |
|
28 | + return parent::render( $request, $exception ); |
|
29 | 29 | } |
30 | 30 | } |
@@ -19,6 +19,6 @@ |
||
19 | 19 | */ |
20 | 20 | public function __construct() |
21 | 21 | { |
22 | - return parent::__construct('Given serializer is not an instance of [' . SerializerAbstract::class . '].'); |
|
22 | + return parent::__construct( 'Given serializer is not an instance of [' . SerializerAbstract::class . '].' ); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * @param string $key |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | - public function relationLoaded($key); |
|
41 | + public function relationLoaded( $key ); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Convert the model instance to an array. |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * @param int $status |
23 | 23 | * @return $this |
24 | 24 | */ |
25 | - protected function seeSuccess($data = null, $status = 200) |
|
25 | + protected function seeSuccess( $data = null, $status = 200 ) |
|
26 | 26 | { |
27 | - $response = $this->seeSuccessResponse($data, $status); |
|
28 | - $this->seeSuccessData($response->getData(true)['data']); |
|
27 | + $response = $this->seeSuccessResponse( $data, $status ); |
|
28 | + $this->seeSuccessData( $response->getData( true )[ 'data' ] ); |
|
29 | 29 | |
30 | 30 | return $this; |
31 | 31 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | * @param int $status |
38 | 38 | * @return $this |
39 | 39 | */ |
40 | - protected function seeSuccessEquals($data = null, $status = 200) |
|
40 | + protected function seeSuccessEquals( $data = null, $status = 200 ) |
|
41 | 41 | { |
42 | - $response = $this->seeSuccessResponse($data, $status); |
|
43 | - $this->seeJsonEquals($response->getData(true)); |
|
42 | + $response = $this->seeSuccessResponse( $data, $status ); |
|
43 | + $this->seeJsonEquals( $response->getData( true ) ); |
|
44 | 44 | |
45 | 45 | return $this; |
46 | 46 | } |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * @param mixed $data |
52 | 52 | * @return $this |
53 | 53 | */ |
54 | - protected function seeSuccessStructure($data = null) |
|
54 | + protected function seeSuccessStructure( $data = null ) |
|
55 | 55 | { |
56 | - $this->seeJsonStructure([ |
|
56 | + $this->seeJsonStructure( [ |
|
57 | 57 | 'data' => $data |
58 | - ]); |
|
58 | + ] ); |
|
59 | 59 | |
60 | 60 | return $this; |
61 | 61 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * @param int $status |
68 | 68 | * @return JsonResponse |
69 | 69 | */ |
70 | - protected function seeSuccessResponse($data = null, $status = 200):JsonResponse |
|
70 | + protected function seeSuccessResponse( $data = null, $status = 200 ):JsonResponse |
|
71 | 71 | { |
72 | - $response = app(Responder::class)->success($data, $status); |
|
72 | + $response = app( Responder::class )->success( $data, $status ); |
|
73 | 73 | |
74 | - $this->seeStatusCode($response->getStatusCode())->seeJson([ |
|
74 | + $this->seeStatusCode( $response->getStatusCode() )->seeJson( [ |
|
75 | 75 | 'success' => true, |
76 | 76 | 'status' => $response->getStatusCode() |
77 | - ])->seeJsonStructure(['data']); |
|
77 | + ] )->seeJsonStructure( [ 'data' ] ); |
|
78 | 78 | |
79 | 79 | return $response; |
80 | 80 | } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | * @param mixed $data |
86 | 86 | * @return $this |
87 | 87 | */ |
88 | - protected function seeSuccessData($data = null) |
|
88 | + protected function seeSuccessData( $data = null ) |
|
89 | 89 | { |
90 | - collect($data)->each(function ($value, $key) { |
|
91 | - if (is_array($value)) { |
|
92 | - $this->seeSuccessData($value); |
|
90 | + collect( $data )->each( function ( $value, $key ) { |
|
91 | + if ( is_array( $value ) ) { |
|
92 | + $this->seeSuccessData( $value ); |
|
93 | 93 | } else { |
94 | - $this->seeJson([$key => $value]); |
|
94 | + $this->seeJson( [ $key => $value ] ); |
|
95 | 95 | } |
96 | 96 | }); |
97 | 97 | |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | * @param string|array $attributes |
105 | 105 | * @return array |
106 | 106 | */ |
107 | - protected function getSuccessData($attributes = null) |
|
107 | + protected function getSuccessData( $attributes = null ) |
|
108 | 108 | { |
109 | - $rawData = $this->decodeResponseJson()['data']; |
|
109 | + $rawData = $this->decodeResponseJson()[ 'data' ]; |
|
110 | 110 | |
111 | - if (is_null($attributes)) { |
|
111 | + if ( is_null( $attributes ) ) { |
|
112 | 112 | return $rawData; |
113 | - } elseif (is_string($attributes)) { |
|
114 | - return array_get($rawData, $attributes); |
|
113 | + } elseif ( is_string( $attributes ) ) { |
|
114 | + return array_get( $rawData, $attributes ); |
|
115 | 115 | } |
116 | 116 | |
117 | - $data = []; |
|
117 | + $data = [ ]; |
|
118 | 118 | |
119 | - foreach ($attributes as $attribute) { |
|
120 | - $data[] = array_get($rawData, $attribute); |
|
119 | + foreach ( $attributes as $attribute ) { |
|
120 | + $data[ ] = array_get( $rawData, $attribute ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return $data; |
@@ -130,25 +130,25 @@ discard block |
||
130 | 130 | * @param int|null $status |
131 | 131 | * @return $this |
132 | 132 | */ |
133 | - protected function seeError(string $error, int $status = null) |
|
133 | + protected function seeError( string $error, int $status = null ) |
|
134 | 134 | { |
135 | - if (! is_null($status)) { |
|
136 | - $this->seeStatusCode($status); |
|
135 | + if ( ! is_null( $status ) ) { |
|
136 | + $this->seeStatusCode( $status ); |
|
137 | 137 | } |
138 | 138 | |
139 | - if ($this->app->config->get('responder.status_code')) { |
|
140 | - $this->seeJson([ |
|
139 | + if ( $this->app->config->get( 'responder.status_code' ) ) { |
|
140 | + $this->seeJson( [ |
|
141 | 141 | 'status' => $status |
142 | - ]); |
|
142 | + ] ); |
|
143 | 143 | } |
144 | 144 | |
145 | - return $this->seeJson([ |
|
145 | + return $this->seeJson( [ |
|
146 | 146 | 'success' => false |
147 | - ])->seeJsonSubset([ |
|
147 | + ] )->seeJsonSubset( [ |
|
148 | 148 | 'error' => [ |
149 | 149 | 'code' => $error |
150 | 150 | ] |
151 | - ]); |
|
151 | + ] ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param int $status |
158 | 158 | * @return $this |
159 | 159 | */ |
160 | - abstract protected function seeStatusCode($status); |
|
160 | + abstract protected function seeStatusCode( $status ); |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Assert that the response contains JSON. |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param bool $negate |
167 | 167 | * @return $this |
168 | 168 | */ |
169 | - abstract public function seeJson(array $data = null, $negate = false); |
|
169 | + abstract public function seeJson( array $data = null, $negate = false ); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Assert that the JSON response has a given structure. |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param array|null $responseData |
176 | 176 | * @return $this |
177 | 177 | */ |
178 | - abstract public function seeJsonStructure(array $structure = null, $responseData = null); |
|
178 | + abstract public function seeJsonStructure( array $structure = null, $responseData = null ); |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Assert that the response is a superset of the given JSON. |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param array $data |
184 | 184 | * @return $this |
185 | 185 | */ |
186 | - abstract protected function seeJsonSubset(array $data); |
|
186 | + abstract protected function seeJsonSubset( array $data ); |
|
187 | 187 | |
188 | 188 | /** |
189 | 189 | * Assert that the response contains an exact JSON array. |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param array $data |
192 | 192 | * @return $this |
193 | 193 | */ |
194 | - abstract public function seeJsonEquals(array $data); |
|
194 | + abstract public function seeJsonEquals( array $data ); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Validate and return the decoded response JSON. |
@@ -36,26 +36,26 @@ discard block |
||
36 | 36 | * @throws RelationNotFoundException |
37 | 37 | * @throws ValidationFailedException |
38 | 38 | */ |
39 | - protected function transformException(Exception $exception) |
|
39 | + protected function transformException( Exception $exception ) |
|
40 | 40 | { |
41 | - if ($exception instanceof AuthenticationException) { |
|
41 | + if ( $exception instanceof AuthenticationException ) { |
|
42 | 42 | throw new UnauthenticatedException(); |
43 | 43 | } |
44 | 44 | |
45 | - if ($exception instanceof AuthorizationException) { |
|
45 | + if ( $exception instanceof AuthorizationException ) { |
|
46 | 46 | throw new UnauthorizedException(); |
47 | 47 | } |
48 | 48 | |
49 | - if ($exception instanceof ModelNotFoundException) { |
|
49 | + if ( $exception instanceof ModelNotFoundException ) { |
|
50 | 50 | throw new ResourceNotFoundException(); |
51 | 51 | } |
52 | 52 | |
53 | - if ($exception instanceof RelationNotFoundException) { |
|
53 | + if ( $exception instanceof RelationNotFoundException ) { |
|
54 | 54 | throw new RelationNotFoundException(); |
55 | 55 | } |
56 | 56 | |
57 | - if ($exception instanceof ValidationException) { |
|
58 | - throw new ValidationFailedException($exception->validator); |
|
57 | + if ( $exception instanceof ValidationException ) { |
|
58 | + throw new ValidationFailedException( $exception->validator ); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | * @param ApiException $exception |
66 | 66 | * @return JsonResponse |
67 | 67 | */ |
68 | - protected function renderApiError(ApiException $exception):JsonResponse |
|
68 | + protected function renderApiError( ApiException $exception ):JsonResponse |
|
69 | 69 | { |
70 | - return app('responder.error') |
|
71 | - ->setError($exception->getErrorCode(), $exception->getMessage()) |
|
72 | - ->addData($exception->getData()) |
|
73 | - ->respond($exception->getStatusCode()); |
|
70 | + return app( 'responder.error' ) |
|
71 | + ->setError( $exception->getErrorCode(), $exception->getMessage() ) |
|
72 | + ->addData( $exception->getData() ) |
|
73 | + ->respond( $exception->getStatusCode() ); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -25,9 +25,9 @@ |
||
25 | 25 | * @return void |
26 | 26 | * @throws ValidationFailedException |
27 | 27 | */ |
28 | - protected function failedValidation(Validator $validator) |
|
28 | + protected function failedValidation( Validator $validator ) |
|
29 | 29 | { |
30 | - throw new ValidationFailedException($validator); |
|
30 | + throw new ValidationFailedException( $validator ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | * @param mixed $message |
25 | 25 | * @return JsonResponse |
26 | 26 | */ |
27 | - public function errorResponse(string $error = null, int $statusCode = null, $message = null):JsonResponse |
|
27 | + public function errorResponse( string $error = null, int $statusCode = null, $message = null ):JsonResponse |
|
28 | 28 | { |
29 | - return app(Responder::class)->error($error, $statusCode, $message); |
|
29 | + return app( Responder::class )->error( $error, $statusCode, $message ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * @param array $meta |
38 | 38 | * @return \Illuminate\Http\JsonResponse |
39 | 39 | */ |
40 | - public function successResponse($data = null, $statusCode = null, array $meta = []):JsonResponse |
|
40 | + public function successResponse( $data = null, $statusCode = null, array $meta = [ ] ):JsonResponse |
|
41 | 41 | { |
42 | - return app(Responder::class)->success($data, $statusCode, $meta); |
|
42 | + return app( Responder::class )->success( $data, $statusCode, $meta ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * @param callable|string|null $transformer |
50 | 50 | * @return \Flugg\Responder\Http\SuccessResponse |
51 | 51 | */ |
52 | - public function transform($data = null, $transformer = null):SuccessResponseBuilder |
|
52 | + public function transform( $data = null, $transformer = null ):SuccessResponseBuilder |
|
53 | 53 | { |
54 | - return app(Responder::class)->transform($data, $transformer); |
|
54 | + return app( Responder::class )->transform( $data, $transformer ); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | \ No newline at end of file |