Completed
Push — master ( ee198e...323919 )
by Neomerx
02:19
created
src/Http/Traits/DefaultControllerMethodsTrait.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
      * @param FactoryInterface           $errorFactory
252 252
      * @param FormatterFactoryInterface  $formatterFactory
253 253
      *
254
-     * @return ResponseInterface
254
+     * @return string
255 255
      */
256 256
     protected static function defaultCreate(
257 257
         string $requestBody,
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Http\Traits;
4 4
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         EncoderInterface $encoder
111 111
     ): ResponseInterface {
112 112
         $queryParser->parse($index, $queryParams);
113
-        $validatedIndex = (string)$queryParser->getIdentity();
113
+        $validatedIndex = (string) $queryParser->getIdentity();
114 114
 
115 115
         $model = $mapper->applyQueryParameters($queryParser, $crud)->read($validatedIndex);
116 116
         assert(!($model instanceof PaginatedDataInterface));
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             $title     = $formatter->formatMessage(Messages::MSG_ERR_CANNOT_CREATE_NON_UNIQUE_RESOURCE);
281 281
             $details   = null;
282 282
             $errorCode = JsonApiResponse::HTTP_CONFLICT;
283
-            $errors->addDataError($title, $details, (string)$errorCode);
283
+            $errors->addDataError($title, $details, (string) $errorCode);
284 284
 
285 285
             throw new JsonApiException($errors);
286 286
         }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
         list ($index, $attributes, $toMany) = static::mapSchemaDataToModelData($captures, $schemaClass, $schemaInfo);
410 410
 
411 411
         try {
412
-            $updated = $crud->update((string)$index, $attributes, $toMany);
412
+            $updated = $crud->update((string) $index, $attributes, $toMany);
413 413
         } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UniqueConstraintViolationException $exception) {
414 414
             $errors    = $errorFactory->createErrorCollection();
415 415
             $formatter = $formatterFactory->createFormatter(Messages::NAMESPACE_NAME);
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
                 ->formatMessage(Messages::MSG_ERR_CANNOT_UPDATE_WITH_UNIQUE_CONSTRAINT_VIOLATION);
418 418
             $details   = null;
419 419
             $errorCode = JsonApiResponse::HTTP_CONFLICT;
420
-            $errors->addDataError($title, $details, (string)$errorCode);
420
+            $errors->addDataError($title, $details, (string) $errorCode);
421 421
 
422 422
             throw new JsonApiException($errors);
423 423
         }
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
         CrudInterface $crud,
471 471
         EncoderInterface $encoder
472 472
     ): ResponseInterface {
473
-        $validatedIndex = (string)$queryParser->parse($index)->getIdentity();
473
+        $validatedIndex = (string) $queryParser->parse($index)->getIdentity();
474 474
         $crud->remove($validatedIndex);
475 475
 
476 476
         $responses = static::defaultCreateResponses($requestUri, $encoder);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         $captures = $dataValidator->assertRelationship($index, $jsonRelName, $jsonData)->getCaptures();
524 524
         $relIds   = $captures[$jsonRelName];
525 525
 
526
-        $validatedIndex = (string)$queryParser->parse($index)->getIdentity();
526
+        $validatedIndex = (string) $queryParser->parse($index)->getIdentity();
527 527
         $parentCrud->createInBelongsToManyRelationship($validatedIndex, $modelRelName, $relIds);
528 528
 
529 529
         $responses = static::defaultCreateResponses($requestUri, $encoder);
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
         $captures = $dataValidator->assertRelationship($index, $jsonRelName, $jsonData)->getCaptures();
577 577
         $relIds   = $captures[$jsonRelName];
578 578
 
579
-        $validatedIndex = (string)$queryParser->parse($index)->getIdentity();
579
+        $validatedIndex = (string) $queryParser->parse($index)->getIdentity();
580 580
         $parentCrud->removeInBelongsToManyRelationship($validatedIndex, $modelRelName, $relIds);
581 581
 
582 582
         $responses = static::defaultCreateResponses($requestUri, $encoder);
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
         $modelClass = $schemaClass::MODEL;
625 625
         assert($schemaInfo->hasRelationship($modelClass, $modelRelName));
626 626
         assert(
627
-            ($type =$schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO ||
627
+            ($type = $schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO ||
628 628
             $type === RelationshipTypes::BELONGS_TO_MANY
629 629
         );
630 630
 
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 
634 634
         // If we are here then we have something in 'data' section.
635 635
 
636
-        $validatedIndex = (string)$queryParser->parse($index)->getIdentity();
636
+        $validatedIndex = (string) $queryParser->parse($index)->getIdentity();
637 637
         list (, $attributes, $toMany) = static::mapSchemaDataToModelData($captures, $schemaClass, $schemaInfo);
638 638
 
639 639
         $updated = $crud->update($validatedIndex, $attributes, $toMany);
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
     ): string {
876 876
         $schema    = $jsonSchemas->getSchema($model);
877 877
         $selfLink  = $schema->getSelfLink($model);
878
-        $urlPrefix = (string)$requestUri->withPath('')->withQuery('')->withFragment('');
878
+        $urlPrefix = (string) $requestUri->withPath('')->withQuery('')->withFragment('');
879 879
         $fullUrl   = $selfLink->getStringRepresentation($urlPrefix);
880 880
 
881 881
         return $fullUrl;
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
      */
889 889
     private static function assertClassValueDefined(?string $value): void
890 890
     {
891
-        assert(empty($value) === false, 'Value should be defined in `' . static::class . '`.');
891
+        assert(empty($value) === false, 'Value should be defined in `'.static::class.'`.');
892 892
     }
893 893
 
894 894
     /**
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
     {
902 902
         assert(
903 903
             array_key_exists($interface, class_implements($class)) === true,
904
-            "Class `$class` should implement `" . $interface . '` interface.'
904
+            "Class `$class` should implement `".$interface.'` interface.'
905 905
         );
906 906
     }
907 907
 }
Please login to merge, or discard this patch.
src/Http/ThrowableHandlers/FluteThrowableHandler.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Http\ThrowableHandlers;
4 4
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
             $details  = null;
133 133
             if ($this->isDebug === true) {
134 134
                 $message = $throwable->getMessage();
135
-                $details = (string)$throwable;
135
+                $details = (string) $throwable;
136 136
             }
137
-            $errors->add(new Error(null, null, null, (string)$httpCode, null, $message, $details));
137
+            $errors->add(new Error(null, null, null, (string) $httpCode, null, $message, $details));
138 138
         }
139 139
 
140 140
         // encode the error and send to client
Please login to merge, or discard this patch.
src/Http/JsonApiBaseController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Http;
4 4
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
         $response = static::defaultCreateHandler(
94 94
             $request->getUri(),
95
-            (string)$request->getBody(),
95
+            (string) $request->getBody(),
96 96
             static::SCHEMA_CLASS,
97 97
             $container->get(ModelSchemaInfoInterface::class),
98 98
             static::defaultCreateDataParser($container, static::ON_CREATE_DATA_VALIDATION_RULES_CLASS),
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
120 120
 
121 121
         return static::defaultReadHandler(
122
-            (string)$routeParams[static::ROUTE_KEY_INDEX],
122
+            (string) $routeParams[static::ROUTE_KEY_INDEX],
123 123
             $request->getQueryParams(),
124 124
             $request->getUri(),
125 125
             static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
         static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
143 143
 
144 144
         $response = static::defaultUpdateHandler(
145
-            (string)$routeParams[static::ROUTE_KEY_INDEX],
145
+            (string) $routeParams[static::ROUTE_KEY_INDEX],
146 146
             $request->getUri(),
147
-            (string)$request->getBody(),
147
+            (string) $request->getBody(),
148 148
             static::SCHEMA_CLASS,
149 149
             $container->get(ModelSchemaInfoInterface::class),
150 150
             static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         static::assertClassValueDefined(static::API_CLASS);
169 169
 
170 170
         $response = static::defaultDeleteHandler(
171
-            (string)$routeParams[static::ROUTE_KEY_INDEX],
171
+            (string) $routeParams[static::ROUTE_KEY_INDEX],
172 172
             $request->getUri(),
173 173
             static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
174 174
             static::defaultCreateApi($container, static::API_CLASS),
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         static::assertClassValueDefined(static::SCHEMA_CLASS);
202 202
 
203 203
         $api     = static::defaultCreateApi($container, static::API_CLASS);
204
-        $handler = function () use ($api, $index, $modelRelName) {
204
+        $handler = function() use ($api, $index, $modelRelName) {
205 205
             return $api->readRelationship($index, $modelRelName);
206 206
         };
207 207
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         static::assertClassValueDefined(static::SCHEMA_CLASS);
241 241
 
242 242
         $api     = static::defaultCreateApi($container, static::API_CLASS);
243
-        $handler = function () use ($api, $index, $modelRelName) {
243
+        $handler = function() use ($api, $index, $modelRelName) {
244 244
             return $api->readRelationship($index, $modelRelName);
245 245
         };
246 246
 
Please login to merge, or discard this patch.
src/Http/Traits/FluteRoutesTrait.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Http\Traits;
4 4
 
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
         assert(class_exists($controllerClass) === true);
51 51
 
52 52
         $groupPrefix = $group->getUriPrefix();
53
-        $indexSlug   = '/{' . JCI::ROUTE_KEY_INDEX . '}';
54
-        $params      = function (string $method) use ($groupPrefix, $resourceName): array {
53
+        $indexSlug   = '/{'.JCI::ROUTE_KEY_INDEX.'}';
54
+        $params      = function(string $method) use ($groupPrefix, $resourceName): array {
55 55
             return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $resourceName, $method)];
56 56
         };
57
-        $handler     = function (string $method) use ($controllerClass): array {
57
+        $handler     = function(string $method) use ($controllerClass): array {
58 58
             return [$controllerClass, $method];
59 59
         };
60 60
 
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
             $group->post($resourceName, $handler(JCI::METHOD_CREATE), $params(JCI::METHOD_CREATE));
68 68
         }
69 69
         if (in_array(ControllerReadInterface::class, $classInterfaces) === true) {
70
-            $group->get($resourceName . $indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ));
70
+            $group->get($resourceName.$indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ));
71 71
         }
72 72
         if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) {
73
-            $group->patch($resourceName . $indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE));
73
+            $group->patch($resourceName.$indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE));
74 74
         }
75 75
         if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) {
76
-            $group->delete($resourceName . $indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE));
76
+            $group->delete($resourceName.$indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE));
77 77
         }
78 78
 
79 79
         return $group;
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
         }
100 100
 
101 101
         $groupPrefix = $group->getUriPrefix();
102
-        $slugged     = $subUri . '/{' . FCI::ROUTE_KEY_INDEX . '}';
103
-        $params      = function (string $method) use ($groupPrefix, $subUri) : array {
102
+        $slugged     = $subUri.'/{'.FCI::ROUTE_KEY_INDEX.'}';
103
+        $params      = function(string $method) use ($groupPrefix, $subUri) : array {
104 104
             return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $subUri, $method)];
105 105
         };
106
-        $handler     = function (string $method) use ($controllerClass): array {
106
+        $handler     = function(string $method) use ($controllerClass): array {
107 107
             return [$controllerClass, $method];
108 108
         };
109 109
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
             $group->get($subUri, $handler(FCI::METHOD_INDEX), $params(FCI::METHOD_INDEX));
115 115
         }
116 116
         if (in_array(ControllerInstanceInterface::class, $classInterfaces) === true) {
117
-            $group->get($subUri . $createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE));
117
+            $group->get($subUri.$createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE));
118 118
         }
119 119
         if (in_array(ControllerCreateInterface::class, $classInterfaces) === true) {
120
-            $group->post($subUri . $createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE));
120
+            $group->post($subUri.$createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE));
121 121
         }
122 122
         if (in_array(ControllerReadInterface::class, $classInterfaces) === true) {
123 123
             $group->get($slugged, $handler(FCI::METHOD_READ), $params(FCI::METHOD_READ));
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $group->post($slugged, $handler(FCI::METHOD_UPDATE), $params(FCI::METHOD_UPDATE));
127 127
         }
128 128
         if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) {
129
-            $deleteUri = $slugged . '/' . FCI::METHOD_DELETE;
129
+            $deleteUri = $slugged.'/'.FCI::METHOD_DELETE;
130 130
             $group->post($deleteUri, $handler(FCI::METHOD_DELETE), $params(FCI::METHOD_DELETE));
131 131
         }
132 132
 
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
         string $controllerClass,
150 150
         string $selfGetMethod
151 151
     ): GroupInterface {
152
-        $resourceIdUri = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/';
153
-        $selfUri       = $resourceIdUri . DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName;
152
+        $resourceIdUri = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/';
153
+        $selfUri       = $resourceIdUri.DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName;
154 154
 
155 155
         return $group
156 156
             // `self`
157 157
             ->get($selfUri, [$controllerClass, $selfGetMethod])
158 158
             // `related`
159
-            ->get($resourceIdUri . $relationshipName, [$controllerClass, $selfGetMethod]);
159
+            ->get($resourceIdUri.$relationshipName, [$controllerClass, $selfGetMethod]);
160 160
     }
161 161
 
162 162
     /**
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
         string $controllerClass,
176 176
         string $addMethod
177 177
     ): GroupInterface {
178
-        $url = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/' .
179
-            DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName;
178
+        $url = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/'.
179
+            DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName;
180 180
 
181 181
         return $group->post($url, [$controllerClass, $addMethod]);
182 182
     }
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
         string $controllerClass,
198 198
         string $deleteMethod
199 199
     ): GroupInterface {
200
-        $url = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/' .
201
-            DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName;
200
+        $url = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/'.
201
+            DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName;
202 202
 
203 203
         return $group->delete($url, [$controllerClass, $deleteMethod]);
204 204
     }
@@ -224,6 +224,6 @@  discard block
 block discarded – undo
224 224
             $subUri = substr($subUri, 0, -1);
225 225
         }
226 226
 
227
-        return $prefix . $subUri . '::' . $method;
227
+        return $prefix.$subUri.'::'.$method;
228 228
     }
229 229
 }
Please login to merge, or discard this patch.
src/Http/Query/Relationship.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Http\Query;
4 4
 
Please login to merge, or discard this patch.
src/Http/Query/ParametersMapper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Http\Query;
4 4
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     public function getMappedIncludes(): iterable
250 250
     {
251 251
         $fromSchema        = $this->getRootSchema();
252
-        $getMappedRelLinks = function (iterable $links) use ($fromSchema) : iterable {
252
+        $getMappedRelLinks = function(iterable $links) use ($fromSchema) : iterable {
253 253
             foreach ($links as $link) {
254 254
                 assert(is_string($link));
255 255
                 $fromSchemaClass = get_class($fromSchema);
@@ -299,14 +299,14 @@  discard block
 block discarded – undo
299 299
         //     ['rel2_name1', ],
300 300
         //     ['rel3_name1', 'rel3_name2', 'rel3_name3', ],
301 301
         // ]
302
-        $includeAsModelNames = function (iterable $relationships): iterable {
302
+        $includeAsModelNames = function(iterable $relationships): iterable {
303 303
             foreach ($relationships as $relationship) {
304 304
                 assert($relationship instanceof RelationshipInterface);
305 305
                 yield $relationship->getNameInModel();
306 306
             }
307 307
         };
308 308
         $mappedIncludes      = $this->getMappedIncludes();
309
-        $getIncludes         = function () use ($mappedIncludes, $includeAsModelNames) : iterable {
309
+        $getIncludes         = function() use ($mappedIncludes, $includeAsModelNames) : iterable {
310 310
             foreach ($mappedIncludes as $relationships) {
311 311
                 yield $includeAsModelNames($relationships);
312 312
             }
Please login to merge, or discard this patch.
src/Http/JsonApiResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Http;
4 4
 
Please login to merge, or discard this patch.
src/Contracts/Http/WebControllerInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Contracts\Http;
4 4
 
Please login to merge, or discard this patch.
src/Contracts/Http/Query/AttributeInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Limoncello\Flute\Contracts\Http\Query;
4 4
 
Please login to merge, or discard this patch.