Completed
Push — master ( 8f8d73...a6ab5d )
by Neomerx
04:28
created
src/Http/Traits/FluteRoutesTrait.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
         assert(class_exists($controllerClass) === true);
49 49
 
50 50
         $groupPrefix = $group->getUriPrefix();
51
-        $indexSlug   = '/{' . JCI::ROUTE_KEY_INDEX . '}';
52
-        $params      = function (string $method) use ($groupPrefix, $resourceName): array {
51
+        $indexSlug   = '/{'.JCI::ROUTE_KEY_INDEX.'}';
52
+        $params      = function(string $method) use ($groupPrefix, $resourceName): array {
53 53
             return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $resourceName, $method)];
54 54
         };
55
-        $handler     = function (string $method) use ($controllerClass): array {
55
+        $handler     = function(string $method) use ($controllerClass): array {
56 56
             return [$controllerClass, $method];
57 57
         };
58 58
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
             $group->post($resourceName, $handler(JCI::METHOD_CREATE), $params(JCI::METHOD_CREATE));
66 66
         }
67 67
         if (in_array(ControllerReadInterface::class, $classInterfaces) === true) {
68
-            $group->get($resourceName . $indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ));
68
+            $group->get($resourceName.$indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ));
69 69
         }
70 70
         if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) {
71
-            $group->patch($resourceName . $indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE));
71
+            $group->patch($resourceName.$indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE));
72 72
         }
73 73
         if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) {
74
-            $group->delete($resourceName . $indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE));
74
+            $group->delete($resourceName.$indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE));
75 75
         }
76 76
 
77 77
         return $group;
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
         }
98 98
 
99 99
         $groupPrefix = $group->getUriPrefix();
100
-        $slugged     = $subUri . '/{' . FCI::ROUTE_KEY_INDEX . '}';
101
-        $params      = function (string $method) use ($groupPrefix, $subUri) : array {
100
+        $slugged     = $subUri.'/{'.FCI::ROUTE_KEY_INDEX.'}';
101
+        $params      = function(string $method) use ($groupPrefix, $subUri) : array {
102 102
             return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $subUri, $method)];
103 103
         };
104
-        $handler     = function (string $method) use ($controllerClass): array {
104
+        $handler     = function(string $method) use ($controllerClass): array {
105 105
             return [$controllerClass, $method];
106 106
         };
107 107
 
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
             $group->get($subUri, $handler(FCI::METHOD_INDEX), $params(FCI::METHOD_INDEX));
113 113
         }
114 114
         if (in_array(ControllerInstanceInterface::class, $classInterfaces) === true) {
115
-            $group->get($subUri . $createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE));
115
+            $group->get($subUri.$createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE));
116 116
         }
117 117
         if (in_array(ControllerCreateInterface::class, $classInterfaces) === true) {
118
-            $group->post($subUri . $createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE));
118
+            $group->post($subUri.$createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE));
119 119
         }
120 120
         if (in_array(ControllerReadInterface::class, $classInterfaces) === true) {
121 121
             $group->get($slugged, $handler(FCI::METHOD_READ), $params(FCI::METHOD_READ));
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             $group->post($slugged, $handler(FCI::METHOD_UPDATE), $params(FCI::METHOD_UPDATE));
125 125
         }
126 126
         if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) {
127
-            $deleteUri = $slugged . '/' . FCI::METHOD_DELETE;
127
+            $deleteUri = $slugged.'/'.FCI::METHOD_DELETE;
128 128
             $group->post($deleteUri, $handler(FCI::METHOD_DELETE), $params(FCI::METHOD_DELETE));
129 129
         }
130 130
 
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
         /** @var string $controllerClass */
151 151
         /** @var string $schemaClass */
152 152
 
153
-        $resourceIdUri = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/';
154
-        $selfUri       = $resourceIdUri . DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName;
153
+        $resourceIdUri = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/';
154
+        $selfUri       = $resourceIdUri.DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName;
155 155
 
156 156
         return $group
157 157
             // `self`
158 158
             ->get($selfUri, [$controllerClass, $selfGetMethod])
159 159
             // `related`
160
-            ->get($resourceIdUri . $relationshipName, [$controllerClass, $selfGetMethod]);
160
+            ->get($resourceIdUri.$relationshipName, [$controllerClass, $selfGetMethod]);
161 161
     }
162 162
 
163 163
     /**
@@ -181,6 +181,6 @@  discard block
 block discarded – undo
181 181
             $subUri = substr($subUri, 0, -1);
182 182
         }
183 183
 
184
-        return $prefix . $subUri . '::' . $method;
184
+        return $prefix.$subUri.'::'.$method;
185 185
     }
186 186
 }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/ToManyRelationshipTypeCheckerRule.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,8 +71,7 @@
 block discarded – undo
71 71
         }
72 72
 
73 73
         $reply = $foundInvalidType === null ?
74
-            static::createSuccessReply($indexes) :
75
-            static::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE);
74
+            static::createSuccessReply($indexes) : static::createErrorReply($context, $foundInvalidType, ErrorCodes::INVALID_RELATIONSHIP_TYPE);
76 75
 
77 76
         return $reply;
78 77
     }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/AreReadableViaApiRule.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,6 @@
 block discarded – undo
77 77
         $result = count($readIndexes) === count($values);
78 78
 
79 79
         return $result === true ?
80
-            static::createSuccessReply($values) :
81
-            static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
80
+            static::createSuccessReply($values) : static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
82 81
     }
83 82
 }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/IsReadableViaApiRule.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,6 @@
 block discarded – undo
76 76
         $result = !empty($data);
77 77
 
78 78
         return $result === true ?
79
-            static::createSuccessReply($value) :
80
-            static::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE);
79
+            static::createSuccessReply($value) : static::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE);
81 80
     }
82 81
 }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/ExistInDbTableMultipleWithDoctrineRule.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,8 +86,7 @@
 block discarded – undo
86 86
         }
87 87
 
88 88
         $reply = $count > 0 ?
89
-            static::createSuccessReply($values) :
90
-            static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
89
+            static::createSuccessReply($values) : static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
91 90
 
92 91
         return $reply;
93 92
     }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/UniqueInDbTableSingleWithDoctrineRule.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@
 block discarded – undo
81 81
         }
82 82
 
83 83
         $reply = $count <= 0 ?
84
-            static::createSuccessReply($value) :
85
-            static::createErrorReply($context, $value, ErrorCodes::UNIQUE_IN_DATABASE_SINGLE);
84
+            static::createSuccessReply($value) : static::createErrorReply($context, $value, ErrorCodes::UNIQUE_IN_DATABASE_SINGLE);
86 85
 
87 86
         return $reply;
88 87
     }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/ExistInDbTableSingleWithDoctrineRule.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@
 block discarded – undo
82 82
         }
83 83
 
84 84
         $reply = $count > 0 ?
85
-            static::createSuccessReply($value) :
86
-            static::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE);
85
+            static::createSuccessReply($value) : static::createErrorReply($context, $value, ErrorCodes::EXIST_IN_DATABASE_SINGLE);
87 86
 
88 87
         return $reply;
89 88
     }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/ToOneRelationshipTypeCheckerRule.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@
 block discarded – undo
62 62
         assert(is_scalar($index) === true && is_scalar($type) === true);
63 63
         $expectedType = $context->getProperties()->getProperty(static::PROPERTY_RESOURCE_TYPE);
64 64
         $reply        = $type === $expectedType ?
65
-            static::createSuccessReply($index) :
66
-            static::createErrorReply($context, $type, ErrorCodes::INVALID_RELATIONSHIP_TYPE);
65
+            static::createSuccessReply($index) : static::createErrorReply($context, $type, ErrorCodes::INVALID_RELATIONSHIP_TYPE);
67 66
 
68 67
         return $reply;
69 68
     }
Please login to merge, or discard this patch.
src/Api/Crud.php 1 patch
Spacing   +19 added lines, -20 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function withIndexesFilter(array $indexes): CrudInterface
209 209
     {
210
-        assert(call_user_func(function () use ($indexes) {
210
+        assert(call_user_func(function() use ($indexes) {
211 211
             $allOk = true;
212 212
 
213 213
             foreach ($indexes as $index) {
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
             $classAtPath = new ArrayObject();
730 730
             $idsAtPath   = new ArrayObject();
731 731
 
732
-            $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
732
+            $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
733 733
                 self::registerModelAtPath(
734 734
                     $model,
735 735
                     static::ROOT_PATH,
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
                 assert(is_string($pathPiece));
818 818
                 $parent                    = $tmpPath;
819 819
                 $tmpPath                   = empty($tmpPath) === true ?
820
-                    $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece;
820
+                    $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece;
821 821
                 $normalizedPaths[$tmpPath] = [$parent, $pathPiece];
822 822
                 $pathsDepths[$parent]      = $parentDepth++;
823 823
             }
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
     ): ModelQueryBuilder {
975 975
         assert(
976 976
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $relationshipName),
977
-            "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`'
977
+            "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`'
978 978
         );
979 979
 
980 980
         // as we read data from a relationship our main table and model would be the table/model in the relationship
@@ -993,8 +993,7 @@  discard block
 block discarded – undo
993 993
             $filters = $this->getFilters();
994 994
             $sorts   = $this->getSorts();
995 995
             $this->areFiltersWithAnd() ?
996
-                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) :
997
-                $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
996
+                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
998 997
         }
999 998
         // ... and the input filters to actual data we select
1000 999
         if ($relationshipFilters !== null) {
@@ -1022,7 +1021,7 @@  discard block
 block discarded – undo
1022 1021
     ) {
1023 1022
         assert(
1024 1023
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1025
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1024
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1026 1025
         );
1027 1026
 
1028 1027
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1049,7 +1048,7 @@  discard block
 block discarded – undo
1049 1048
     ): array {
1050 1049
         assert(
1051 1050
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1052
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1051
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1053 1052
         );
1054 1053
 
1055 1054
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1123,7 +1122,7 @@  discard block
 block discarded – undo
1123 1122
 
1124 1123
         $this->clearFetchParameters();
1125 1124
 
1126
-        return (int)$deleted;
1125
+        return (int) $deleted;
1127 1126
     }
1128 1127
 
1129 1128
     /**
@@ -1137,7 +1136,7 @@  discard block
 block discarded – undo
1137 1136
 
1138 1137
         $this->clearFetchParameters();
1139 1138
 
1140
-        return (int)$deleted > 0;
1139
+        return (int) $deleted > 0;
1141 1140
     }
1142 1141
 
1143 1142
     /**
@@ -1158,7 +1157,7 @@  discard block
 block discarded – undo
1158 1157
 
1159 1158
         $this->clearBuilderParameters()->clearFetchParameters();
1160 1159
 
1161
-        $this->inTransaction(function () use ($saveMain, $toMany, &$index) {
1160
+        $this->inTransaction(function() use ($saveMain, $toMany, &$index) {
1162 1161
             $saveMain->execute();
1163 1162
 
1164 1163
             // if no index given will use last insert ID as index
@@ -1174,7 +1173,7 @@  discard block
 block discarded – undo
1174 1173
                         ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName)
1175 1174
                 );
1176 1175
                 foreach ($secondaryIds as $secondaryId) {
1177
-                    $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1176
+                    $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1178 1177
                 }
1179 1178
             }
1180 1179
         });
@@ -1203,12 +1202,12 @@  discard block
 block discarded – undo
1203 1202
             ->createBuilder($this->getModelClass())
1204 1203
             ->updateModels($allowedChanges)
1205 1204
             ->addFiltersWithAndToTable($filters);
1206
-        $saveMain       = $this->builderSaveResourceOnUpdate($saveMain);
1205
+        $saveMain = $this->builderSaveResourceOnUpdate($saveMain);
1207 1206
         $saveMain->getSQL(); // prepare
1208 1207
 
1209 1208
         $this->clearBuilderParameters()->clearFetchParameters();
1210 1209
 
1211
-        $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) {
1210
+        $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) {
1212 1211
             $updated = $saveMain->execute();
1213 1212
 
1214 1213
             foreach ($toMany as $relationshipName => $secondaryIds) {
@@ -1228,12 +1227,12 @@  discard block
 block discarded – undo
1228 1227
                         ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName)
1229 1228
                 );
1230 1229
                 foreach ($secondaryIds as $secondaryId) {
1231
-                    $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1230
+                    $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1232 1231
                 }
1233 1232
             }
1234 1233
         });
1235 1234
 
1236
-        return (int)$updated;
1235
+        return (int) $updated;
1237 1236
     }
1238 1237
 
1239 1238
     /**
@@ -1384,7 +1383,7 @@  discard block
 block discarded – undo
1384 1383
     {
1385 1384
         $countBuilder = $this->createBuilder($this->getModelClass());
1386 1385
         $countBuilder->setParameters($builder->getParameters());
1387
-        $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT');
1386
+        $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT');
1388 1387
 
1389 1388
         return $countBuilder;
1390 1389
     }
@@ -1595,7 +1594,7 @@  discard block
 block discarded – undo
1595 1594
 
1596 1595
         $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass);
1597 1596
 
1598
-        $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1597
+        $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1599 1598
             return self::registerModelAtPath(
1600 1599
                 $model,
1601 1600
                 $path,
@@ -1607,7 +1606,7 @@  discard block
 block discarded – undo
1607 1606
         };
1608 1607
 
1609 1608
         foreach ($childRelationships as $name) {
1610
-            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name;
1609
+            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name;
1611 1610
 
1612 1611
             $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name);
1613 1612
             list ($targetModelClass, $reverseRelName) =
@@ -1657,7 +1656,7 @@  discard block
 block discarded – undo
1657 1656
                             [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]],
1658 1657
                             []
1659 1658
                         );
1660
-                        $children      = $this->fetchPaginatedResourcesWithoutRelationships(
1659
+                        $children = $this->fetchPaginatedResourcesWithoutRelationships(
1661 1660
                             $clonedBuilder,
1662 1661
                             $clonedBuilder->getModelClass()
1663 1662
                         );
Please login to merge, or discard this patch.