Completed
Push — develop ( c734df...a43bb8 )
by Neomerx
06:19 queued 03:53
created
src/Api/Crud.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function withIndexesFilter(array $indexes): CrudInterface
210 210
     {
211
-        assert(call_user_func(function () use ($indexes) {
211
+        assert(call_user_func(function() use ($indexes) {
212 212
             $allOk = true;
213 213
 
214 214
             foreach ($indexes as $index) {
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
             $classAtPath = new ArrayObject();
761 761
             $idsAtPath   = new ArrayObject();
762 762
 
763
-            $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
763
+            $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
764 764
                 self::registerModelAtPath(
765 765
                     $model,
766 766
                     static::ROOT_PATH,
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
                 assert(is_string($pathPiece));
849 849
                 $parent                    = $tmpPath;
850 850
                 $tmpPath                   = empty($tmpPath) === true ?
851
-                    $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece;
851
+                    $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece;
852 852
                 $normalizedPaths[$tmpPath] = [$parent, $pathPiece];
853 853
                 $pathsDepths[$parent]      = $parentDepth++;
854 854
             }
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
     ): ModelQueryBuilder {
1018 1018
         assert(
1019 1019
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $relationshipName),
1020
-            "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`'
1020
+            "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`'
1021 1021
         );
1022 1022
 
1023 1023
         // as we read data from a relationship our main table and model would be the table/model in the relationship
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
         if ($this->hasFilters() === true) {
1036 1036
             $filters = $this->getFilters();
1037 1037
             $sorts   = $this->getSorts();
1038
-            $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder::AND : ModelQueryBuilder::OR;
1038
+            $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder:: AND : ModelQueryBuilder:: OR ;
1039 1039
             $builder->addRelationshipFiltersAndSorts($reverseRelName, $filters, $sorts, $joinCondition);
1040 1040
         }
1041 1041
         // ... and the input filters to actual data we select
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
     ) {
1067 1067
         assert(
1068 1068
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1069
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1069
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1070 1070
         );
1071 1071
 
1072 1072
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
     ): array {
1096 1096
         assert(
1097 1097
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1098
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1098
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1099 1099
         );
1100 1100
 
1101 1101
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 
1172 1172
         $this->clearFetchParameters();
1173 1173
 
1174
-        return (int)$deleted;
1174
+        return (int) $deleted;
1175 1175
     }
1176 1176
 
1177 1177
     /**
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 
1188 1188
         $this->clearFetchParameters();
1189 1189
 
1190
-        return (int)$deleted > 0;
1190
+        return (int) $deleted > 0;
1191 1191
     }
1192 1192
 
1193 1193
     /**
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 
1213 1213
         $this->clearBuilderParameters()->clearFetchParameters();
1214 1214
 
1215
-        $this->inTransaction(function () use ($saveMain, $toMany, &$index) {
1215
+        $this->inTransaction(function() use ($saveMain, $toMany, &$index) {
1216 1216
             $saveMain->execute();
1217 1217
 
1218 1218
             // if no index given will use last insert ID as index
@@ -1253,12 +1253,12 @@  discard block
 block discarded – undo
1253 1253
             ->createBuilder($this->getModelClass())
1254 1254
             ->updateModels($allowedChanges)
1255 1255
             ->addFiltersWithAndToTable($filters);
1256
-        $saveMain       = $this->builderSaveResourceOnUpdate($saveMain);
1256
+        $saveMain = $this->builderSaveResourceOnUpdate($saveMain);
1257 1257
         $saveMain->getSQL(); // prepare
1258 1258
 
1259 1259
         $this->clearBuilderParameters()->clearFetchParameters();
1260 1260
 
1261
-        $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) {
1261
+        $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) {
1262 1262
             $updated = $saveMain->execute();
1263 1263
 
1264 1264
             $builderHook = Closure::fromCallable([$this, 'builderSaveRelationshipOnUpdate']);
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
                 )->execute();
1275 1275
 
1276 1276
                 // add new ones
1277
-                $updated   += $this->addInToManyRelationship(
1277
+                $updated += $this->addInToManyRelationship(
1278 1278
                     $connection,
1279 1279
                     $index,
1280 1280
                     $relationshipName,
@@ -1284,7 +1284,7 @@  discard block
 block discarded – undo
1284 1284
             }
1285 1285
         });
1286 1286
 
1287
-        return (int)$updated;
1287
+        return (int) $updated;
1288 1288
     }
1289 1289
 
1290 1290
     /**
@@ -1299,9 +1299,9 @@  discard block
 block discarded – undo
1299 1299
     public function createInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int
1300 1300
     {
1301 1301
         // Check that relationship is `BelongsToMany`
1302
-        assert(call_user_func(function () use ($name): bool {
1302
+        assert(call_user_func(function() use ($name): bool {
1303 1303
             $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name);
1304
-            $errMsg  = "Relationship `$name` of class `" . $this->getModelClass() .
1304
+            $errMsg  = "Relationship `$name` of class `".$this->getModelClass().
1305 1305
                 '` either is not `belongsToMany` or do not exist in the class.';
1306 1306
             $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY;
1307 1307
 
@@ -1323,9 +1323,9 @@  discard block
 block discarded – undo
1323 1323
     public function removeInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int
1324 1324
     {
1325 1325
         // Check that relationship is `BelongsToMany`
1326
-        assert(call_user_func(function () use ($name): bool {
1326
+        assert(call_user_func(function() use ($name): bool {
1327 1327
             $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name);
1328
-            $errMsg  = "Relationship `$name` of class `" . $this->getModelClass() .
1328
+            $errMsg  = "Relationship `$name` of class `".$this->getModelClass().
1329 1329
                 '` either is not `belongsToMany` or do not exist in the class.';
1330 1330
             $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY;
1331 1331
 
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
     {
1494 1494
         $countBuilder = $this->createBuilder($this->getModelClass());
1495 1495
         $countBuilder->setParameters($builder->getParameters());
1496
-        $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT');
1496
+        $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT');
1497 1497
 
1498 1498
         return $countBuilder;
1499 1499
     }
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
 
1526 1526
         foreach ($secondaryIdentities as $secondaryId) {
1527 1527
             try {
1528
-                $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1528
+                $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1529 1529
             } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UcvException $exception) {
1530 1530
                 // Spec: If all of the specified resources can be added to, or are already present in,
1531 1531
                 // the relationship then the server MUST return a successful response.
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
 
1773 1773
         $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass);
1774 1774
 
1775
-        $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1775
+        $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1776 1776
             return self::registerModelAtPath(
1777 1777
                 $model,
1778 1778
                 $path,
@@ -1784,7 +1784,7 @@  discard block
 block discarded – undo
1784 1784
         };
1785 1785
 
1786 1786
         foreach ($childRelationships as $name) {
1787
-            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name;
1787
+            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name;
1788 1788
 
1789 1789
             $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name);
1790 1790
             list ($targetModelClass, $reverseRelName) =
@@ -1839,7 +1839,7 @@  discard block
 block discarded – undo
1839 1839
                             [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]],
1840 1840
                             []
1841 1841
                         );
1842
-                        $children      = $this->fetchPaginatedResourcesWithoutRelationships(
1842
+                        $children = $this->fetchPaginatedResourcesWithoutRelationships(
1843 1843
                             $clonedBuilder,
1844 1844
                             $clonedBuilder->getModelClass()
1845 1845
                         );
Please login to merge, or discard this patch.