Test Failed
Push — v2 ( 45f521...b247ab )
by Alexander
08:12
created
src/Exceptions/ConvertsExceptions.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @var array
34 34
      */
35
-    protected $dontConvert = [];
35
+    protected $dontConvert = [ ];
36 36
 
37 37
     /**
38 38
      * Convert an exception to another exception
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
      * @param  array      $convert
42 42
      * @return void
43 43
      */
44
-    protected function convert(Exception $exception, array $convert)
44
+    protected function convert( Exception $exception, array $convert )
45 45
     {
46
-        foreach ($convert as $source => $target) {
47
-            if ($exception instanceof $source) {
48
-                if (is_callable($target)) {
49
-                    $target($exception);
46
+        foreach ( $convert as $source => $target ) {
47
+            if ( $exception instanceof $source ) {
48
+                if ( is_callable( $target ) ) {
49
+                    $target( $exception );
50 50
                 }
51 51
 
52 52
                 throw new $target;
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
      * @param  \Exception $exception
61 61
      * @return void
62 62
      */
63
-    protected function convertDefaultException(Exception $exception)
63
+    protected function convertDefaultException( Exception $exception )
64 64
     {
65
-        $this->convert($exception, array_diff_key([
65
+        $this->convert( $exception, array_diff_key( [
66 66
             AuthenticationException::class => UnauthenticatedException::class,
67 67
             AuthorizationException::class => UnauthorizedException::class,
68 68
             NotFoundHttpException::class => PageNotFoundException::class,
69 69
             ModelNotFoundException::class => PageNotFoundException::class,
70 70
             BaseRelationNotFoundException::class => RelationNotFoundException::class,
71
-            ValidationException::class => function ($exception) {
72
-                throw new ValidationFailedException($exception->validator);
71
+            ValidationException::class => function ( $exception ) {
72
+                throw new ValidationFailedException( $exception->validator );
73 73
             },
74
-        ], array_flip($this->dontConvert)));
74
+        ], array_flip( $this->dontConvert ) ) );
75 75
     }
76 76
 
77 77
     /**
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
      * @param  \Flugg\Responder\Exceptions\Http\HttpException $exception
81 81
      * @return \Illuminate\Http\JsonResponse
82 82
      */
83
-    protected function renderResponse(HttpException $exception): JsonResponse
83
+    protected function renderResponse( HttpException $exception ): JsonResponse
84 84
     {
85
-        return $this->container->make(Responder::class)
86
-            ->error($exception->errorCode(), $exception->message())
87
-            ->data($exception->data())
88
-            ->respond($exception->statusCode());
85
+        return $this->container->make( Responder::class )
86
+            ->error( $exception->errorCode(), $exception->message() )
87
+            ->data( $exception->data() )
88
+            ->respond( $exception->statusCode() );
89 89
     }
90 90
 }
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
src/Exceptions/Handler.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
24 24
      * @param  \Exception               $exception
25 25
      * @return \Symfony\Component\HttpFoundation\Response
26 26
      */
27
-    public function render($request, Exception $exception)
27
+    public function render( $request, Exception $exception )
28 28
     {
29
-        $this->convertDefaultException($exception);
29
+        $this->convertDefaultException( $exception );
30 30
 
31
-        if ($exception instanceof HttpException) {
32
-            return $this->renderResponse($exception);
31
+        if ( $exception instanceof HttpException ) {
32
+            return $this->renderResponse( $exception );
33 33
         }
34 34
 
35
-        return parent::render($request, $exception);
35
+        return parent::render( $request, $exception );
36 36
     }
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
src/Exceptions/Http/HttpException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      *
47 47
      * @var array
48 48
      */
49
-    protected $headers = [];
49
+    protected $headers = [ ];
50 50
 
51 51
     /**
52 52
      * Construct the exception class.
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
      * @param string|null $message
55 55
      * @param array|null  $headers
56 56
      */
57
-    public function __construct(string $message = null, array $headers = null)
57
+    public function __construct( string $message = null, array $headers = null )
58 58
     {
59
-        parent::__construct($this->status, $message ?? $this->message, null, $headers ?? $this->headers);
59
+        parent::__construct( $this->status, $message ?? $this->message, null, $headers ?? $this->headers );
60 60
     }
61 61
 
62 62
     /**
Please login to merge, or discard this patch.
src/Http/MakesResponses.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
      * @param  string|null                                                    $resourceKey
24 24
      * @return \Flugg\Responder\Http\Responses\SuccessResponseBuilder
25 25
      */
26
-    public function success($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder
26
+    public function success( $data = null, $transformer = null, string $resourceKey = null ): SuccessResponseBuilder
27 27
     {
28
-        return app(Responder::class)->success(...func_get_args());
28
+        return app( Responder::class )->success( ...func_get_args() );
29 29
     }
30 30
 
31 31
     /**
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
      * @param  string|null $message
36 36
      * @return \Flugg\Responder\Http\Responses\ErrorResponseBuilder
37 37
      */
38
-    public function error(string $errorCode = null, string $message = null): ErrorResponseBuilder
38
+    public function error( string $errorCode = null, string $message = null ): ErrorResponseBuilder
39 39
     {
40
-        return app(Responder::class)->error(...func_get_args());
40
+        return app( Responder::class )->error( ...func_get_args() );
41 41
     }
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/Serializers/SuccessSerializer.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/ResponderServiceProvider.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Transformers/Transformer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Transformers/TransformerResolver.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Transformers/Concerns/HasRelationships.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.