Passed
Push — v2 ( 1005f4...220fbf )
by Alexander
02:47
created
src/Contracts/Responder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * @param  string|null $message
22 22
      * @return \Flugg\Responder\Http\Responses\ErrorResponseBuilder
23 23
      */
24
-    public function error(string $errorCode = null, string $message = null): ErrorResponseBuilder;
24
+    public function error( string $errorCode = null, string $message = null ): ErrorResponseBuilder;
25 25
 
26 26
     /**
27 27
      * Build a successful response.
@@ -31,5 +31,5 @@  discard block
 block discarded – undo
31 31
      * @param  string|null                                                    $resourceKey
32 32
      * @return \Flugg\Responder\Http\Responses\SuccessResponseBuilder
33 33
      */
34
-    public function success($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder;
34
+    public function success( $data = null, $transformer = null, string $resourceKey = null ): SuccessResponseBuilder;
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
src/Contracts/ResponseFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,5 +21,5 @@
 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
 }
Please login to merge, or discard this patch.
src/Contracts/Pagination/PaginatorFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
23 23
      * @return \League\Fractal\Pagination\PaginatorInterface
24 24
      */
25
-    public function make(LengthAwarePaginator $paginator): PaginatorInterface;
25
+    public function make( LengthAwarePaginator $paginator ): PaginatorInterface;
26 26
 
27 27
     /**
28 28
      * Make a Fractal paginator adapter from a Laravel paginator.
@@ -30,5 +30,5 @@  discard block
 block discarded – undo
30 30
      * @param  \Flugg\Responder\Pagination\CursorPaginator $paginator
31 31
      * @return \League\Fractal\Pagination\Cursor
32 32
      */
33
-    public function makeCursor(CursorPaginator $paginator): Cursor;
33
+    public function makeCursor( CursorPaginator $paginator ): Cursor;
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
src/Contracts/TransformFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,5 +22,5 @@
 block discarded – undo
22 22
      * @param  array                                         $options
23 23
      * @return array
24 24
      */
25
-    public function make(ResourceInterface $resource, SerializerAbstract $serializer, array $options = []): array;
25
+    public function make( ResourceInterface $resource, SerializerAbstract $serializer, array $options = [ ] ): array;
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/Contracts/ErrorSerializer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,5 +19,5 @@
 block discarded – undo
19 19
      * @param  array|null  $data
20 20
      * @return array
21 21
      */
22
-    public function format(string $errorCode = null, string $message = null, array $data = null): array;
22
+    public function format( string $errorCode = null, string $message = null, array $data = null ): array;
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
src/Contracts/Resources/ResourceFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,5 +21,5 @@
 block discarded – undo
21 21
      * @param  string|null                                                    $resourceKey
22 22
      * @return \League\Fractal\Resource\ResourceInterface
23 23
      */
24
-    public function make($data = null, $transformer = null, string $resourceKey = null): ResourceInterface;
24
+    public function make( $data = null, $transformer = null, string $resourceKey = null ): ResourceInterface;
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
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/Console/MakeTransformer.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     protected function getStub()
44 44
     {
45
-        if ($this->option('model')) {
45
+        if ( $this->option( 'model' ) ) {
46 46
             return __DIR__ . '../../resources/stubs/transformer.model.stub';
47 47
         }
48 48
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @param  string $rootNamespace
56 56
      * @return string
57 57
      */
58
-    protected function getDefaultNamespace($rootNamespace)
58
+    protected function getDefaultNamespace( $rootNamespace )
59 59
     {
60 60
         return $rootNamespace . '\Transformers';
61 61
     }
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
      * @param  string $name
67 67
      * @return string
68 68
      */
69
-    protected function buildClass($name)
69
+    protected function buildClass( $name )
70 70
     {
71
-        $replace = [];
71
+        $replace = [ ];
72 72
 
73
-        if ($this->option('model')) {
74
-            $replace = $this->buildModelReplacements($replace);
73
+        if ( $this->option( 'model' ) ) {
74
+            $replace = $this->buildModelReplacements( $replace );
75 75
         }
76 76
 
77
-        return str_replace(array_keys($replace), array_values($replace), parent::buildClass($name));
77
+        return str_replace( array_keys( $replace ), array_values( $replace ), parent::buildClass( $name ) );
78 78
     }
79 79
 
80 80
     /**
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
      * @param  array $replace
84 84
      * @return array
85 85
      */
86
-    protected function buildModelReplacements(array $replace)
86
+    protected function buildModelReplacements( array $replace )
87 87
     {
88
-        $model = $this->qualifyClass($this->option('model'));
88
+        $model = $this->qualifyClass( $this->option( 'model' ) );
89 89
 
90
-        return array_merge($replace, [
90
+        return array_merge( $replace, [
91 91
             'DummyFullModelClass' => $model,
92
-            'DummyModelClass' => class_basename($model),
93
-            'DummyModelVariable' => lcfirst(class_basename($model)),
94
-        ]);
92
+            'DummyModelClass' => class_basename( $model ),
93
+            'DummyModelVariable' => lcfirst( class_basename( $model ) ),
94
+        ] );
95 95
     }
96 96
 
97 97
     /**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     protected function getOptions()
103 103
     {
104 104
         return [
105
-            ['model', 'm', InputOption::VALUE_OPTIONAL, 'Generate a model transformerl.'],
105
+            [ 'model', 'm', InputOption::VALUE_OPTIONAL, 'Generate a model transformerl.' ],
106 106
         ];
107 107
     }
108 108
 }
109 109
\ No newline at end of file
Please login to merge, or discard this patch.