Passed
Push — v2 ( 1005f4...220fbf )
by Alexander
02:47
created
src/FractalTransformFactory.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @param \League\Fractal\Manager $manager
30 30
      */
31
-    public function __construct(Manager $manager)
31
+    public function __construct( Manager $manager )
32 32
     {
33 33
         $this->manager = $manager;
34 34
     }
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
      * @param  array                                         $options
42 42
      * @return array
43 43
      */
44
-    public function make(ResourceInterface $resource, SerializerAbstract $serializer, array $options = []): array
44
+    public function make( ResourceInterface $resource, SerializerAbstract $serializer, array $options = [ ] ): array
45 45
     {
46
-        return $this->manager->setSerializer($serializer)
47
-            ->parseIncludes($options['includes'] ?? [])
48
-            ->parseExcludes($options['excludes'] ?? [])
49
-            ->parseFieldsets($options['fields'] ?? [])
50
-            ->createData($resource)
46
+        return $this->manager->setSerializer( $serializer )
47
+            ->parseIncludes( $options[ 'includes' ] ?? [ ] )
48
+            ->parseExcludes( $options[ 'excludes' ] ?? [ ] )
49
+            ->parseFieldsets( $options[ 'fields' ] ?? [ ] )
50
+            ->createData( $resource )
51 51
             ->toArray();
52 52
     }
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
src/Testing/MakesApiRequests.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
      * @param  int   $status
22 22
      * @return $this
23 23
      */
24
-    protected function seeSuccess($data = null, $status = 200)
24
+    protected function seeSuccess( $data = null, $status = 200 )
25 25
     {
26
-        $response = $this->seeSuccessResponse($data, $status);
27
-        $this->seeSuccessData($response->getData(true)['data']);
26
+        $response = $this->seeSuccessResponse( $data, $status );
27
+        $this->seeSuccessData( $response->getData( true )[ 'data' ] );
28 28
 
29 29
         return $this;
30 30
     }
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
      * @param  int   $status
37 37
      * @return $this
38 38
      */
39
-    protected function seeSuccessEquals($data = null, $status = 200)
39
+    protected function seeSuccessEquals( $data = null, $status = 200 )
40 40
     {
41
-        $response = $this->seeSuccessResponse($data, $status);
42
-        $this->seeJsonEquals($response->getData(true));
41
+        $response = $this->seeSuccessResponse( $data, $status );
42
+        $this->seeJsonEquals( $response->getData( true ) );
43 43
 
44 44
         return $this;
45 45
     }
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
      * @param  mixed $data
51 51
      * @return $this
52 52
      */
53
-    protected function seeSuccessStructure($data = null)
53
+    protected function seeSuccessStructure( $data = null )
54 54
     {
55
-        $this->seeJsonStructure([
55
+        $this->seeJsonStructure( [
56 56
             'data' => $data,
57
-        ]);
57
+        ] );
58 58
 
59 59
         return $this;
60 60
     }
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
      * @param  int   $status
67 67
      * @return \Illuminate\Http\JsonResponse
68 68
      */
69
-    protected function seeSuccessResponse($data = null, $status = 200): JsonResponse
69
+    protected function seeSuccessResponse( $data = null, $status = 200 ): JsonResponse
70 70
     {
71
-        $response = $this->app->make(Responder::class)->success($data, $status);
71
+        $response = $this->app->make( Responder::class )->success( $data, $status );
72 72
 
73
-        $this->seeStatusCode($response->getStatusCode())->seeJson([
73
+        $this->seeStatusCode( $response->getStatusCode() )->seeJson( [
74 74
             'success' => true,
75 75
             'status' => $response->getStatusCode(),
76
-        ])->seeJsonStructure(['data']);
76
+        ] )->seeJsonStructure( [ 'data' ] );
77 77
 
78 78
         return $response;
79 79
     }
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
      * @param  mixed $data
85 85
      * @return $this
86 86
      */
87
-    protected function seeSuccessData($data = null)
87
+    protected function seeSuccessData( $data = null )
88 88
     {
89
-        collect($data)->each(function ($value, $key) {
90
-            if (is_array($value)) {
91
-                $this->seeSuccessData($value);
89
+        collect( $data )->each( function ( $value, $key ) {
90
+            if ( is_array( $value ) ) {
91
+                $this->seeSuccessData( $value );
92 92
             } else {
93
-                $this->seeJson([$key => $value]);
93
+                $this->seeJson( [ $key => $value ] );
94 94
             }
95 95
         });
96 96
 
@@ -103,20 +103,20 @@  discard block
 block discarded – undo
103 103
      * @param  string|array|null $attributes
104 104
      * @return array
105 105
      */
106
-    protected function getSuccessData($attributes = null)
106
+    protected function getSuccessData( $attributes = null )
107 107
     {
108
-        $rawData = $this->decodeResponseJson()['data'];
108
+        $rawData = $this->decodeResponseJson()[ 'data' ];
109 109
 
110
-        if (is_null($attributes)) {
110
+        if ( is_null( $attributes ) ) {
111 111
             return $rawData;
112
-        } elseif (is_string($attributes)) {
113
-            return array_get($rawData, $attributes);
112
+        } elseif ( is_string( $attributes ) ) {
113
+            return array_get( $rawData, $attributes );
114 114
         }
115 115
 
116
-        $data = [];
116
+        $data = [ ];
117 117
 
118
-        foreach ($attributes as $attribute) {
119
-            $data[] = array_get($rawData, $attribute);
118
+        foreach ( $attributes as $attribute ) {
119
+            $data[ ] = array_get( $rawData, $attribute );
120 120
         }
121 121
 
122 122
         return $data;
@@ -129,25 +129,25 @@  discard block
 block discarded – undo
129 129
      * @param  int|null $status
130 130
      * @return $this
131 131
      */
132
-    protected function seeError(string $error, int $status = null)
132
+    protected function seeError( string $error, int $status = null )
133 133
     {
134
-        if (! is_null($status)) {
135
-            $this->seeStatusCode($status);
134
+        if ( ! is_null( $status ) ) {
135
+            $this->seeStatusCode( $status );
136 136
         }
137 137
 
138
-        if ($this->app->config->get('responder.status_code')) {
139
-            $this->seeJson([
138
+        if ( $this->app->config->get( 'responder.status_code' ) ) {
139
+            $this->seeJson( [
140 140
                 'status' => $status,
141
-            ]);
141
+            ] );
142 142
         }
143 143
 
144
-        return $this->seeJson([
144
+        return $this->seeJson( [
145 145
             'success' => false,
146
-        ])->seeJsonSubset([
146
+        ] )->seeJsonSubset( [
147 147
             'error' => [
148 148
                 'code' => $error,
149 149
             ],
150
-        ]);
150
+        ] );
151 151
     }
152 152
 
153 153
     /**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      * @param  int $status
157 157
      * @return $this
158 158
      */
159
-    abstract protected function seeStatusCode($status);
159
+    abstract protected function seeStatusCode( $status );
160 160
 
161 161
     /**
162 162
      * Assert that the response contains JSON.
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @param  bool       $negate
166 166
      * @return $this
167 167
      */
168
-    abstract public function seeJson(array $data = null, $negate = false);
168
+    abstract public function seeJson( array $data = null, $negate = false );
169 169
 
170 170
     /**
171 171
      * Assert that the JSON response has a given structure.
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * @param  array|null $responseData
175 175
      * @return $this
176 176
      */
177
-    abstract public function seeJsonStructure(array $structure = null, $responseData = null);
177
+    abstract public function seeJsonStructure( array $structure = null, $responseData = null );
178 178
 
179 179
     /**
180 180
      * Assert that the response is a superset of the given JSON.
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      * @param  array $data
183 183
      * @return $this
184 184
      */
185
-    abstract protected function seeJsonSubset(array $data);
185
+    abstract protected function seeJsonSubset( array $data );
186 186
 
187 187
     /**
188 188
      * Assert that the response contains an exact JSON array.
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      * @param  array $data
191 191
      * @return $this
192 192
      */
193
-    abstract public function seeJsonEquals(array $data);
193
+    abstract public function seeJsonEquals( array $data );
194 194
 
195 195
     /**
196 196
      * Validate and return the decoded response JSON.
Please login to merge, or discard this patch.
src/ErrorMessageResolver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @param \Illuminate\Contracts\Translation\Translator $translator
28 28
      */
29
-    public function __construct(Translator $translator)
29
+    public function __construct( Translator $translator )
30 30
     {
31 31
         $this->translator = $translator;
32 32
     }
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
      * @param  string $errorCode
38 38
      * @return string|null
39 39
      */
40
-    public function resolve(string $errorCode)
40
+    public function resolve( string $errorCode )
41 41
     {
42
-        if (! $this->translator->has($errorCode = "errors.$errorCode")) {
42
+        if ( ! $this->translator->has( $errorCode = "errors.$errorCode" ) ) {
43 43
             return null;
44 44
         }
45 45
 
46
-        return $this->translator->trans($errorCode);
46
+        return $this->translator->trans( $errorCode );
47 47
     }
48 48
 }
49 49
\ No newline at end of file
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/Transformer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @param \Flugg\Responder\TransformBuilder $transformBuilder
28 28
      */
29
-    public function __construct(TransformBuilder $transformBuilder)
29
+    public function __construct( TransformBuilder $transformBuilder )
30 30
     {
31 31
         $this->transformBuilder = $transformBuilder;
32 32
     }
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
      * @param  string[]                                                       $without
41 41
      * @return array
42 42
      */
43
-    public function transform($data = null, $transformer = null, array $with = [], array $without = []): array
43
+    public function transform( $data = null, $transformer = null, array $with = [ ], array $without = [ ] ): array
44 44
     {
45
-        return $this->transformBuilder->resource($data, $transformer)
46
-            ->with($with)
47
-            ->without($without)
48
-            ->serializer(new NullSerializer)
45
+        return $this->transformBuilder->resource( $data, $transformer )
46
+            ->with( $with )
47
+            ->without( $without )
48
+            ->serializer( new NullSerializer )
49 49
             ->transform();
50 50
     }
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use Flugg\Responder\Contracts\Responder;
4 4
 use Flugg\Responder\Contracts\Transformer;
5 5
 
6
-if (! function_exists('responder')) {
6
+if ( ! function_exists( 'responder' ) ) {
7 7
 
8 8
     /**
9 9
      * A helper method to resolve the responder service out of the service container.
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
      */
13 13
     function responder(): Responder
14 14
     {
15
-        return app(Responder::class);
15
+        return app( Responder::class );
16 16
     }
17 17
 }
18 18
 
19
-if (! function_exists('transform')) {
19
+if ( ! function_exists( 'transform' ) ) {
20 20
 
21 21
     /**
22 22
      * A helper method to transform data without serializing.
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
      * @param  string[]                                                       $without
28 28
      * @return array
29 29
      */
30
-    function transform($data = null, $transformer = null, array $with = [], array $without = []): array
30
+    function transform( $data = null, $transformer = null, array $with = [ ], array $without = [ ] ): array
31 31
     {
32
-        return app(Transformer::class)->transform($data, $transformer, $with, $without);
32
+        return app( Transformer::class )->transform( $data, $transformer, $with, $without );
33 33
     }
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
src/Responder.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\Http\Responses\ErrorResponseBuilder   $errorResponseBuilder
36 36
      * @param \Flugg\Responder\Http\Responses\SuccessResponseBuilder $successResponseBuilder
37 37
      */
38
-    public function __construct(ErrorResponseBuilder $errorResponseBuilder, SuccessResponseBuilder $successResponseBuilder)
38
+    public function __construct( ErrorResponseBuilder $errorResponseBuilder, SuccessResponseBuilder $successResponseBuilder )
39 39
     {
40 40
         $this->errorResponseBuilder = $errorResponseBuilder;
41 41
         $this->successResponseBuilder = $successResponseBuilder;
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      * @param  string|null $message
49 49
      * @return \Flugg\Responder\Http\Responses\ErrorResponseBuilder
50 50
      */
51
-    public function error(string $errorCode = null, string $message = null): ErrorResponseBuilder
51
+    public function error( string $errorCode = null, string $message = null ): ErrorResponseBuilder
52 52
     {
53
-        return $this->errorResponseBuilder->error($errorCode, $message);
53
+        return $this->errorResponseBuilder->error( $errorCode, $message );
54 54
     }
55 55
 
56 56
     /**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      * @param  string|null                                                    $resourceKey
62 62
      * @return \Flugg\Responder\Http\Responses\SuccessResponseBuilder
63 63
      */
64
-    public function success($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder
64
+    public function success( $data = null, $transformer = null, string $resourceKey = null ): SuccessResponseBuilder
65 65
     {
66
-        return $this->successResponseBuilder->transform($data, $transformer, $resourceKey);
66
+        return $this->successResponseBuilder->transform( $data, $transformer, $resourceKey );
67 67
     }
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
src/Exceptions/InvalidSerializerException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,6 +19,6 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct()
21 21
     {
22
-        parent::__construct('Given serializer must be an instance of [' . SerializerAbstract::class . '].');
22
+        parent::__construct( 'Given serializer must be an instance of [' . SerializerAbstract::class . '].' );
23 23
     }
24 24
 }
25 25
\ 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->transformException($exception);
29
+        $this->transformException( $exception );
30 30
 
31
-        if ($exception instanceof ApiException) {
32
-            return $this->renderApiError($exception);
31
+        if ( $exception instanceof ApiException ) {
32
+            return $this->renderApiError( $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.