Completed
Push — v2 ( 975246...e7bb8d )
by Alexander
05:01
created
src/Contracts/Transformers/TransformerResolver.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      * @param  string|callback $transformer
19 19
      * @return void
20 20
      */
21
-    public function bind($transformable, $transformer);
21
+    public function bind( $transformable, $transformer );
22 22
 
23 23
     /**
24 24
      * Resolve a transformer.
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * @return \Flugg\Responder\Transformers\Transformer|callable
28 28
      * @throws \Flugg\Responder\Exceptions\InvalidTransformerException
29 29
      */
30
-    public function resolve($transformer);
30
+    public function resolve( $transformer );
31 31
 
32 32
     /**
33 33
      * Resolve a transformer from the given data.
@@ -35,5 +35,5 @@  discard block
 block discarded – undo
35 35
      * @param  mixed $data
36 36
      * @return \Flugg\Responder\Transformers\Transformer|callable|null
37 37
      */
38
-    public function resolveFromData($data);
38
+    public function resolveFromData( $data );
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
src/TransformBuilder.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @var array
66 66
      */
67
-    protected $with = [];
67
+    protected $with = [ ];
68 68
 
69 69
     /**
70 70
      * A list of excluded relations.
71 71
      *
72 72
      * @var array
73 73
      */
74
-    protected $without = [];
74
+    protected $without = [ ];
75 75
 
76 76
     /**
77 77
      * A list of sparse fieldsets.
78 78
      *
79 79
      * @var array
80 80
      */
81
-    protected $only = [];
81
+    protected $only = [ ];
82 82
 
83 83
     /**
84 84
      * Construct the builder class.
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param \Flugg\Responder\Contracts\TransformFactory            $transformFactory
88 88
      * @param \Flugg\Responder\Contracts\Pagination\PaginatorFactory $paginatorFactory
89 89
      */
90
-    public function __construct(ResourceFactory $resourceFactory, TransformFactory $transformFactory, PaginatorFactory $paginatorFactory)
90
+    public function __construct( ResourceFactory $resourceFactory, TransformFactory $transformFactory, PaginatorFactory $paginatorFactory )
91 91
     {
92 92
         $this->resourceFactory = $resourceFactory;
93 93
         $this->transformFactory = $transformFactory;
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
      * @param  string|null                                                    $resourceKey
104 104
      * @return self
105 105
      */
106
-    public function resource($data = null, $transformer = null, string $resourceKey = null): TransformBuilder
106
+    public function resource( $data = null, $transformer = null, string $resourceKey = null ): TransformBuilder
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
 block discarded – undo
122 122
      * @param  \League\Fractal\Pagination\Cursor $cursor
123 123
      * @return self
124 124
      */
125
-    public function cursor(Cursor $cursor): TransformBuilder
125
+    public function cursor( Cursor $cursor ): TransformBuilder
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
 block discarded – undo
135 135
      * @param  \League\Fractal\Pagination\IlluminatePaginatorAdapter $paginator
136 136
      * @return self
137 137
      */
138
-    public function paginator(IlluminatePaginatorAdapter $paginator): TransformBuilder
138
+    public function paginator( IlluminatePaginatorAdapter $paginator ): TransformBuilder
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
 block discarded – undo
148 148
      * @param  array $meta
149 149
      * @return self
150 150
      */
151
-    public function meta(array $meta): TransformBuilder
151
+    public function meta( array $meta ): TransformBuilder
152 152
     {
153
-        $this->resource->setMeta($meta);
153
+        $this->resource->setMeta( $meta );
154 154
 
155 155
         return $this;
156 156
     }
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
      * @param  string[]|string $relations
162 162
      * @return self
163 163
      */
164
-    public function with($relations): TransformBuilder
164
+    public function with( $relations ): TransformBuilder
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
 block discarded – undo
174 174
      * @param  string[]|string $relations
175 175
      * @return self
176 176
      */
177
-    public function without($relations): TransformBuilder
177
+    public function without( $relations ): TransformBuilder
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
 block discarded – undo
187 187
      * @param  string[]|string $fields
188 188
      * @return self
189 189
      */
190
-    public function only($fields): TransformBuilder
190
+    public function only( $fields ): TransformBuilder
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
 block discarded – undo
201 201
      * @return self
202 202
      * @throws \Flugg\Responder\Exceptions\InvalidSerializerException
203 203
      */
204
-    public function serializer($serializer): TransformBuilder
204
+    public function serializer( $serializer ): TransformBuilder
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
 
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
     {
226 226
         $this->prepareRelations();
227 227
 
228
-        return $this->transformFactory->make($this->resource, $this->serializer, [
228
+        return $this->transformFactory->make( $this->resource, $this->serializer, [
229 229
             'includes' => $this->with,
230 230
             'excludes' => $this->without,
231 231
             'fields' => $this->only,
232
-        ]);
232
+        ] );
233 233
     }
234 234
 
235 235
     /**
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
      */
240 240
     protected function prepareRelations()
241 241
     {
242
-        $this->setDefaultIncludes($this->resource->getTransformer());
243
-        $this->eagerLoadIfApplicable($this->resource->getData());
242
+        $this->setDefaultIncludes( $this->resource->getTransformer() );
243
+        $this->eagerLoadIfApplicable( $this->resource->getData() );
244 244
 
245
-        $this->with = $this->trimEagerLoadFunctions($this->with);
245
+        $this->with = $this->trimEagerLoadFunctions( $this->with );
246 246
     }
247 247
 
248 248
     /**
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
      * @param \Flugg\Responder\Transformers\Transformer|callable $transformer
252 252
      * @return void
253 253
      */
254
-    protected function setDefaultIncludes($transformer)
254
+    protected function setDefaultIncludes( $transformer )
255 255
     {
256
-        if ($transformer instanceof Transformer) {
257
-            $this->with($transformer->extractDefaultRelations());
256
+        if ( $transformer instanceof Transformer ) {
257
+            $this->with( $transformer->extractDefaultRelations() );
258 258
         }
259 259
     }
260 260
 
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
      * @param  mixed $data
265 265
      * @return void
266 266
      */
267
-    protected function eagerLoadIfApplicable($data)
267
+    protected function eagerLoadIfApplicable( $data )
268 268
     {
269
-        if ($data instanceof Model || $data instanceof Collection) {
270
-            $data->load($this->with);
269
+        if ( $data instanceof Model || $data instanceof Collection ) {
270
+            $data->load( $this->with );
271 271
         }
272 272
     }
273 273
 
@@ -277,10 +277,10 @@  discard block
 block discarded – undo
277 277
      * @param  array $relations
278 278
      * @return void
279 279
      */
280
-    protected function trimEagerLoadFunctions(array $relations)
280
+    protected function trimEagerLoadFunctions( array $relations )
281 281
     {
282
-        return collect($relations)->map(function ($value, $key) {
283
-            return is_numeric($key) ? $value : $key;
282
+        return collect( $relations )->map( function ( $value, $key ) {
283
+            return is_numeric( $key ) ? $value : $key;
284 284
         })->values()->all();
285 285
     }
286 286
 }
287 287
\ No newline at end of file
Please login to merge, or discard this patch.
src/Http/Responses/Factories/LaravelResponseFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @param \Illuminate\Contracts\Routing\ResponseFactory $factory
29 29
      */
30
-    public function __construct(BaseLaravelResponseFactory $factory)
30
+    public function __construct( BaseLaravelResponseFactory $factory )
31 31
     {
32 32
         $this->factory = $factory;
33 33
     }
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
      * @param  array $headers
41 41
      * @return \Illuminate\Http\JsonResponse
42 42
      */
43
-    public function make(array $data, int $status, array $headers = []): JsonResponse
43
+    public function make( array $data, int $status, array $headers = [ ] ): JsonResponse
44 44
     {
45
-        return $this->factory->json($data, $status, $headers);
45
+        return $this->factory->json( $data, $status, $headers );
46 46
     }
47 47
 }
Please login to merge, or discard this patch.
src/Http/Responses/Factories/LumenResponseFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @param \Laravel\Lumen\Http\ResponseFactory $factory
29 29
      */
30
-    public function __construct(BaseLumenResponseFactory $factory)
30
+    public function __construct( BaseLumenResponseFactory $factory )
31 31
     {
32 32
         $this->factory = $factory;
33 33
     }
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
      * @param  array $headers
41 41
      * @return \Illuminate\Http\JsonResponse
42 42
      */
43
-    public function make(array $data, int $status, array $headers = []): JsonResponse
43
+    public function make( array $data, int $status, array $headers = [ ] ): JsonResponse
44 44
     {
45
-        return $this->factory->json($data, $status, $headers);
45
+        return $this->factory->json( $data, $status, $headers );
46 46
     }
47 47
 }
Please login to merge, or discard this patch.
src/Http/Responses/Decorators/SuccessFlagDecorator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
21 21
      * @param  array $headers
22 22
      * @return \Illuminate\Http\JsonResponse
23 23
      */
24
-    public function make(array $data, int $status, array $headers = []): JsonResponse
24
+    public function make( array $data, int $status, array $headers = [ ] ): JsonResponse
25 25
     {
26
-        return $this->factory->make(array_merge([
26
+        return $this->factory->make( array_merge( [
27 27
             'success' => $status >= 100 || $status < 400,
28
-        ], $data), $status, $headers);
28
+        ], $data ), $status, $headers );
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
src/Http/Responses/Decorators/ResponseDecorator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @param \Flugg\Responder\Contracts\ResponseFactory $factory
28 28
      */
29
-    public function __construct(ResponseFactory $factory)
29
+    public function __construct( ResponseFactory $factory )
30 30
     {
31 31
         $this->factory = $factory;
32 32
     }
@@ -39,5 +39,5 @@  discard block
 block discarded – undo
39 39
      * @param  array $headers
40 40
      * @return \Illuminate\Http\JsonResponse
41 41
      */
42
-    abstract public function make(array $data, int $status, array $headers = []): JsonResponse;
42
+    abstract public function make( array $data, int $status, array $headers = [ ] ): JsonResponse;
43 43
 }
Please login to merge, or discard this patch.
src/Http/Responses/Decorators/StatusCodeDecorator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
21 21
      * @param  array $headers
22 22
      * @return \Illuminate\Http\JsonResponse
23 23
      */
24
-    public function make(array $data, int $status, array $headers = []): JsonResponse
24
+    public function make( array $data, int $status, array $headers = [ ] ): JsonResponse
25 25
     {
26
-        return $this->factory->make(array_merge([
26
+        return $this->factory->make( array_merge( [
27 27
             'status' => $status,
28
-        ], $data), $status, $headers);
28
+        ], $data ), $status, $headers );
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
src/Http/Middleware/ConvertToSnakeCase.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
      * @param  array $data
31 31
      * @return array
32 32
      */
33
-    protected function cleanArray(array $data)
33
+    protected function cleanArray( array $data )
34 34
     {
35
-        return collect($data)->mapWithKeys(function ($value, $key) {
36
-            $key = in_array($key, $this->except) ? $key : snake_case($key);
35
+        return collect( $data )->mapWithKeys( function ( $value, $key ) {
36
+            $key = in_array( $key, $this->except ) ? $key : snake_case( $key );
37 37
 
38
-            return [$key => $value];
38
+            return [ $key => $value ];
39 39
         })->all();
40 40
     }
41 41
 }
Please login to merge, or discard this patch.
src/Resources/DataNormalizer.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
      * @param  mixed $data
27 27
      * @return mixed
28 28
      */
29
-    public function normalize($data = null)
29
+    public function normalize( $data = null )
30 30
     {
31
-        if ($data instanceof Builder || $data instanceof CursorPaginator) {
31
+        if ( $data instanceof Builder || $data instanceof CursorPaginator ) {
32 32
             return $data->get();
33
-        } elseif ($data instanceof Paginator) {
33
+        } elseif ( $data instanceof Paginator ) {
34 34
             return $data->getCollection();
35
-        } elseif ($data instanceof Relation) {
36
-            return $this->normalizeRelation($data);
35
+        } elseif ( $data instanceof Relation ) {
36
+            return $this->normalizeRelation( $data );
37 37
         }
38 38
 
39 39
         return $data;
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
      * @param  \Illuminate\Database\Eloquent\Relations\Relation $relation
46 46
      * @return \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|null
47 47
      */
48
-    protected function normalizeRelation(Relation $relation)
48
+    protected function normalizeRelation( Relation $relation )
49 49
     {
50
-        return $this->isSingularRelation($relation) ? $relation->first() : $relation->get();
50
+        return $this->isSingularRelation( $relation ) ? $relation->first() : $relation->get();
51 51
     }
52 52
 
53 53
     /**
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
      * @param  \Illuminate\Database\Eloquent\Relations\Relation $relation
57 57
      * @return bool
58 58
      */
59
-    protected function isSingularRelation(Relation $relation): bool
59
+    protected function isSingularRelation( Relation $relation ): bool
60 60
     {
61
-        $singularRelations = [BelongsTo::class, HasOne::class, MorphOne::class, MorphTo::class];
61
+        $singularRelations = [ BelongsTo::class, HasOne::class, MorphOne::class, MorphTo::class ];
62 62
 
63
-        foreach ($singularRelations as $singularRelation) {
64
-            if ($relation instanceof $singularRelation) {
63
+        foreach ( $singularRelations as $singularRelation ) {
64
+            if ( $relation instanceof $singularRelation ) {
65 65
                 return true;
66 66
             }
67 67
         }
Please login to merge, or discard this patch.