Test Failed
Push — v2 ( 45f521...b247ab )
by Alexander
08:12
created
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.
src/Transformers/Concerns/MakesResources.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @var \League\Fractal\ResourceInterface[]
23 23
      */
24
-    protected $resources = [];
24
+    protected $resources = [ ];
25 25
 
26 26
     /**
27 27
      * Make a resource.
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
      * @param  string|null                                                    $resourceKey
32 32
      * @return \League\Fractal\Resource\ResourceInterface
33 33
      */
34
-    protected function resource($data = null, $transformer = null, string $resourceKey = null): ResourceInterface
34
+    protected function resource( $data = null, $transformer = null, string $resourceKey = null ): ResourceInterface
35 35
     {
36
-        $resourceFactory = $this->resolveContainer()->make(ResourceFactory::class);
36
+        $resourceFactory = $this->resolveContainer()->make( ResourceFactory::class );
37 37
 
38
-        return $resourceFactory->make($data, $transformer, $resourceKey);
38
+        return $resourceFactory->make( $data, $transformer, $resourceKey );
39 39
     }
40 40
 
41 41
     /**
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
      * @return \League\Fractal\Resource\ResourceInterface
48 48
      * @throws \LogicException
49 49
      */
50
-    protected function includeResource(string $identifier, $data, array $parameters): ResourceInterface
50
+    protected function includeResource( string $identifier, $data, array $parameters ): ResourceInterface
51 51
     {
52
-        if (method_exists($this, $method = 'include' . ucfirst($identifier))) {
53
-            $resource = $this->$method($data, $parameters);
54
-        } elseif ($data instanceof Model) {
55
-            $resource = $this->includeResourceFromModel($data, $identifier);
52
+        if ( method_exists( $this, $method = 'include' . ucfirst( $identifier ) ) ) {
53
+            $resource = $this->$method( $data, $parameters );
54
+        } elseif ( $data instanceof Model ) {
55
+            $resource = $this->includeResourceFromModel( $data, $identifier );
56 56
         } else {
57
-            throw new LogicException('Relation [' . $identifier . '] not found in [' . get_class($this) . '].');
57
+            throw new LogicException( 'Relation [' . $identifier . '] not found in [' . get_class( $this ) . '].' );
58 58
         }
59 59
 
60 60
         return $resource;
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
      * @param string                              $identifier
68 68
      * @return \League\Fractal\Resource\ResourceInterface
69 69
      */
70
-    protected function includeResourceFromModel(Model $model, string $identifier): ResourceInterface
70
+    protected function includeResourceFromModel( Model $model, string $identifier ): ResourceInterface
71 71
     {
72
-        $data = $this->resolveRelation($model, $identifier);
72
+        $data = $this->resolveRelation( $model, $identifier );
73 73
 
74
-        if (key_exists($identifier, $this->resources)) {
75
-            return $this->resources[$identifier]->setData($data);
74
+        if ( key_exists( $identifier, $this->resources ) ) {
75
+            return $this->resources[ $identifier ]->setData( $data );
76 76
         }
77 77
 
78
-        return $this->resources[$identifier] = $this->resource($data, null, $identifier);
78
+        return $this->resources[ $identifier ] = $this->resource( $data, null, $identifier );
79 79
     }
80 80
 
81 81
     /**
@@ -92,5 +92,5 @@  discard block
 block discarded – undo
92 92
      * @param  string                              $identifier
93 93
      * @return mixed
94 94
      */
95
-    protected abstract function resolveRelation(Model $model, string $identifier);
95
+    protected abstract function resolveRelation( Model $model, string $identifier );
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
src/Transformers/Concerns/OverridesFractal.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function getAvailableIncludes()
24 24
     {
25
-        if ($this->allowsAllRelations()) {
26
-            return $this->resolveScopedIncludes($this->getCurrentScope());
25
+        if ( $this->allowsAllRelations() ) {
26
+            return $this->resolveScopedIncludes( $this->getCurrentScope() );
27 27
         }
28 28
 
29 29
         return $this->getRelations();
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
      * @param  mixed                 $data
48 48
      * @return \League\Fractal\Resource\ResourceInterface
49 49
      */
50
-    protected function callIncludeMethod(Scope $scope, $identifier, $data)
50
+    protected function callIncludeMethod( Scope $scope, $identifier, $data )
51 51
     {
52
-        $parameters = $this->resolveScopedParameters($scope, $identifier);
52
+        $parameters = $this->resolveScopedParameters( $scope, $identifier );
53 53
 
54
-        return $this->includeResource($identifier, $data, $parameters);
54
+        return $this->includeResource( $identifier, $data, $parameters );
55 55
     }
56 56
 
57 57
     /**
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
      * @param  \League\Fractal\Scope $scope
61 61
      * @return array
62 62
      */
63
-    protected function resolveScopedIncludes(Scope $scope): array
63
+    protected function resolveScopedIncludes( Scope $scope ): array
64 64
     {
65
-        $level = count($scope->getParentScopes());
65
+        $level = count( $scope->getParentScopes() );
66 66
         $includes = $scope->getManager()->getRequestedIncludes();
67 67
 
68
-        return Collection::make($includes)->map(function ($include) {
69
-            return explode('.', $include);
70
-        })->filter(function ($include) use ($level) {
71
-            return count($include) > $level;
72
-        })->pluck($level)->unique()->all();
68
+        return Collection::make( $includes )->map( function ( $include ) {
69
+            return explode( '.', $include );
70
+        })->filter( function ( $include ) use ($level) {
71
+            return count( $include ) > $level;
72
+        })->pluck( $level )->unique()->all();
73 73
     }
74 74
 
75 75
     /**
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      * @param  string                $identifier
80 80
      * @return array
81 81
      */
82
-    protected function resolveScopedParameters(Scope $scope, string $identifier): array
82
+    protected function resolveScopedParameters( Scope $scope, string $identifier ): array
83 83
     {
84
-        return iterator_to_array($scope->getManager()->getIncludeParams($scope->getIdentifier($identifier)));
84
+        return iterator_to_array( $scope->getManager()->getIncludeParams( $scope->getIdentifier( $identifier ) ) );
85 85
     }
86 86
 
87 87
     /**
@@ -120,5 +120,5 @@  discard block
 block discarded – undo
120 120
      * @param  array  $parameters
121 121
      * @return \League\Fractal\Resource\ResourceInterface
122 122
      */
123
-    protected abstract function includeResource(string $identifier, $data, array $parameters): ResourceInterface;
123
+    protected abstract function includeResource( string $identifier, $data, array $parameters ): ResourceInterface;
124 124
 }
125 125
\ No newline at end of file
Please login to merge, or discard this patch.
src/Http/Responses/ResponseBuilder.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @param \Flugg\Responder\Contracts\ResponseFactory $responseFactory
38 38
      */
39
-    public function __construct(ResponseFactory $responseFactory)
39
+    public function __construct( ResponseFactory $responseFactory )
40 40
     {
41 41
         $this->responseFactory = $responseFactory;
42 42
     }
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
      * @param  string[]|string $decorator
48 48
      * @return $this
49 49
      */
50
-    public function decorator($decorator)
50
+    public function decorator( $decorator )
51 51
     {
52
-        $decorators = is_array($decorator) ? $decorator : func_get_args();
52
+        $decorators = is_array( $decorator ) ? $decorator : func_get_args();
53 53
 
54
-        foreach ($decorators as $decorator) {
55
-            $this->responseFactory = new $decorator($this->responseFactory);
54
+        foreach ( $decorators as $decorator ) {
55
+            $this->responseFactory = new $decorator( $this->responseFactory );
56 56
         };
57 57
 
58 58
         return $this;
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
      * @param  array    $headers
66 66
      * @return \Illuminate\Http\JsonResponse
67 67
      */
68
-    public function respond(int $status = null, array $headers = []): JsonResponse
68
+    public function respond( int $status = null, array $headers = [ ] ): JsonResponse
69 69
     {
70
-        if (! is_null($status)) {
71
-            $this->setStatusCode($status);
70
+        if ( ! is_null( $status ) ) {
71
+            $this->setStatusCode( $status );
72 72
         }
73 73
 
74
-        return $this->responseFactory->make($this->getOutput(), $this->status, $headers);
74
+        return $this->responseFactory->make( $this->getOutput(), $this->status, $headers );
75 75
     }
76 76
 
77 77
     /**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function toArray(): array
83 83
     {
84
-        return $this->respond()->getData(true);
84
+        return $this->respond()->getData( true );
85 85
     }
86 86
 
87 87
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function toCollection(): Collection
93 93
     {
94
-        return new Collection($this->toArray());
94
+        return new Collection( $this->toArray() );
95 95
     }
96 96
 
97 97
     /**
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
      * @param  int $options
101 101
      * @return string
102 102
      */
103
-    public function toJson($options = 0): string
103
+    public function toJson( $options = 0 ): string
104 104
     {
105
-        return json_encode($this->toArray(), $options);
105
+        return json_encode( $this->toArray(), $options );
106 106
     }
107 107
 
108 108
     /**
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
      * @param  int $status
112 112
      * @return void
113 113
      */
114
-    protected function setStatusCode(int $status)
114
+    protected function setStatusCode( int $status )
115 115
     {
116
-        $this->validateStatusCode($this->status = $status);
116
+        $this->validateStatusCode( $this->status = $status );
117 117
     }
118 118
 
119 119
     /**
@@ -129,5 +129,5 @@  discard block
 block discarded – undo
129 129
      * @param  int $status
130 130
      * @return void
131 131
      */
132
-    abstract protected function validateStatusCode(int $status);
132
+    abstract protected function validateStatusCode( int $status );
133 133
 }
Please login to merge, or discard this patch.
src/Http/Responses/ErrorResponseBuilder.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
      * @param \Flugg\Responder\Contracts\ResponseFactory $responseFactory
57 57
      * @param \Flugg\Responder\Contracts\ErrorFactory    $errorFactory
58 58
      */
59
-    public function __construct(ResponseFactory $responseFactory, ErrorFactory $errorFactory)
59
+    public function __construct( ResponseFactory $responseFactory, ErrorFactory $errorFactory )
60 60
     {
61 61
         $this->errorFactory = $errorFactory;
62 62
 
63
-        parent::__construct($responseFactory);
63
+        parent::__construct( $responseFactory );
64 64
     }
65 65
 
66 66
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param  string|null $message
71 71
      * @return $this
72 72
      */
73
-    public function error(string $errorCode = null, string $message = null)
73
+    public function error( string $errorCode = null, string $message = null )
74 74
     {
75 75
         $this->errorCode = $errorCode;
76 76
         $this->message = $message;
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      * @param  array $data
85 85
      * @return $this
86 86
      */
87
-    public function data(array $data)
87
+    public function data( array $data )
88 88
     {
89
-        $this->data = array_merge((array) $this->data, $data);
89
+        $this->data = array_merge( (array) $this->data, $data );
90 90
 
91 91
         return $this;
92 92
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     protected function getOutput(): array
100 100
     {
101
-        return $this->errorFactory->make($this->errorCode, $this->message, $this->data);
101
+        return $this->errorFactory->make( $this->errorCode, $this->message, $this->data );
102 102
     }
103 103
 
104 104
     /**
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
      * @return void
109 109
      * @throws \InvalidArgumentException
110 110
      */
111
-    protected function validateStatusCode(int $status)
111
+    protected function validateStatusCode( int $status )
112 112
     {
113
-        if ($status < 400 || $status >= 600) {
114
-            throw new InvalidArgumentException("{$status} is not a valid error HTTP status code.");
113
+        if ( $status < 400 || $status >= 600 ) {
114
+            throw new InvalidArgumentException( "{$status} is not a valid error HTTP status code." );
115 115
         }
116 116
     }
117 117
 }
Please login to merge, or discard this patch.
src/ErrorMessageResolver.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @var array
28 28
      */
29
-    protected $messages = [];
29
+    protected $messages = [ ];
30 30
 
31 31
     /**
32 32
      * Construct the resolver class.
33 33
      *
34 34
      * @param \Illuminate\Contracts\Translation\Translator $translator
35 35
      */
36
-    public function __construct(Translator $translator)
36
+    public function __construct( Translator $translator )
37 37
     {
38 38
         $this->translator = $translator;
39 39
     }
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
      * @param  string $message
46 46
      * @return void
47 47
      */
48
-    public function register(string $errorCode, string $message)
48
+    public function register( string $errorCode, string $message )
49 49
     {
50
-        $this->messages = array_merge($this->messages, is_array($errorCode) ? $errorCode : [
50
+        $this->messages = array_merge( $this->messages, is_array( $errorCode ) ? $errorCode : [
51 51
             $errorCode => $message,
52
-        ]);
52
+        ] );
53 53
     }
54 54
 
55 55
     /**
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
      * @param  string $errorCode
59 59
      * @return string|null
60 60
      */
61
-    public function resolve(string $errorCode)
61
+    public function resolve( string $errorCode )
62 62
     {
63
-        if (key_exists($errorCode, $this->messages)) {
64
-            return $this->messages[$errorCode];
63
+        if ( key_exists( $errorCode, $this->messages ) ) {
64
+            return $this->messages[ $errorCode ];
65 65
         }
66 66
 
67
-        if ($this->translator->has($errorCode = "errors.$errorCode")) {
68
-            return $this->translator->trans($errorCode);
67
+        if ( $this->translator->has( $errorCode = "errors.$errorCode" ) ) {
68
+            return $this->translator->trans( $errorCode );
69 69
         }
70 70
 
71 71
         return null;
Please login to merge, or discard this patch.
src/FractalTransformFactory.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @param \League\Fractal\Manager $manager
31 31
      */
32
-    public function __construct(Manager $manager)
32
+    public function __construct( Manager $manager )
33 33
     {
34 34
         $this->manager = $manager;
35 35
     }
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
      * @param  array                                         $options
43 43
      * @return array
44 44
      */
45
-    public function make(ResourceInterface $resource, SerializerAbstract $serializer, array $options = []): array
45
+    public function make( ResourceInterface $resource, SerializerAbstract $serializer, array $options = [ ] ): array
46 46
     {
47
-        $options = $this->parseOptions($options, $resource);
47
+        $options = $this->parseOptions( $options, $resource );
48 48
 
49
-        return $this->manager->setSerializer($serializer)
50
-            ->parseIncludes($options['includes'])
51
-            ->parseExcludes($options['excludes'])
52
-            ->parseFieldsets($options['fieldsets'])
53
-            ->createData($resource)
49
+        return $this->manager->setSerializer( $serializer )
50
+            ->parseIncludes( $options[ 'includes' ] )
51
+            ->parseExcludes( $options[ 'excludes' ] )
52
+            ->parseFieldsets( $options[ 'fieldsets' ] )
53
+            ->createData( $resource )
54 54
             ->toArray();
55 55
     }
56 56
 
@@ -61,20 +61,20 @@  discard block
 block discarded – undo
61 61
      * @param  \League\Fractal\Resource\ResourceInterface $resource
62 62
      * @return array
63 63
      */
64
-    protected function parseOptions(array $options, ResourceInterface $resource): array
64
+    protected function parseOptions( array $options, ResourceInterface $resource ): array
65 65
     {
66
-        $options = array_merge([
67
-            'includes' => [],
68
-            'excludes' => [],
69
-            'fieldsets' => [],
70
-        ], $options);
71
-
72
-        if (! empty($options['fieldsets'])) {
73
-            if (is_null($resourceKey = $resource->getResourceKey())) {
74
-                throw new LogicException('Filtering fields using sparse fieldsets require resource key to be set.');
66
+        $options = array_merge( [
67
+            'includes' => [ ],
68
+            'excludes' => [ ],
69
+            'fieldsets' => [ ],
70
+        ], $options );
71
+
72
+        if ( ! empty($options[ 'fieldsets' ]) ) {
73
+            if ( is_null( $resourceKey = $resource->getResourceKey() ) ) {
74
+                throw new LogicException( 'Filtering fields using sparse fieldsets require resource key to be set.' );
75 75
             }
76 76
 
77
-            $options['fieldsets'] = $this->parseFieldsets($options['fieldsets'], $resourceKey, $options['includes']);
77
+            $options[ 'fieldsets' ] = $this->parseFieldsets( $options[ 'fieldsets' ], $resourceKey, $options[ 'includes' ] );
78 78
         }
79 79
 
80 80
         return $options;
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
      * @param  array  $includes
89 89
      * @return array
90 90
      */
91
-    protected function parseFieldsets(array $fieldsets, string $resourceKey, array $includes): array
91
+    protected function parseFieldsets( array $fieldsets, string $resourceKey, array $includes ): array
92 92
     {
93
-        $includes = array_map(function ($include) use ($resourceKey) {
93
+        $includes = array_map( function ( $include ) use ($resourceKey) {
94 94
             return "$resourceKey.$include";
95
-        }, $includes);
95
+        }, $includes );
96 96
 
97
-        foreach ($fieldsets as $key => $fields) {
98
-            if (is_numeric($key)) {
99
-                unset($fieldsets[$key]);
97
+        foreach ( $fieldsets as $key => $fields ) {
98
+            if ( is_numeric( $key ) ) {
99
+                unset($fieldsets[ $key ]);
100 100
                 $key = $resourceKey;
101 101
             }
102 102
 
103
-            $fieldsets[$key] = $this->parseFieldset($key, (array) $fields, $includes);
103
+            $fieldsets[ $key ] = $this->parseFieldset( $key, (array) $fields, $includes );
104 104
         }
105 105
 
106 106
         return $fieldsets;
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
      * @param  array  $includes
115 115
      * @return string
116 116
      */
117
-    protected function parseFieldset(string $key, array $fields, array $includes): string
117
+    protected function parseFieldset( string $key, array $fields, array $includes ): string
118 118
     {
119
-        $childIncludes = array_reduce($includes, function ($segments, $include) use ($key) {
120
-            return array_merge($segments, $this->resolveChildIncludes($key, $include));
121
-        }, []);
119
+        $childIncludes = array_reduce( $includes, function ( $segments, $include ) use ($key) {
120
+            return array_merge( $segments, $this->resolveChildIncludes( $key, $include ) );
121
+        }, [ ] );
122 122
 
123
-        return implode(',', array_merge($fields, array_unique($childIncludes)));
123
+        return implode( ',', array_merge( $fields, array_unique( $childIncludes ) ) );
124 124
     }
125 125
 
126 126
     /**
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
      * @param  string $include
131 131
      * @return array
132 132
      */
133
-    protected function resolveChildIncludes($key, string $include): array
133
+    protected function resolveChildIncludes( $key, string $include ): array
134 134
     {
135
-        if (count($segments = explode('.', $include)) <= 1) {
136
-            return [];
135
+        if ( count( $segments = explode( '.', $include ) ) <= 1 ) {
136
+            return [ ];
137 137
         }
138 138
 
139
-        $relation = $key === array_shift($segments) ? [$segments[0]] : [];
139
+        $relation = $key === array_shift( $segments ) ? [ $segments[ 0 ] ] : [ ];
140 140
 
141
-        return array_merge($relation, $this->resolveChildIncludes($key, implode('.', $segments)));
141
+        return array_merge( $relation, $this->resolveChildIncludes( $key, implode( '.', $segments ) ) );
142 142
     }
143 143
 }
144 144
\ No newline at end of file
Please login to merge, or discard this patch.
src/Resources/ResourceFactory.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @param \Flugg\Responder\Resources\DataNormalizer                   $normalizer
41 41
      * @param \Flugg\Responder\Contracts\Transformers\TransformerResolver $transformerResolver
42 42
      */
43
-    public function __construct(DataNormalizer $normalizer, TransformerResolver $transformerResolver)
43
+    public function __construct( DataNormalizer $normalizer, TransformerResolver $transformerResolver )
44 44
     {
45 45
         $this->normalizer = $normalizer;
46 46
         $this->transformerResolver = $transformerResolver;
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
      * @param  string|null                                                    $resourceKey
55 55
      * @return \League\Fractal\Resource\ResourceInterface
56 56
      */
57
-    public function make($data = null, $transformer = null, string $resourceKey = null): ResourceInterface
57
+    public function make( $data = null, $transformer = null, string $resourceKey = null ): ResourceInterface
58 58
     {
59
-        if ($data instanceof ResourceInterface) {
60
-            return $data->setTransformer($this->resolveTransformer($data->getData(), $transformer ?: $data->getTransformer()));
61
-        } elseif (is_null($data = $this->normalizer->normalize($data))) {
62
-            return $this->instatiateResource($data);
59
+        if ( $data instanceof ResourceInterface ) {
60
+            return $data->setTransformer( $this->resolveTransformer( $data->getData(), $transformer ?: $data->getTransformer() ) );
61
+        } elseif ( is_null( $data = $this->normalizer->normalize( $data ) ) ) {
62
+            return $this->instatiateResource( $data );
63 63
         }
64 64
 
65
-        $transformer = $this->resolveTransformer($data, $transformer);
65
+        $transformer = $this->resolveTransformer( $data, $transformer );
66 66
 
67
-        return $this->instatiateResource($data, $transformer, $resourceKey);
67
+        return $this->instatiateResource( $data, $transformer, $resourceKey );
68 68
     }
69 69
 
70 70
     /**
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
      * @param  \Flugg\Responder\Transformers\Transformer|string|callable|null $transformer
75 75
      * @return \Flugg\Responder\Transformers\Transformer|callable
76 76
      */
77
-    protected function resolveTransformer($data, $transformer)
77
+    protected function resolveTransformer( $data, $transformer )
78 78
     {
79
-        if (isset($transformer)) {
80
-            return $this->transformerResolver->resolve($transformer);
79
+        if ( isset($transformer) ) {
80
+            return $this->transformerResolver->resolve( $transformer );
81 81
         }
82 82
 
83
-        return $this->transformerResolver->resolveFromData($data);
83
+        return $this->transformerResolver->resolveFromData( $data );
84 84
     }
85 85
 
86 86
     /**
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
      * @param  string|null                                             $resourceKey
92 92
      * @return \League\Fractal\Resource\ResourceInterface
93 93
      */
94
-    protected function instatiateResource($data, $transformer = null, string $resourceKey = null): ResourceInterface
94
+    protected function instatiateResource( $data, $transformer = null, string $resourceKey = null ): ResourceInterface
95 95
     {
96
-        if (is_null($data)) {
96
+        if ( is_null( $data ) ) {
97 97
             return new NullResource;
98
-        } elseif ($this->shouldCreateCollection($data)) {
99
-            return new CollectionResource($data, $transformer, $resourceKey);
98
+        } elseif ( $this->shouldCreateCollection( $data ) ) {
99
+            return new CollectionResource( $data, $transformer, $resourceKey );
100 100
         }
101 101
 
102
-        return new ItemResource($data, $transformer, $resourceKey);
102
+        return new ItemResource( $data, $transformer, $resourceKey );
103 103
     }
104 104
 
105 105
     /**
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
      * @param  mixed $data
109 109
      * @return bool
110 110
      */
111
-    protected function shouldCreateCollection($data): bool
111
+    protected function shouldCreateCollection( $data ): bool
112 112
     {
113
-        if (is_array($data)) {
114
-            return ! is_scalar(Arr::first($data));
113
+        if ( is_array( $data ) ) {
114
+            return ! is_scalar( Arr::first( $data ) );
115 115
         }
116 116
 
117 117
         return $data instanceof Traversable;
Please login to merge, or discard this patch.