@@ -10,9 +10,9 @@ |
||
10 | 10 | use Flugg\Responder\Contracts\Resources\ResourceFactory as ResourceFactoryContract; |
11 | 11 | use Flugg\Responder\Contracts\Responder as ResponderContract; |
12 | 12 | use Flugg\Responder\Contracts\ResponseFactory as ResponseFactoryContract; |
13 | +use Flugg\Responder\Contracts\TransformFactory as TransformFactoryContract; |
|
13 | 14 | use Flugg\Responder\Contracts\Transformer as TransformerContract; |
14 | 15 | use Flugg\Responder\Contracts\Transformers\TransformerResolver as TransformerResolverContract; |
15 | -use Flugg\Responder\Contracts\TransformFactory as TransformFactoryContract; |
|
16 | 16 | use Flugg\Responder\Http\Responses\Factories\LaravelResponseFactory; |
17 | 17 | use Flugg\Responder\Http\Responses\Factories\LumenResponseFactory; |
18 | 18 | use Flugg\Responder\Pagination\PaginatorFactory; |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function register() |
52 | 52 | { |
53 | - if ($this->app instanceof Laravel) { |
|
53 | + if ( $this->app instanceof Laravel ) { |
|
54 | 54 | $this->registerLaravelBindings(); |
55 | - } elseif ($this->app instanceof Lumen) { |
|
55 | + } elseif ( $this->app instanceof Lumen ) { |
|
56 | 56 | $this->registerLumenBindings(); |
57 | 57 | } |
58 | 58 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | */ |
74 | 74 | protected function registerLaravelBindings() |
75 | 75 | { |
76 | - $this->app->singleton(ResponseFactoryContract::class, function ($app) { |
|
77 | - return $this->decorateResponseFactory($app->make(LaravelResponseFactory::class)); |
|
76 | + $this->app->singleton( ResponseFactoryContract::class, function ( $app ) { |
|
77 | + return $this->decorateResponseFactory( $app->make( LaravelResponseFactory::class ) ); |
|
78 | 78 | }); |
79 | 79 | } |
80 | 80 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function registerLumenBindings() |
87 | 87 | { |
88 | - $this->app->singleton(ResponseFactoryContract::class, function ($app) { |
|
89 | - return $this->decorateResponseFactory($app->make(LumenResponseFactory::class)); |
|
88 | + $this->app->singleton( ResponseFactoryContract::class, function ( $app ) { |
|
89 | + return $this->decorateResponseFactory( $app->make( LumenResponseFactory::class ) ); |
|
90 | 90 | }); |
91 | 91 | } |
92 | 92 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @param \Flugg\Responder\Contracts\ResponseFactory $factory |
97 | 97 | * @return void |
98 | 98 | */ |
99 | - protected function decorateResponseFactory(ResponseFactoryContract $factory) |
|
99 | + protected function decorateResponseFactory( ResponseFactoryContract $factory ) |
|
100 | 100 | { |
101 | - foreach ($this->app->config['responder.decorators'] as $decorator) { |
|
102 | - $factory = new $decorator($factory); |
|
101 | + foreach ( $this->app->config[ 'responder.decorators' ] as $decorator ) { |
|
102 | + $factory = new $decorator( $factory ); |
|
103 | 103 | }; |
104 | 104 | |
105 | 105 | return $factory; |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function registerSerializerBindings() |
114 | 114 | { |
115 | - $this->app->bind(ErrorSerializerContract::class, function ($app) { |
|
116 | - return $app->make($app->config['responder.serializers.error']); |
|
115 | + $this->app->bind( ErrorSerializerContract::class, function ( $app ) { |
|
116 | + return $app->make( $app->config[ 'responder.serializers.error' ] ); |
|
117 | 117 | }); |
118 | 118 | |
119 | - $this->app->bind(SerializerAbstract::class, function ($app) { |
|
120 | - return $app->make($app->config['responder.serializers.success']); |
|
119 | + $this->app->bind( SerializerAbstract::class, function ( $app ) { |
|
120 | + return $app->make( $app->config[ 'responder.serializers.success' ] ); |
|
121 | 121 | }); |
122 | 122 | } |
123 | 123 | |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function registerErrorBindings() |
130 | 130 | { |
131 | - $this->app->singleton(ErrorMessageResolverContract::class, function ($app) { |
|
132 | - return $app->make(ErrorMessageResolver::class); |
|
131 | + $this->app->singleton( ErrorMessageResolverContract::class, function ( $app ) { |
|
132 | + return $app->make( ErrorMessageResolver::class ); |
|
133 | 133 | }); |
134 | 134 | |
135 | - $this->app->singleton(ErrorFactoryContract::class, function ($app) { |
|
136 | - return $app->make(ErrorFactory::class); |
|
135 | + $this->app->singleton( ErrorFactoryContract::class, function ( $app ) { |
|
136 | + return $app->make( ErrorFactory::class ); |
|
137 | 137 | }); |
138 | 138 | } |
139 | 139 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | */ |
145 | 145 | protected function registerFractalBindings() |
146 | 146 | { |
147 | - $this->app->bind(Manager::class, function ($app) { |
|
148 | - return (new Manager)->setRecursionLimit($app->config['responder.recursion_limit']); |
|
147 | + $this->app->bind( Manager::class, function ( $app ) { |
|
148 | + return (new Manager)->setRecursionLimit( $app->config[ 'responder.recursion_limit' ] ); |
|
149 | 149 | }); |
150 | 150 | } |
151 | 151 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | */ |
157 | 157 | protected function registerResourceBindings() |
158 | 158 | { |
159 | - $this->app->singleton(ResourceFactoryContract::class, function ($app) { |
|
160 | - return $app->make(ResourceFactory::class); |
|
159 | + $this->app->singleton( ResourceFactoryContract::class, function ( $app ) { |
|
160 | + return $app->make( ResourceFactory::class ); |
|
161 | 161 | }); |
162 | 162 | } |
163 | 163 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | */ |
169 | 169 | protected function registerPaginationBindings() |
170 | 170 | { |
171 | - $this->app->singleton(PaginatorFactoryContract::class, function ($app) { |
|
172 | - return new PaginatorFactory($app->make(Request::class)->query()); |
|
171 | + $this->app->singleton( PaginatorFactoryContract::class, function ( $app ) { |
|
172 | + return new PaginatorFactory( $app->make( Request::class )->query() ); |
|
173 | 173 | }); |
174 | 174 | } |
175 | 175 | |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | */ |
181 | 181 | protected function registerTransformationBindings() |
182 | 182 | { |
183 | - $this->app->singleton(TransformFactoryContract::class, function ($app) { |
|
184 | - return $app->make(FractalTransformFactory::class); |
|
183 | + $this->app->singleton( TransformFactoryContract::class, function ( $app ) { |
|
184 | + return $app->make( FractalTransformFactory::class ); |
|
185 | 185 | }); |
186 | 186 | |
187 | - $this->app->bind(TransformBuilder::class, function ($app) { |
|
188 | - return (new TransformBuilder($app->make(ResourceFactoryContract::class), $app->make(TransformFactoryContract::class), $app->make(PaginatorFactoryContract::class)))->serializer($app->make(SerializerAbstract::class)) |
|
189 | - ->with($app->make(Request::class)->input($app->config['responder.load_relations_parameter'], [])) |
|
190 | - ->only($app->make(Request::class)->input($app->config['responder.filter_fields_parameter'], [])); |
|
187 | + $this->app->bind( TransformBuilder::class, function ( $app ) { |
|
188 | + return (new TransformBuilder( $app->make( ResourceFactoryContract::class ), $app->make( TransformFactoryContract::class ), $app->make( PaginatorFactoryContract::class ) ))->serializer( $app->make( SerializerAbstract::class ) ) |
|
189 | + ->with( $app->make( Request::class )->input( $app->config[ 'responder.load_relations_parameter' ], [ ] ) ) |
|
190 | + ->only( $app->make( Request::class )->input( $app->config[ 'responder.filter_fields_parameter' ], [ ] ) ); |
|
191 | 191 | }); |
192 | 192 | |
193 | - $this->app->singleton(TransformerResolverContract::class, function ($app) { |
|
194 | - return $app->make(TransformerResolver::class); |
|
193 | + $this->app->singleton( TransformerResolverContract::class, function ( $app ) { |
|
194 | + return $app->make( TransformerResolver::class ); |
|
195 | 195 | }); |
196 | 196 | } |
197 | 197 | |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function registerTransformerBindings() |
204 | 204 | { |
205 | - $this->app->singleton(TransformerResolverContract::class, function ($app) { |
|
206 | - return $app->make(TransformerResolver::class); |
|
205 | + $this->app->singleton( TransformerResolverContract::class, function ( $app ) { |
|
206 | + return $app->make( TransformerResolver::class ); |
|
207 | 207 | }); |
208 | 208 | |
209 | - Transformer::containerResolver(function () { |
|
210 | - return $this->app->make(Container::class); |
|
209 | + Transformer::containerResolver( function () { |
|
210 | + return $this->app->make( Container::class ); |
|
211 | 211 | }); |
212 | 212 | } |
213 | 213 | |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function registerServiceBindings() |
220 | 220 | { |
221 | - $this->app->singleton(ResponderContract::class, function ($app) { |
|
222 | - return $app->make(Responder::class); |
|
221 | + $this->app->singleton( ResponderContract::class, function ( $app ) { |
|
222 | + return $app->make( Responder::class ); |
|
223 | 223 | }); |
224 | 224 | |
225 | - $this->app->singleton(TransformerContract::class, function ($app) { |
|
226 | - return $app->make(Transformer::class); |
|
225 | + $this->app->singleton( TransformerContract::class, function ( $app ) { |
|
226 | + return $app->make( Transformer::class ); |
|
227 | 227 | }); |
228 | 228 | } |
229 | 229 | |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function boot() |
236 | 236 | { |
237 | - if ($this->app instanceof Laravel) { |
|
237 | + if ( $this->app instanceof Laravel ) { |
|
238 | 238 | $this->bootLaravelApplication(); |
239 | - } elseif ($this->app instanceof Lumen) { |
|
239 | + } elseif ( $this->app instanceof Lumen ) { |
|
240 | 240 | $this->bootLumenApplication(); |
241 | 241 | } |
242 | 242 | |
243 | - $this->mergeConfigFrom(__DIR__ . '/../config/responder.php', 'responder'); |
|
244 | - $this->commands(MakeTransformer::class); |
|
243 | + $this->mergeConfigFrom( __DIR__ . '/../config/responder.php', 'responder' ); |
|
244 | + $this->commands( MakeTransformer::class ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | */ |
252 | 252 | protected function bootLaravelApplication() |
253 | 253 | { |
254 | - if ($this->app->runningInConsole()) { |
|
255 | - $this->publishes([ |
|
256 | - __DIR__ . '/../config/responder.php' => config_path('responder.php'), |
|
257 | - ], 'config'); |
|
258 | - $this->publishes([ |
|
259 | - __DIR__ . '/../resources/lang/en/errors.php' => base_path('resources/lang/en/errors.php'), |
|
260 | - ], 'lang'); |
|
254 | + if ( $this->app->runningInConsole() ) { |
|
255 | + $this->publishes( [ |
|
256 | + __DIR__ . '/../config/responder.php' => config_path( 'responder.php' ), |
|
257 | + ], 'config' ); |
|
258 | + $this->publishes( [ |
|
259 | + __DIR__ . '/../resources/lang/en/errors.php' => base_path( 'resources/lang/en/errors.php' ), |
|
260 | + ], 'lang' ); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -268,6 +268,6 @@ discard block |
||
268 | 268 | */ |
269 | 269 | protected function bootLumenApplication() |
270 | 270 | { |
271 | - $this->app->configure('responder'); |
|
271 | + $this->app->configure( 'responder' ); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | \ No newline at end of file |
@@ -171,7 +171,7 @@ |
||
171 | 171 | /** |
172 | 172 | * Exclude relations from the transform. |
173 | 173 | * |
174 | - * @param string[]|string $relations |
|
174 | + * @param string[] $relations |
|
175 | 175 | * @return $this |
176 | 176 | */ |
177 | 177 | public function without($relations) |
@@ -65,21 +65,21 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @var array |
67 | 67 | */ |
68 | - protected $with = []; |
|
68 | + protected $with = [ ]; |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * A list of excluded relations. |
72 | 72 | * |
73 | 73 | * @var array |
74 | 74 | */ |
75 | - protected $without = []; |
|
75 | + protected $without = [ ]; |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * A list of sparse fieldsets. |
79 | 79 | * |
80 | 80 | * @var array |
81 | 81 | */ |
82 | - protected $only = []; |
|
82 | + protected $only = [ ]; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Construct the builder class. |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param \Flugg\Responder\Contracts\TransformFactory $transformFactory |
89 | 89 | * @param \Flugg\Responder\Contracts\Pagination\PaginatorFactory $paginatorFactory |
90 | 90 | */ |
91 | - public function __construct(ResourceFactory $resourceFactory, TransformFactory $transformFactory, PaginatorFactory $paginatorFactory) |
|
91 | + public function __construct( ResourceFactory $resourceFactory, TransformFactory $transformFactory, PaginatorFactory $paginatorFactory ) |
|
92 | 92 | { |
93 | 93 | $this->resourceFactory = $resourceFactory; |
94 | 94 | $this->transformFactory = $transformFactory; |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @param string|null $resourceKey |
104 | 104 | * @return $this |
105 | 105 | */ |
106 | - public function resource($data = null, $transformer = null, string $resourceKey = null) |
|
106 | + public function resource( $data = null, $transformer = null, string $resourceKey = null ) |
|
107 | 107 | { |
108 | - $this->resource = $this->resourceFactory->make($data, $transformer, $resourceKey); |
|
108 | + $this->resource = $this->resourceFactory->make( $data, $transformer, $resourceKey ); |
|
109 | 109 | |
110 | - if ($data instanceof CursorPaginator) { |
|
111 | - $this->cursor($this->paginatorFactory->makeCursor($data)); |
|
112 | - } elseif ($data instanceof LengthAwarePaginator) { |
|
113 | - $this->paginator($this->paginatorFactory->make($data)); |
|
110 | + if ( $data instanceof CursorPaginator ) { |
|
111 | + $this->cursor( $this->paginatorFactory->makeCursor( $data ) ); |
|
112 | + } elseif ( $data instanceof LengthAwarePaginator ) { |
|
113 | + $this->paginator( $this->paginatorFactory->make( $data ) ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $this; |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | * @param \League\Fractal\Pagination\Cursor $cursor |
123 | 123 | * @return $this |
124 | 124 | */ |
125 | - public function cursor(Cursor $cursor) |
|
125 | + public function cursor( Cursor $cursor ) |
|
126 | 126 | { |
127 | - $this->resource->setCursor($cursor); |
|
127 | + $this->resource->setCursor( $cursor ); |
|
128 | 128 | |
129 | 129 | return $this; |
130 | 130 | } |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | * @param \League\Fractal\Pagination\IlluminatePaginatorAdapter $paginator |
136 | 136 | * @return $this |
137 | 137 | */ |
138 | - public function paginator(IlluminatePaginatorAdapter $paginator) |
|
138 | + public function paginator( IlluminatePaginatorAdapter $paginator ) |
|
139 | 139 | { |
140 | - $this->resource->setPaginator($paginator); |
|
140 | + $this->resource->setPaginator( $paginator ); |
|
141 | 141 | |
142 | 142 | return $this; |
143 | 143 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param array $data |
149 | 149 | * @return $this |
150 | 150 | */ |
151 | - public function meta(array $data) |
|
151 | + public function meta( array $data ) |
|
152 | 152 | { |
153 | - $this->resource->setMeta($data); |
|
153 | + $this->resource->setMeta( $data ); |
|
154 | 154 | |
155 | 155 | return $this; |
156 | 156 | } |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string[]|string $relations |
162 | 162 | * @return $this |
163 | 163 | */ |
164 | - public function with($relations) |
|
164 | + public function with( $relations ) |
|
165 | 165 | { |
166 | - $this->with = array_merge($this->with, is_array($relations) ? $relations : func_get_args()); |
|
166 | + $this->with = array_merge( $this->with, is_array( $relations ) ? $relations : func_get_args() ); |
|
167 | 167 | |
168 | 168 | return $this; |
169 | 169 | } |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * @param string[]|string $relations |
175 | 175 | * @return $this |
176 | 176 | */ |
177 | - public function without($relations) |
|
177 | + public function without( $relations ) |
|
178 | 178 | { |
179 | - $this->without = array_merge($this->without, is_array($relations) ? $relations : func_get_args()); |
|
179 | + $this->without = array_merge( $this->without, is_array( $relations ) ? $relations : func_get_args() ); |
|
180 | 180 | |
181 | 181 | return $this; |
182 | 182 | } |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @param string[]|string $fields |
188 | 188 | * @return $this |
189 | 189 | */ |
190 | - public function only($fields) |
|
190 | + public function only( $fields ) |
|
191 | 191 | { |
192 | - $this->only = array_merge($this->only, is_array($fields) ? $fields : func_get_args()); |
|
192 | + $this->only = array_merge( $this->only, is_array( $fields ) ? $fields : func_get_args() ); |
|
193 | 193 | |
194 | 194 | return $this; |
195 | 195 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * @return $this |
202 | 202 | * @throws \Flugg\Responder\Exceptions\InvalidSerializerException |
203 | 203 | */ |
204 | - public function serializer($serializer) |
|
204 | + public function serializer( $serializer ) |
|
205 | 205 | { |
206 | - if (is_string($serializer)) { |
|
206 | + if ( is_string( $serializer ) ) { |
|
207 | 207 | $serializer = new $serializer; |
208 | 208 | } |
209 | 209 | |
210 | - if (! $serializer instanceof SerializerAbstract) { |
|
210 | + if ( ! $serializer instanceof SerializerAbstract ) { |
|
211 | 211 | throw new InvalidSerializerException; |
212 | 212 | } |
213 | 213 | |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function transform(): array |
225 | 225 | { |
226 | - $this->prepareRelations($this->resource->getData(), $this->resource->getTransformer()); |
|
226 | + $this->prepareRelations( $this->resource->getData(), $this->resource->getTransformer() ); |
|
227 | 227 | |
228 | - return $this->transformFactory->make($this->resource ?: new NullResource, $this->serializer, [ |
|
228 | + return $this->transformFactory->make( $this->resource ?: new NullResource, $this->serializer, [ |
|
229 | 229 | 'includes' => $this->with, |
230 | 230 | 'excludes' => $this->without, |
231 | 231 | 'fieldsets' => $this->only, |
232 | - ]); |
|
232 | + ] ); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -239,18 +239,18 @@ discard block |
||
239 | 239 | * @param \Flugg\Responder\Transformers\Transformer|callable|string|null $transformer |
240 | 240 | * @return void |
241 | 241 | */ |
242 | - protected function prepareRelations($data, $transformer) |
|
242 | + protected function prepareRelations( $data, $transformer ) |
|
243 | 243 | { |
244 | - if ($transformer instanceof Transformer) { |
|
245 | - $transformer->setRelations($this->with); |
|
246 | - $this->with($transformer->extractDefaultRelations()); |
|
244 | + if ( $transformer instanceof Transformer ) { |
|
245 | + $transformer->setRelations( $this->with ); |
|
246 | + $this->with( $transformer->extractDefaultRelations() ); |
|
247 | 247 | } |
248 | 248 | |
249 | - if ($data instanceof Model || $data instanceof Collection) { |
|
250 | - $data->load($this->with); |
|
249 | + if ( $data instanceof Model || $data instanceof Collection ) { |
|
250 | + $data->load( $this->with ); |
|
251 | 251 | } |
252 | 252 | |
253 | - $this->with = $this->stripRelations($this->with); |
|
253 | + $this->with = $this->stripRelations( $this->with ); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | * @param array $relations |
260 | 260 | * @return void |
261 | 261 | */ |
262 | - protected function stripRelations(array $relations) |
|
262 | + protected function stripRelations( array $relations ) |
|
263 | 263 | { |
264 | - return collect($relations)->map(function ($value, $key) { |
|
265 | - return is_numeric($key) ? $value : $key; |
|
264 | + return collect( $relations )->map( function ( $value, $key ) { |
|
265 | + return is_numeric( $key ) ? $value : $key; |
|
266 | 266 | })->values()->all(); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | \ No newline at end of file |
@@ -110,8 +110,8 @@ |
||
110 | 110 | /** |
111 | 111 | * Resolve a transformer from the transformable element. |
112 | 112 | * |
113 | - * @param mixed $transformable |
|
114 | - * @return \Flugg\Responder\Contracts\Transformable|callable|null |
|
113 | + * @param Transformable|null $transformable |
|
114 | + * @return callable |
|
115 | 115 | */ |
116 | 116 | protected function resolveTransformer($transformable) |
117 | 117 | { |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @var array |
32 | 32 | */ |
33 | - protected $bindings = []; |
|
33 | + protected $bindings = [ ]; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Construct the resolver class. |
37 | 37 | * |
38 | 38 | * @param \Illuminate\Contracts\Container\Container $container |
39 | 39 | */ |
40 | - public function __construct(Container $container) |
|
40 | + public function __construct( Container $container ) |
|
41 | 41 | { |
42 | 42 | $this->container = $container; |
43 | 43 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | * @param string|callback|null $transformer |
50 | 50 | * @return void |
51 | 51 | */ |
52 | - public function bind($transformable, $transformer = null) |
|
52 | + public function bind( $transformable, $transformer = null ) |
|
53 | 53 | { |
54 | - $this->bindings = array_merge($this->bindings, is_array($transformable) ? $transformable : [ |
|
54 | + $this->bindings = array_merge( $this->bindings, is_array( $transformable ) ? $transformable : [ |
|
55 | 55 | $transformable => $transformer, |
56 | - ]); |
|
56 | + ] ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * @return \Flugg\Responder\Transformers\Transformer|callable |
64 | 64 | * @throws \Flugg\Responder\Exceptions\InvalidTransformerException |
65 | 65 | */ |
66 | - public function resolve($transformer) |
|
66 | + public function resolve( $transformer ) |
|
67 | 67 | { |
68 | - if (is_string($transformer)) { |
|
69 | - return $this->container->make($transformer); |
|
68 | + if ( is_string( $transformer ) ) { |
|
69 | + return $this->container->make( $transformer ); |
|
70 | 70 | } |
71 | 71 | |
72 | - if (! is_callable($transformer) && ! $transformer instanceof Transformer) { |
|
72 | + if ( ! is_callable( $transformer ) && ! $transformer instanceof Transformer ) { |
|
73 | 73 | throw new InvalidTransformerException; |
74 | 74 | } |
75 | 75 | |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | * @param mixed $data |
83 | 83 | * @return \Flugg\Responder\Transformers\Transformer|callable|null |
84 | 84 | */ |
85 | - public function resolveFromData($data) |
|
85 | + public function resolveFromData( $data ) |
|
86 | 86 | { |
87 | - $transformable = $this->resolveTransformable($data); |
|
88 | - $transformer = $this->resolveTransformer($transformable); |
|
87 | + $transformable = $this->resolveTransformable( $data ); |
|
88 | + $transformer = $this->resolveTransformer( $transformable ); |
|
89 | 89 | |
90 | - return $this->resolve($transformer); |
|
90 | + return $this->resolve( $transformer ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @param mixed $data |
97 | 97 | * @return \Flugg\Responder\Contracts\Transformable|null |
98 | 98 | */ |
99 | - protected function resolveTransformable($data) |
|
99 | + protected function resolveTransformable( $data ) |
|
100 | 100 | { |
101 | - if (is_array($data) || $data instanceof Traversable) { |
|
102 | - foreach ($data as $item) { |
|
101 | + if ( is_array( $data ) || $data instanceof Traversable ) { |
|
102 | + foreach ( $data as $item ) { |
|
103 | 103 | return $item; |
104 | 104 | } |
105 | 105 | } |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | * @param mixed $transformable |
114 | 114 | * @return \Flugg\Responder\Contracts\Transformable|callable|null |
115 | 115 | */ |
116 | - protected function resolveTransformer($transformable) |
|
116 | + protected function resolveTransformer( $transformable ) |
|
117 | 117 | { |
118 | - if (is_object($transformable) && key_exists(get_class($transformable), $this->bindings)) { |
|
119 | - return $this->bindings[get_class($transformable)]; |
|
118 | + if ( is_object( $transformable ) && key_exists( get_class( $transformable ), $this->bindings ) ) { |
|
119 | + return $this->bindings[ get_class( $transformable ) ]; |
|
120 | 120 | } |
121 | 121 | |
122 | - if ($transformable instanceof Transformable) { |
|
122 | + if ( $transformable instanceof Transformable ) { |
|
123 | 123 | return $transformable->transformer(); |
124 | 124 | } |
125 | 125 | |
126 | - return function ($data) { |
|
126 | + return function ( $data ) { |
|
127 | 127 | return $data instanceof Arrayable ? $data->toArray() : $data; |
128 | 128 | }; |
129 | 129 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | * @param array $data |
24 | 24 | * @return array |
25 | 25 | */ |
26 | - public function collection($resourceKey, array $data) |
|
26 | + public function collection( $resourceKey, array $data ) |
|
27 | 27 | { |
28 | - return ['data' => $data]; |
|
28 | + return [ 'data' => $data ]; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @param array $data |
36 | 36 | * @return array |
37 | 37 | */ |
38 | - public function item($resourceKey, array $data) |
|
38 | + public function item( $resourceKey, array $data ) |
|
39 | 39 | { |
40 | - return ['data' => $data]; |
|
40 | + return [ 'data' => $data ]; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function null() |
49 | 49 | { |
50 | - return ['data' => null]; |
|
50 | + return [ 'data' => null ]; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param array $meta |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function meta(array $meta) |
|
59 | + public function meta( array $meta ) |
|
60 | 60 | { |
61 | 61 | return $meta; |
62 | 62 | } |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | * @param \League\Fractal\Pagination\PaginatorInterface $paginator |
68 | 68 | * @return array |
69 | 69 | */ |
70 | - public function paginator(PaginatorInterface $paginator) |
|
70 | + public function paginator( PaginatorInterface $paginator ) |
|
71 | 71 | { |
72 | - $pagination = parent::paginator($paginator)['pagination']; |
|
72 | + $pagination = parent::paginator( $paginator )[ 'pagination' ]; |
|
73 | 73 | |
74 | 74 | return [ |
75 | 75 | 'pagination' => [ |
76 | - 'count' => $pagination['count'], |
|
77 | - 'total' => $pagination['total'], |
|
78 | - 'perPage' => $pagination['per_page'], |
|
79 | - 'currentPage' => $pagination['current_page'], |
|
80 | - 'totalPages' => $pagination['total_pages'], |
|
81 | - 'links' => $pagination['links'], |
|
76 | + 'count' => $pagination[ 'count' ], |
|
77 | + 'total' => $pagination[ 'total' ], |
|
78 | + 'perPage' => $pagination[ 'per_page' ], |
|
79 | + 'currentPage' => $pagination[ 'current_page' ], |
|
80 | + 'totalPages' => $pagination[ 'total_pages' ], |
|
81 | + 'links' => $pagination[ 'links' ], |
|
82 | 82 | ], |
83 | 83 | ]; |
84 | 84 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param \League\Fractal\Pagination\CursorInterface $cursor |
90 | 90 | * @return array |
91 | 91 | */ |
92 | - public function cursor(CursorInterface $cursor) |
|
92 | + public function cursor( CursorInterface $cursor ) |
|
93 | 93 | { |
94 | 94 | return [ |
95 | 95 | 'cursor' => [ |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param array $includedData |
119 | 119 | * @return array |
120 | 120 | */ |
121 | - public function mergeIncludes($transformedData, $includedData) |
|
121 | + public function mergeIncludes( $transformedData, $includedData ) |
|
122 | 122 | { |
123 | - foreach (array_keys($includedData) as $key) { |
|
124 | - $includedData[$key] = $includedData[$key]['data']; |
|
123 | + foreach ( array_keys( $includedData ) as $key ) { |
|
124 | + $includedData[ $key ] = $includedData[ $key ][ 'data' ]; |
|
125 | 125 | } |
126 | 126 | |
127 | - return array_merge($transformedData, $includedData); |
|
127 | + return array_merge( $transformedData, $includedData ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @param array $data |
135 | 135 | * @return array |
136 | 136 | */ |
137 | - public function includedData(ResourceInterface $resource, array $data) |
|
137 | + public function includedData( ResourceInterface $resource, array $data ) |
|
138 | 138 | { |
139 | - return []; |
|
139 | + return [ ]; |
|
140 | 140 | } |
141 | 141 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param \Closure $resolver |
36 | 36 | * @return void |
37 | 37 | */ |
38 | - public static function containerResolver(Closure $resolver) |
|
38 | + public static function containerResolver( Closure $resolver ) |
|
39 | 39 | { |
40 | 40 | static::$containerResolver = $resolver; |
41 | 41 | } |
@@ -47,6 +47,6 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function resolveContainer(): Container |
49 | 49 | { |
50 | - return call_user_func(static::$containerResolver); |
|
50 | + return call_user_func( static::$containerResolver ); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @var string[] |
23 | 23 | */ |
24 | - protected $relations = ['*']; |
|
24 | + protected $relations = [ '*' ]; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * A list of autoloaded default relations. |
28 | 28 | * |
29 | 29 | * @var array |
30 | 30 | */ |
31 | - protected $load = []; |
|
31 | + protected $load = [ ]; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Indicates if all relations are allowed. |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function allowsAllRelations(): bool |
39 | 39 | { |
40 | - return $this->relations == ['*']; |
|
40 | + return $this->relations == [ '*' ]; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function getRelations(): array |
49 | 49 | { |
50 | - return array_filter($this->relations, function ($relation) { |
|
50 | + return array_filter( $this->relations, function ( $relation ) { |
|
51 | 51 | return $relation != '*'; |
52 | 52 | }); |
53 | 53 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function getDefaultRelations(): array |
61 | 61 | { |
62 | - return array_keys($this->load); |
|
62 | + return array_keys( $this->load ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function extractDefaultRelations(): array |
71 | 71 | { |
72 | - return collect($this->getDefaultRelationsWithEagerLoads()) |
|
73 | - ->merge(collect($this->load)->map(function ($transformer, $relation) { |
|
74 | - return collect($this->resolveContainer()->make($transformer)->extractDefaultRelations()) |
|
72 | + return collect( $this->getDefaultRelationsWithEagerLoads() ) |
|
73 | + ->merge( collect( $this->load )->map( function ( $transformer, $relation ) { |
|
74 | + return collect( $this->resolveContainer()->make( $transformer )->extractDefaultRelations() ) |
|
75 | 75 | ->keys() |
76 | - ->map(function ($nestedRelation) use ($relation) { |
|
76 | + ->map( function ( $nestedRelation ) use ($relation) { |
|
77 | 77 | return "$relation.$nestedRelation"; |
78 | 78 | }); |
79 | - })) |
|
79 | + }) ) |
|
80 | 80 | ->all(); |
81 | 81 | } |
82 | 82 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function getDefaultRelationsWithEagerLoads(): array |
89 | 89 | { |
90 | - return collect($this->load)->keys()->mapWithKeys(function ($relation) { |
|
91 | - if (method_exists($this, $method = 'load' . ucfirst($relation))) { |
|
92 | - return [$relation => $this->makeEagerLoadCallback($method)]; |
|
90 | + return collect( $this->load )->keys()->mapWithKeys( function ( $relation ) { |
|
91 | + if ( method_exists( $this, $method = 'load' . ucfirst( $relation ) ) ) { |
|
92 | + return [ $relation => $this->makeEagerLoadCallback( $method ) ]; |
|
93 | 93 | } |
94 | 94 | |
95 | - return [$relation => function () { }]; |
|
95 | + return [ $relation => function () { } ]; |
|
96 | 96 | })->all(); |
97 | 97 | } |
98 | 98 | |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | * @param string $method |
103 | 103 | * @return \Closure |
104 | 104 | */ |
105 | - protected function makeEagerLoadCallback(string $method): Closure |
|
105 | + protected function makeEagerLoadCallback( string $method ): Closure |
|
106 | 106 | { |
107 | - return function ($query) use ($method) { |
|
108 | - return $this->$method($query); |
|
107 | + return function ( $query ) use ($method) { |
|
108 | + return $this->$method( $query ); |
|
109 | 109 | }; |
110 | 110 | } |
111 | 111 | |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | * @param string $identifier |
117 | 117 | * @return mixed |
118 | 118 | */ |
119 | - protected function resolveRelation(Model $model, string $identifier) |
|
119 | + protected function resolveRelation( Model $model, string $identifier ) |
|
120 | 120 | { |
121 | - if (method_exists($this, $method = 'filter' . ucfirst($identifier))) { |
|
122 | - return $this->$method($model->$identifier); |
|
121 | + if ( method_exists( $this, $method = 'filter' . ucfirst( $identifier ) ) ) { |
|
122 | + return $this->$method( $model->$identifier ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $model->$identifier; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @var \League\Fractal\ResourceInterface[] |
23 | 23 | */ |
24 | - protected $resources = []; |
|
24 | + protected $resources = [ ]; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Make a resource. |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | * @param string|null $resourceKey |
32 | 32 | * @return \League\Fractal\Resource\ResourceInterface |
33 | 33 | */ |
34 | - protected function resource($data = null, $transformer = null, string $resourceKey = null): ResourceInterface |
|
34 | + protected function resource( $data = null, $transformer = null, string $resourceKey = null ): ResourceInterface |
|
35 | 35 | { |
36 | - $resourceFactory = $this->resolveContainer()->make(ResourceFactory::class); |
|
36 | + $resourceFactory = $this->resolveContainer()->make( ResourceFactory::class ); |
|
37 | 37 | |
38 | - return $resourceFactory->make($data, $transformer, $resourceKey); |
|
38 | + return $resourceFactory->make( $data, $transformer, $resourceKey ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | * @return \League\Fractal\Resource\ResourceInterface |
48 | 48 | * @throws \LogicException |
49 | 49 | */ |
50 | - protected function includeResource(string $identifier, $data, array $parameters): ResourceInterface |
|
50 | + protected function includeResource( string $identifier, $data, array $parameters ): ResourceInterface |
|
51 | 51 | { |
52 | - if (method_exists($this, $method = 'include' . ucfirst($identifier))) { |
|
53 | - $resource = $this->$method($data, $parameters); |
|
54 | - } elseif ($data instanceof Model) { |
|
55 | - $resource = $this->includeResourceFromModel($data, $identifier); |
|
52 | + if ( method_exists( $this, $method = 'include' . ucfirst( $identifier ) ) ) { |
|
53 | + $resource = $this->$method( $data, $parameters ); |
|
54 | + } elseif ( $data instanceof Model ) { |
|
55 | + $resource = $this->includeResourceFromModel( $data, $identifier ); |
|
56 | 56 | } else { |
57 | - throw new LogicException('Relation [' . $identifier . '] not found in [' . get_class($this) . '].'); |
|
57 | + throw new LogicException( 'Relation [' . $identifier . '] not found in [' . get_class( $this ) . '].' ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $resource; |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | * @param string $identifier |
68 | 68 | * @return \League\Fractal\Resource\ResourceInterface |
69 | 69 | */ |
70 | - protected function includeResourceFromModel(Model $model, string $identifier): ResourceInterface |
|
70 | + protected function includeResourceFromModel( Model $model, string $identifier ): ResourceInterface |
|
71 | 71 | { |
72 | - $data = $this->resolveRelation($model, $identifier); |
|
72 | + $data = $this->resolveRelation( $model, $identifier ); |
|
73 | 73 | |
74 | - if (key_exists($identifier, $this->resources)) { |
|
75 | - return $this->resources[$identifier]->setData($data); |
|
74 | + if ( key_exists( $identifier, $this->resources ) ) { |
|
75 | + return $this->resources[ $identifier ]->setData( $data ); |
|
76 | 76 | } |
77 | 77 | |
78 | - return $this->resources[$identifier] = $this->resource($data, null, $identifier); |
|
78 | + return $this->resources[ $identifier ] = $this->resource( $data, null, $identifier ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -92,5 +92,5 @@ discard block |
||
92 | 92 | * @param string $identifier |
93 | 93 | * @return mixed |
94 | 94 | */ |
95 | - protected abstract function resolveRelation(Model $model, string $identifier); |
|
95 | + protected abstract function resolveRelation( Model $model, string $identifier ); |
|
96 | 96 | } |
97 | 97 | \ No newline at end of file |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function getAvailableIncludes() |
24 | 24 | { |
25 | - if ($this->allowsAllRelations()) { |
|
26 | - return $this->resolveScopedIncludes($this->getCurrentScope()); |
|
25 | + if ( $this->allowsAllRelations() ) { |
|
26 | + return $this->resolveScopedIncludes( $this->getCurrentScope() ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return $this->getRelations(); |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param mixed $data |
48 | 48 | * @return \League\Fractal\Resource\ResourceInterface |
49 | 49 | */ |
50 | - protected function callIncludeMethod(Scope $scope, $identifier, $data) |
|
50 | + protected function callIncludeMethod( Scope $scope, $identifier, $data ) |
|
51 | 51 | { |
52 | - $parameters = $this->resolveScopedParameters($scope, $identifier); |
|
52 | + $parameters = $this->resolveScopedParameters( $scope, $identifier ); |
|
53 | 53 | |
54 | - return $this->includeResource($identifier, $data, $parameters); |
|
54 | + return $this->includeResource( $identifier, $data, $parameters ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @param \League\Fractal\Scope $scope |
61 | 61 | * @return array |
62 | 62 | */ |
63 | - protected function resolveScopedIncludes(Scope $scope): array |
|
63 | + protected function resolveScopedIncludes( Scope $scope ): array |
|
64 | 64 | { |
65 | - $level = count($scope->getParentScopes()); |
|
65 | + $level = count( $scope->getParentScopes() ); |
|
66 | 66 | $includes = $scope->getManager()->getRequestedIncludes(); |
67 | 67 | |
68 | - return Collection::make($includes)->map(function ($include) { |
|
69 | - return explode('.', $include); |
|
70 | - })->filter(function ($include) use ($level) { |
|
71 | - return count($include) > $level; |
|
72 | - })->pluck($level)->unique()->all(); |
|
68 | + return Collection::make( $includes )->map( function ( $include ) { |
|
69 | + return explode( '.', $include ); |
|
70 | + })->filter( function ( $include ) use ($level) { |
|
71 | + return count( $include ) > $level; |
|
72 | + })->pluck( $level )->unique()->all(); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param string $identifier |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - protected function resolveScopedParameters(Scope $scope, string $identifier): array |
|
82 | + protected function resolveScopedParameters( Scope $scope, string $identifier ): array |
|
83 | 83 | { |
84 | - return iterator_to_array($scope->getManager()->getIncludeParams($scope->getIdentifier($identifier))); |
|
84 | + return iterator_to_array( $scope->getManager()->getIncludeParams( $scope->getIdentifier( $identifier ) ) ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -120,5 +120,5 @@ discard block |
||
120 | 120 | * @param array $parameters |
121 | 121 | * @return \League\Fractal\Resource\ResourceInterface |
122 | 122 | */ |
123 | - protected abstract function includeResource(string $identifier, $data, array $parameters): ResourceInterface; |
|
123 | + protected abstract function includeResource( string $identifier, $data, array $parameters ): ResourceInterface; |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param \Flugg\Responder\Contracts\ResponseFactory $responseFactory |
38 | 38 | */ |
39 | - public function __construct(ResponseFactory $responseFactory) |
|
39 | + public function __construct( ResponseFactory $responseFactory ) |
|
40 | 40 | { |
41 | 41 | $this->responseFactory = $responseFactory; |
42 | 42 | } |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @param string[]|string $decorator |
48 | 48 | * @return $this |
49 | 49 | */ |
50 | - public function decorator($decorator) |
|
50 | + public function decorator( $decorator ) |
|
51 | 51 | { |
52 | - $decorators = is_array($decorator) ? $decorator : func_get_args(); |
|
52 | + $decorators = is_array( $decorator ) ? $decorator : func_get_args(); |
|
53 | 53 | |
54 | - foreach ($decorators as $decorator) { |
|
55 | - $this->responseFactory = new $decorator($this->responseFactory); |
|
54 | + foreach ( $decorators as $decorator ) { |
|
55 | + $this->responseFactory = new $decorator( $this->responseFactory ); |
|
56 | 56 | }; |
57 | 57 | |
58 | 58 | return $this; |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * @param array $headers |
66 | 66 | * @return \Illuminate\Http\JsonResponse |
67 | 67 | */ |
68 | - public function respond(int $status = null, array $headers = []): JsonResponse |
|
68 | + public function respond( int $status = null, array $headers = [ ] ): JsonResponse |
|
69 | 69 | { |
70 | - if (! is_null($status)) { |
|
71 | - $this->setStatusCode($status); |
|
70 | + if ( ! is_null( $status ) ) { |
|
71 | + $this->setStatusCode( $status ); |
|
72 | 72 | } |
73 | 73 | |
74 | - return $this->responseFactory->make($this->getOutput(), $this->status, $headers); |
|
74 | + return $this->responseFactory->make( $this->getOutput(), $this->status, $headers ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function toArray(): array |
83 | 83 | { |
84 | - return $this->respond()->getData(true); |
|
84 | + return $this->respond()->getData( true ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function toCollection(): Collection |
93 | 93 | { |
94 | - return new Collection($this->toArray()); |
|
94 | + return new Collection( $this->toArray() ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * @param int $options |
101 | 101 | * @return string |
102 | 102 | */ |
103 | - public function toJson($options = 0): string |
|
103 | + public function toJson( $options = 0 ): string |
|
104 | 104 | { |
105 | - return json_encode($this->toArray(), $options); |
|
105 | + return json_encode( $this->toArray(), $options ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @param int $status |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - protected function setStatusCode(int $status) |
|
114 | + protected function setStatusCode( int $status ) |
|
115 | 115 | { |
116 | - $this->validateStatusCode($this->status = $status); |
|
116 | + $this->validateStatusCode( $this->status = $status ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -129,5 +129,5 @@ discard block |
||
129 | 129 | * @param int $status |
130 | 130 | * @return void |
131 | 131 | */ |
132 | - abstract protected function validateStatusCode(int $status); |
|
132 | + abstract protected function validateStatusCode( int $status ); |
|
133 | 133 | } |