Test Setup Failed
Push — v2 ( 74186a...c94b75 )
by Alexander
06:56
created
src/Providers/LaravelServiceProvider.php 2 patches
Unused Use Statements   -12 removed lines patch added patch discarded remove patch
@@ -2,22 +2,10 @@
 block discarded – undo
2 2
 
3 3
 namespace Flugg\Responder;
4 4
 
5
-use Flugg\Responder\Contracts\ErrorFactory as ErrorFactoryContract;
6
-use Flugg\Responder\Contracts\ErrorSerializer as ErrorSerializerContract;
7
-use Flugg\Responder\Contracts\Responder as ResponderContract;
8 5
 use Flugg\Responder\Contracts\ResponseFactory as ResponseFactoryContract;
9
-use Flugg\Responder\Contracts\Transformer as TransformerContract;
10
-use Flugg\Responder\Contracts\TransformFactory;
11
-use Flugg\Responder\Http\Responses\ErrorResponseBuilder;
12 6
 use Flugg\Responder\Http\Responses\Factories\LaravelResponseFactory;
13
-use Flugg\Responder\Http\Responses\SuccessResponseBuilder;
14
-use Flugg\Responder\Pagination\CursorFactory;
15
-use Flugg\Responder\Pagination\PaginatorFactory;
16
-use Flugg\Responder\Serializers\ErrorSerializer;
17 7
 use Illuminate\Contracts\Routing\ResponseFactory;
18
-use Illuminate\Http\Request;
19 8
 use Illuminate\Support\ServiceProvider as BaseServiceProvider;
20
-use League\Fractal\Manager;
21 9
 
22 10
 /**
23 11
  * A service provider class responsible for bootstrapping the parts of the Laravel package.
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function register()
44 44
     {
45
-        $this->app->bind(ResponseFactoryContract::class, function ($app) {
46
-            $factory = new LaravelResponseFactory($app[ResponseFactory::class]);
45
+        $this->app->bind( ResponseFactoryContract::class, function ( $app ) {
46
+            $factory = new LaravelResponseFactory( $app[ ResponseFactory::class ] );
47 47
 
48
-            foreach ($this->app->config['responder.decorators'] as $decorator) {
49
-                $factory = new $decorator($factory);
48
+            foreach ( $this->app->config[ 'responder.decorators' ] as $decorator ) {
49
+                $factory = new $decorator( $factory );
50 50
             };
51 51
 
52 52
             return $factory;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function boot()
62 62
     {
63
-        $this->publishes([
64
-            __DIR__ . '/../resources/config/responder.php' => config_path('responder.php')
65
-        ], 'config');
66
-        $this->publishes([
67
-            __DIR__ . '/../resources/lang/en/errors.php' => base_path('resources/lang/en/errors.php')
68
-        ], 'lang');
63
+        $this->publishes( [
64
+            __DIR__ . '/../resources/config/responder.php' => config_path( 'responder.php' )
65
+        ], 'config' );
66
+        $this->publishes( [
67
+            __DIR__ . '/../resources/lang/en/errors.php' => base_path( 'resources/lang/en/errors.php' )
68
+        ], 'lang' );
69 69
     }
70 70
 }
71 71
\ No newline at end of file
Please login to merge, or discard this patch.
src/Resources/ResourceFactory.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Flugg\Responder\Contracts\Resources\ResourceFactory as ResourceFactoryContract;
6 6
 use Flugg\Responder\Contracts\Transformers\TransformerResolver;
7
-use Flugg\Responder\Transformers\TransformerManager;
8 7
 use League\Fractal\Resource\Collection as CollectionResource;
9 8
 use League\Fractal\Resource\Item as ItemResource;
10 9
 use League\Fractal\Resource\NullResource;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      * @param \Flugg\Responder\Resources\DataNormalizer                   $normalizer
40 40
      * @param \Flugg\Responder\Contracts\Transformers\TransformerResolver $transformerResolver
41 41
      */
42
-    public function __construct(DataNormalizer $normalizer, TransformerResolver $transformerResolver)
42
+    public function __construct( DataNormalizer $normalizer, TransformerResolver $transformerResolver )
43 43
     {
44 44
         $this->normalizer = $normalizer;
45 45
         $this->transformerResolver = $transformerResolver;
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
      * @param  string|null                                                    $resourceKey
54 54
      * @return \League\Fractal\Resource\ResourceInterface
55 55
      */
56
-    public function make($data = null, $transformer = null, string $resourceKey = null): ResourceInterface
56
+    public function make( $data = null, $transformer = null, string $resourceKey = null ): ResourceInterface
57 57
     {
58
-        if (is_null($data = $this->normalizer->normalize($data))) {
59
-            return $this->instatiateResource($data);
58
+        if ( is_null( $data = $this->normalizer->normalize( $data ) ) ) {
59
+            return $this->instatiateResource( $data );
60 60
         }
61 61
 
62
-        $transformer = $this->resolveTransformer($data, $transformer);
62
+        $transformer = $this->resolveTransformer( $data, $transformer );
63 63
 
64
-        return $this->instatiateResource($data, $transformer, $resourceKey);
64
+        return $this->instatiateResource( $data, $transformer, $resourceKey );
65 65
     }
66 66
 
67 67
     /**
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
      * @param  \Flugg\Responder\Transformers\Transformer|string|callable|null $transformer
72 72
      * @return \Flugg\Responder\Transformers\Transformer|callable
73 73
      */
74
-    protected function resolveTransformer($data, $transformer)
74
+    protected function resolveTransformer( $data, $transformer )
75 75
     {
76
-        if (isset($transformer)) {
77
-            return $this->transformerResolver->resolve($transformer);
76
+        if ( isset($transformer) ) {
77
+            return $this->transformerResolver->resolve( $transformer );
78 78
         }
79 79
 
80
-        return $this->transformerResolver->resolveFromData($data);
80
+        return $this->transformerResolver->resolveFromData( $data );
81 81
     }
82 82
 
83 83
     /**
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
      * @param  string|null                                             $resourceKey
89 89
      * @return \League\Fractal\Resource\ResourceInterface
90 90
      */
91
-    protected function instatiateResource($data, $transformer = null, string $resourceKey = null): ResourceInterface
91
+    protected function instatiateResource( $data, $transformer = null, string $resourceKey = null ): ResourceInterface
92 92
     {
93
-        if (is_null($data)) {
93
+        if ( is_null( $data ) ) {
94 94
             return new NullResource();
95
-        } elseif (is_iterable($data)) {
96
-            return new CollectionResource($data, $transformer, $resourceKey);
95
+        } elseif ( is_iterable( $data ) ) {
96
+            return new CollectionResource( $data, $transformer, $resourceKey );
97 97
         }
98 98
 
99
-        return new ItemResource($data, $transformer, $resourceKey);
99
+        return new ItemResource( $data, $transformer, $resourceKey );
100 100
     }
101 101
 }
102 102
\ No newline at end of file
Please login to merge, or discard this patch.
src/ResponderServiceProvider.php 2 patches
Unused Use Statements   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,12 +7,11 @@
 block discarded – undo
7 7
 use Flugg\Responder\Contracts\ErrorMessageResolver as ErrorMessageResolverContract;
8 8
 use Flugg\Responder\Contracts\ErrorSerializer as ErrorSerializerContract;
9 9
 use Flugg\Responder\Contracts\Pagination\PaginatorFactory as PaginatorFactoryContract;
10
-use Flugg\Responder\Contracts\Resources\TransformerResolver as ResourceFactoryContract;
11 10
 use Flugg\Responder\Contracts\Resources\TransformerResolver as TransformerResolverContract;
12 11
 use Flugg\Responder\Contracts\Responder as ResponderContract;
13 12
 use Flugg\Responder\Contracts\ResponseFactory as ResponseFactoryContract;
14
-use Flugg\Responder\Contracts\Transformer as TransformerContract;
15 13
 use Flugg\Responder\Contracts\TransformFactory as TransformFactoryContract;
14
+use Flugg\Responder\Contracts\Transformer as TransformerContract;
16 15
 use Flugg\Responder\Http\Responses\Factories\LaravelResponseFactory;
17 16
 use Flugg\Responder\Http\Responses\Factories\LumenResponseFactory;
18 17
 use Flugg\Responder\Pagination\PaginatorFactory;
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        if ($this->app instanceof Laravel) {
51
+        if ( $this->app instanceof Laravel ) {
52 52
             $this->registerLaravelBindings();
53
-        } elseif ($this->app instanceof Lumen) {
53
+        } elseif ( $this->app instanceof Lumen ) {
54 54
             $this->registerLumenBindings();
55 55
         }
56 56
 
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
      */
71 71
     protected function registerLaravelBindings()
72 72
     {
73
-        $this->app->bind(ResponseFactoryContract::class, function ($app) {
74
-            return $this->decorateResponseFactory($app->make(LaravelResponseFactory::class));
73
+        $this->app->bind( ResponseFactoryContract::class, function ( $app ) {
74
+            return $this->decorateResponseFactory( $app->make( LaravelResponseFactory::class ) );
75 75
         });
76 76
     }
77 77
 
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
      */
83 83
     protected function registerLumenBindings()
84 84
     {
85
-        $this->app->bind(ResponseFactoryContract::class, function ($app) {
86
-            return $this->decorateResponseFactory($app->make(LumenResponseFactory::class));
85
+        $this->app->bind( ResponseFactoryContract::class, function ( $app ) {
86
+            return $this->decorateResponseFactory( $app->make( LumenResponseFactory::class ) );
87 87
         });
88 88
     }
89 89
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      * @param  \Flugg\Responder\Contracts\ResponseFactory $factory
94 94
      * @return void
95 95
      */
96
-    protected function decorateResponseFactory(ResponseFactoryContract $factory)
96
+    protected function decorateResponseFactory( ResponseFactoryContract $factory )
97 97
     {
98
-        foreach ($this->app->config['responder.decorators'] as $decorator) {
99
-            $factory = new $decorator($factory);
98
+        foreach ( $this->app->config[ 'responder.decorators' ] as $decorator ) {
99
+            $factory = new $decorator( $factory );
100 100
         };
101 101
 
102 102
         return $factory;
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function registerSerializerBindings()
111 111
     {
112
-        $this->app->bind(ErrorSerializerContract::class, function ($app) {
113
-            return $app->make($app->config['responder.serializers.error']);
112
+        $this->app->bind( ErrorSerializerContract::class, function ( $app ) {
113
+            return $app->make( $app->config[ 'responder.serializers.error' ] );
114 114
         });
115 115
 
116
-        $this->app->bind(SerializerAbstract::class, function ($app) {
117
-            return $app->make($app->config['responder.serializers.success']);
116
+        $this->app->bind( SerializerAbstract::class, function ( $app ) {
117
+            return $app->make( $app->config[ 'responder.serializers.success' ] );
118 118
         });
119 119
     }
120 120
 
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function registerErrorBindings()
127 127
     {
128
-        $this->app->bind(ErrorMessageResolverContract::class, function () {
129
-            return $app->make(ErrorMessageResolver::class);
128
+        $this->app->bind( ErrorMessageResolverContract::class, function () {
129
+            return $app->make( ErrorMessageResolver::class );
130 130
         });
131 131
 
132
-        $this->app->bind(ErrorFactoryContract::class, function ($app) {
133
-            return $app->make(ErrorFactory::class);
132
+        $this->app->bind( ErrorFactoryContract::class, function ( $app ) {
133
+            return $app->make( ErrorFactory::class );
134 134
         });
135 135
     }
136 136
 
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
      */
142 142
     protected function registerFractalBindings()
143 143
     {
144
-        $this->app->bind(Manager::class, function ($app) {
145
-            return $app->make(Manager::class)->setRecursionLimit($app->config['responder.recursion_limit']);
144
+        $this->app->bind( Manager::class, function ( $app ) {
145
+            return $app->make( Manager::class )->setRecursionLimit( $app->config[ 'responder.recursion_limit' ] );
146 146
         });
147 147
     }
148 148
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
      */
154 154
     protected function registerResourceBindings()
155 155
     {
156
-        $this->app->bind(ResourceFactoryContract::class, function ($app) {
157
-            return $app->make(ResourceFactory::class);
156
+        $this->app->bind( ResourceFactoryContract::class, function ( $app ) {
157
+            return $app->make( ResourceFactory::class );
158 158
         });
159 159
     }
160 160
 
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
      */
166 166
     protected function registerPaginationBindings()
167 167
     {
168
-        $this->app->bind(PaginatorFactoryContract::class, function ($app) {
169
-            return new PaginatorFactory($app->make(Request::class)->query());
168
+        $this->app->bind( PaginatorFactoryContract::class, function ( $app ) {
169
+            return new PaginatorFactory( $app->make( Request::class )->query() );
170 170
         });
171 171
     }
172 172
 
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
      */
178 178
     protected function registerTransformationBindings()
179 179
     {
180
-        $this->app->bind(TransformFactoryContract::class, function () {
181
-            return $app->make(FractalTransformFactory::class);
180
+        $this->app->bind( TransformFactoryContract::class, function () {
181
+            return $app->make( FractalTransformFactory::class );
182 182
         });
183 183
 
184
-        $this->app->bind(TransformBuilder::class, function ($app) {
185
-            return $app->make(TransformBuilder::class)
186
-                ->serializer($app->make(SerializerAbstract::class))
187
-                ->with($app->make(Request::class)->input($app->config['responder.load_relations_parameter'], []))
188
-                ->only($app->make(Request::class)->input($app->config['responder.filter_fields_parameter'], []));
184
+        $this->app->bind( TransformBuilder::class, function ( $app ) {
185
+            return $app->make( TransformBuilder::class )
186
+                ->serializer( $app->make( SerializerAbstract::class ) )
187
+                ->with( $app->make( Request::class )->input( $app->config[ 'responder.load_relations_parameter' ], [ ] ) )
188
+                ->only( $app->make( Request::class )->input( $app->config[ 'responder.filter_fields_parameter' ], [ ] ) );
189 189
         });
190 190
 
191
-        $this->app->bind(TransformerResolverContract::class, function ($app) {
192
-            return $app->make(TransformerResolver::class);
191
+        $this->app->bind( TransformerResolverContract::class, function ( $app ) {
192
+            return $app->make( TransformerResolver::class );
193 193
         });
194 194
     }
195 195
 
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
      */
201 201
     protected function registerServiceBindings()
202 202
     {
203
-        $this->app->bind(ResponderContract::class, function ($app) {
204
-            return $app->make(Responder::class);
203
+        $this->app->bind( ResponderContract::class, function ( $app ) {
204
+            return $app->make( Responder::class );
205 205
         });
206 206
 
207
-        $this->app->bind(TransformerContract::class, function ($app) {
208
-            return $app->make(Transformer::class);
207
+        $this->app->bind( TransformerContract::class, function ( $app ) {
208
+            return $app->make( Transformer::class );
209 209
         });
210 210
     }
211 211
 
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
      */
217 217
     public function boot()
218 218
     {
219
-        if ($this->app instanceof Laravel) {
219
+        if ( $this->app instanceof Laravel ) {
220 220
             $this->bootLaravelApplication();
221
-        } elseif ($this->app instanceof Lumen) {
221
+        } elseif ( $this->app instanceof Lumen ) {
222 222
             $this->bootLumenApplication();
223 223
         }
224 224
 
225
-        $this->mergeConfigFrom(__DIR__ . '/../config/responder.php', 'responder');
226
-        $this->commands(MakeTransformer::class);
225
+        $this->mergeConfigFrom( __DIR__ . '/../config/responder.php', 'responder' );
226
+        $this->commands( MakeTransformer::class );
227 227
     }
228 228
 
229 229
     /**
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
      */
234 234
     protected function bootLaravelApplication()
235 235
     {
236
-        if ($this->app->runningInConsole()) {
237
-            $this->publishes([
238
-                __DIR__ . '/../resources/config/responder.php' => config_path('responder.php'),
239
-            ], 'config');
236
+        if ( $this->app->runningInConsole() ) {
237
+            $this->publishes( [
238
+                __DIR__ . '/../resources/config/responder.php' => config_path( 'responder.php' ),
239
+            ], 'config' );
240 240
 
241
-            $this->publishes([
242
-                __DIR__ . '/../resources/lang/en/errors.php' => base_path('resources/lang/en/errors.php'),
243
-            ], 'lang');
241
+            $this->publishes( [
242
+                __DIR__ . '/../resources/lang/en/errors.php' => base_path( 'resources/lang/en/errors.php' ),
243
+            ], 'lang' );
244 244
         }
245 245
     }
246 246
 
@@ -251,6 +251,6 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function bootLumenApplication()
253 253
     {
254
-        $this->app->configure('responder');
254
+        $this->app->configure( 'responder' );
255 255
     }
256 256
 }
257 257
\ No newline at end of file
Please login to merge, or discard this patch.
src/TransformBuilder.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     /**
159 159
      * Include relations to the transform.
160 160
      *
161
-     * @param  string[]|string $relations
161
+     * @param  string[] $relations
162 162
      * @return self
163 163
      */
164 164
     public function with($relations): TransformBuilder
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     /**
172 172
      * Exclude relations from the transform.
173 173
      *
174
-     * @param  string[]|string $relations
174
+     * @param  string[] $relations
175 175
      * @return self
176 176
      */
177 177
     public function without($relations): TransformBuilder
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     /**
198 198
      * Set the serializer.
199 199
      *
200
-     * @param  \League\Fractal\Serializer\SerializerAbstract|string $serializer
200
+     * @param  Serializers\NullSerializer $serializer
201 201
      * @return self
202 202
      * @throws \Flugg\Responder\Exceptions\InvalidSerializerException
203 203
      */
Please login to merge, or discard this 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/Transformers/TransformerResolver.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
     /**
130 130
      * Make a simple closure transformer.
131 131
      *
132
-     * @return callable
132
+     * @return \Closure
133 133
      */
134 134
     protected function makeClosureTransformer(): callable
135 135
     {
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 namespace Flugg\Responder\Transformers;
4 4
 
5
-use Flugg\Responder\Contracts\Transformers\TransformerResolver as TransformerResolverContract;
6 5
 use Flugg\Responder\Contracts\Transformable;
6
+use Flugg\Responder\Contracts\Transformers\TransformerResolver as TransformerResolverContract;
7 7
 use Flugg\Responder\Exceptions\InvalidTransformerException;
8 8
 use Illuminate\Contracts\Container\Container;
9 9
 use Illuminate\Contracts\Support\Arrayable;
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @var array
31 31
      */
32
-    protected $bindings = [];
32
+    protected $bindings = [ ];
33 33
 
34 34
     /**
35 35
      * Construct the resolver class.
36 36
      *
37 37
      * @param \Illuminate\Contracts\Container\Container $container
38 38
      */
39
-    public function __construct(Container $container)
39
+    public function __construct( Container $container )
40 40
     {
41 41
         $this->container = $container;
42 42
     }
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
      * @param  string|callback $transformer
49 49
      * @return void
50 50
      */
51
-    public function bind($transformable, $transformer)
51
+    public function bind( $transformable, $transformer )
52 52
     {
53
-        $this->bindings = array_merge($this->bindings, is_array($transformable) ? $transformable : [
53
+        $this->bindings = array_merge( $this->bindings, is_array( $transformable ) ? $transformable : [
54 54
             $transformable => $transformer,
55
-        ]);
55
+        ] );
56 56
     }
57 57
 
58 58
     /**
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
      * @return \Flugg\Responder\Transformers\Transformer|callable
63 63
      * @throws \Flugg\Responder\Exceptions\InvalidTransformerException
64 64
      */
65
-    public function resolve($transformer)
65
+    public function resolve( $transformer )
66 66
     {
67
-        if (is_string($transformer)) {
68
-            return $this->container->make($transformer);
67
+        if ( is_string( $transformer ) ) {
68
+            return $this->container->make( $transformer );
69 69
         }
70 70
 
71
-        if (! is_callable($transformer) && ! $transformer instanceof Transformer) {
71
+        if ( ! is_callable( $transformer ) && ! $transformer instanceof Transformer ) {
72 72
             throw new InvalidTransformerException;
73 73
         }
74 74
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
      * @param  mixed $data
82 82
      * @return \Flugg\Responder\Transformers\Transformer|callable|null
83 83
      */
84
-    public function resolveFromData($data)
84
+    public function resolveFromData( $data )
85 85
     {
86
-        if ($transformable = $this->resolveTransformable($data)) {
87
-            if ($transformer = $this->resolveTransformer()) {
88
-                return $this->resolve($transformer);
86
+        if ( $transformable = $this->resolveTransformable( $data ) ) {
87
+            if ( $transformer = $this->resolveTransformer() ) {
88
+                return $this->resolve( $transformer );
89 89
             }
90 90
         }
91 91
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
      * @param  mixed $data
99 99
      * @return \Flugg\Responder\Contracts\Transformable|null
100 100
      */
101
-    protected function resolveTransformable($data)
101
+    protected function resolveTransformable( $data )
102 102
     {
103
-        if (is_iterable($data)) {
104
-            foreach ($data as $item) {
105
-                if ($item instanceof Transformable) {
103
+        if ( is_iterable( $data ) ) {
104
+            foreach ( $data as $item ) {
105
+                if ( $item instanceof Transformable ) {
106 106
                     return $item;
107 107
                 }
108 108
             }
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
      * @param  \Flugg\Responder\Contracts\Transformable $transformable
118 118
      * @return \Flugg\Responder\Contracts\Transformable|null
119 119
      */
120
-    protected function resolveTransformer(Transformable $transformable)
120
+    protected function resolveTransformer( Transformable $transformable )
121 121
     {
122
-        if (key_exists($this->bindings, get_class($transformable))) {
123
-            return $this->bindings[get_class($transformable)];
122
+        if ( key_exists( $this->bindings, get_class( $transformable ) ) ) {
123
+            return $this->bindings[ get_class( $transformable ) ];
124 124
         }
125 125
 
126 126
         return $transformable->transformer();
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     protected function makeClosureTransformer(): callable
135 135
     {
136
-        return function ($data) {
136
+        return function ( $data ) {
137 137
             return $data instanceof Arrayable ? $data->toArray() : $data;
138 138
         };
139 139
     }
Please login to merge, or discard this patch.
src/ErrorFactory.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * @param \Flugg\Responder\Contracts\ErrorMessageResolver $messageResolver
36 36
      * @param \Flugg\Responder\Contracts\ErrorSerializer      $serializer
37 37
      */
38
-    public function __construct(ErrorMessageResolver $messageResolver, ErrorSerializer $serializer)
38
+    public function __construct( ErrorMessageResolver $messageResolver, ErrorSerializer $serializer )
39 39
     {
40 40
         $this->messageResolver = $messageResolver;
41 41
         $this->serializer = $serializer;
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
      * @param  array|null  $data
50 50
      * @return array
51 51
      */
52
-    public function make(string $errorCode = null, string $message = null, array $data = null): array
52
+    public function make( string $errorCode = null, string $message = null, array $data = null ): array
53 53
     {
54
-        if (isset($errorCode) && ! isset($message)) {
55
-            $message = $this->messageResolver->resolve($errorCode);
54
+        if ( isset($errorCode) && ! isset($message) ) {
55
+            $message = $this->messageResolver->resolve( $errorCode );
56 56
         }
57 57
 
58
-        return $this->serializer->format($errorCode, $message, $data);
58
+        return $this->serializer->format( $errorCode, $message, $data );
59 59
     }
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
src/Pagination/PaginatorFactory.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @param array $parameters
31 31
      */
32
-    public function __construct(array $parameters)
32
+    public function __construct( array $parameters )
33 33
     {
34 34
         $this->parameters = $parameters;
35 35
     }
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
      * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
41 41
      * @return \League\Fractal\Pagination\PaginatorInterface
42 42
      */
43
-    public function make(LengthAwarePaginator $paginator): PaginatorInterface
43
+    public function make( LengthAwarePaginator $paginator ): PaginatorInterface
44 44
     {
45
-        $paginator->appends($this->parameters);
45
+        $paginator->appends( $this->parameters );
46 46
 
47
-        return new IlluminatePaginatorAdapter($paginator);
47
+        return new IlluminatePaginatorAdapter( $paginator );
48 48
     }
49 49
 
50 50
     /**
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      * @param  \Flugg\Responder\Pagination\CursorPaginator $paginator
54 54
      * @return \League\Fractal\Pagination\Cursor
55 55
      */
56
-    public function makeCursor(CursorPaginator $paginator): Cursor
56
+    public function makeCursor( CursorPaginator $paginator ): Cursor
57 57
     {
58
-        $paginator->appends($this->parameters);
58
+        $paginator->appends( $this->parameters );
59 59
 
60
-        return new Cursor($paginator->cursor(), $paginator->previous(), $paginator->next(), $paginator->get()->count());
60
+        return new Cursor( $paginator->cursor(), $paginator->previous(), $paginator->next(), $paginator->get()->count() );
61 61
     }
62 62
 }
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/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.