Completed
Push — master ( a43bb8...369074 )
by Neomerx
10:33
created
src/Api/Crud.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             throw new InvalidArgumentException($this->getMessage(Messages::MSG_ERR_INVALID_ARGUMENT));
213 213
         }
214 214
 
215
-        assert(call_user_func(function () use ($indexes) {
215
+        assert(call_user_func(function() use ($indexes) {
216 216
             $allOk = true;
217 217
 
218 218
             foreach ($indexes as $index) {
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
             $classAtPath = new ArrayObject();
765 765
             $idsAtPath   = new ArrayObject();
766 766
 
767
-            $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
767
+            $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
768 768
                 self::registerModelAtPath(
769 769
                     $model,
770 770
                     static::ROOT_PATH,
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
                 assert(is_string($pathPiece));
853 853
                 $parent                    = $tmpPath;
854 854
                 $tmpPath                   = empty($tmpPath) === true ?
855
-                    $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece;
855
+                    $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece;
856 856
                 $normalizedPaths[$tmpPath] = [$parent, $pathPiece];
857 857
                 $pathsDepths[$parent]      = $parentDepth++;
858 858
             }
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
     ): ModelQueryBuilder {
1022 1022
         assert(
1023 1023
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $relationshipName),
1024
-            "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`'
1024
+            "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`'
1025 1025
         );
1026 1026
 
1027 1027
         // as we read data from a relationship our main table and model would be the table/model in the relationship
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
         if ($this->hasFilters() === true) {
1040 1040
             $filters = $this->getFilters();
1041 1041
             $sorts   = $this->getSorts();
1042
-            $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder::AND : ModelQueryBuilder::OR;
1042
+            $joinCondition = $this->areFiltersWithAnd() === true ? ModelQueryBuilder:: AND : ModelQueryBuilder:: OR ;
1043 1043
             $builder->addRelationshipFiltersAndSorts($reverseRelName, $filters, $sorts, $joinCondition);
1044 1044
         }
1045 1045
         // ... and the input filters to actual data we select
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
     ) {
1071 1071
         assert(
1072 1072
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1073
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1073
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1074 1074
         );
1075 1075
 
1076 1076
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
     ): array {
1100 1100
         assert(
1101 1101
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1102
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1102
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1103 1103
         );
1104 1104
 
1105 1105
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 
1176 1176
         $this->clearFetchParameters();
1177 1177
 
1178
-        return (int)$deleted;
1178
+        return (int) $deleted;
1179 1179
     }
1180 1180
 
1181 1181
     /**
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 
1192 1192
         $this->clearFetchParameters();
1193 1193
 
1194
-        return (int)$deleted > 0;
1194
+        return (int) $deleted > 0;
1195 1195
     }
1196 1196
 
1197 1197
     /**
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
         $this->clearBuilderParameters()->clearFetchParameters();
1218 1218
 
1219
-        $this->inTransaction(function () use ($saveMain, $toMany, &$index) {
1219
+        $this->inTransaction(function() use ($saveMain, $toMany, &$index) {
1220 1220
             $saveMain->execute();
1221 1221
 
1222 1222
             // if no index given will use last insert ID as index
@@ -1257,12 +1257,12 @@  discard block
 block discarded – undo
1257 1257
             ->createBuilder($this->getModelClass())
1258 1258
             ->updateModels($allowedChanges)
1259 1259
             ->addFiltersWithAndToTable($filters);
1260
-        $saveMain       = $this->builderSaveResourceOnUpdate($saveMain);
1260
+        $saveMain = $this->builderSaveResourceOnUpdate($saveMain);
1261 1261
         $saveMain->getSQL(); // prepare
1262 1262
 
1263 1263
         $this->clearBuilderParameters()->clearFetchParameters();
1264 1264
 
1265
-        $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) {
1265
+        $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) {
1266 1266
             $updated = $saveMain->execute();
1267 1267
 
1268 1268
             $builderHook = Closure::fromCallable([$this, 'builderSaveRelationshipOnUpdate']);
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
                 )->execute();
1279 1279
 
1280 1280
                 // add new ones
1281
-                $updated   += $this->addInToManyRelationship(
1281
+                $updated += $this->addInToManyRelationship(
1282 1282
                     $connection,
1283 1283
                     $index,
1284 1284
                     $relationshipName,
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
             }
1289 1289
         });
1290 1290
 
1291
-        return (int)$updated;
1291
+        return (int) $updated;
1292 1292
     }
1293 1293
 
1294 1294
     /**
@@ -1303,9 +1303,9 @@  discard block
 block discarded – undo
1303 1303
     public function createInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int
1304 1304
     {
1305 1305
         // Check that relationship is `BelongsToMany`
1306
-        assert(call_user_func(function () use ($name): bool {
1306
+        assert(call_user_func(function() use ($name): bool {
1307 1307
             $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name);
1308
-            $errMsg  = "Relationship `$name` of class `" . $this->getModelClass() .
1308
+            $errMsg  = "Relationship `$name` of class `".$this->getModelClass().
1309 1309
                 '` either is not `belongsToMany` or do not exist in the class.';
1310 1310
             $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY;
1311 1311
 
@@ -1327,9 +1327,9 @@  discard block
 block discarded – undo
1327 1327
     public function removeInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int
1328 1328
     {
1329 1329
         // Check that relationship is `BelongsToMany`
1330
-        assert(call_user_func(function () use ($name): bool {
1330
+        assert(call_user_func(function() use ($name): bool {
1331 1331
             $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name);
1332
-            $errMsg  = "Relationship `$name` of class `" . $this->getModelClass() .
1332
+            $errMsg  = "Relationship `$name` of class `".$this->getModelClass().
1333 1333
                 '` either is not `belongsToMany` or do not exist in the class.';
1334 1334
             $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY;
1335 1335
 
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
     {
1498 1498
         $countBuilder = $this->createBuilder($this->getModelClass());
1499 1499
         $countBuilder->setParameters($builder->getParameters());
1500
-        $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT');
1500
+        $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT');
1501 1501
 
1502 1502
         return $countBuilder;
1503 1503
     }
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 
1530 1530
         foreach ($secondaryIdentities as $secondaryId) {
1531 1531
             try {
1532
-                $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1532
+                $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1533 1533
             } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UcvException $exception) {
1534 1534
                 // Spec: If all of the specified resources can be added to, or are already present in,
1535 1535
                 // the relationship then the server MUST return a successful response.
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
 
1777 1777
         $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass);
1778 1778
 
1779
-        $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1779
+        $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1780 1780
             return self::registerModelAtPath(
1781 1781
                 $model,
1782 1782
                 $path,
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
         };
1789 1789
 
1790 1790
         foreach ($childRelationships as $name) {
1791
-            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name;
1791
+            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name;
1792 1792
 
1793 1793
             $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name);
1794 1794
             list ($targetModelClass, $reverseRelName) =
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
                             [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]],
1844 1844
                             []
1845 1845
                         );
1846
-                        $children      = $this->fetchPaginatedResourcesWithoutRelationships(
1846
+                        $children = $this->fetchPaginatedResourcesWithoutRelationships(
1847 1847
                             $clonedBuilder,
1848 1848
                             $clonedBuilder->getModelClass()
1849 1849
                         );
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
@@ -82,7 +82,6 @@
 block discarded – undo
82 82
         }
83 83
 
84 84
         return $result === true ?
85
-            static::createSuccessReply($values) :
86
-            static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
85
+            static::createSuccessReply($values) : static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
87 86
     }
88 87
 }
Please login to merge, or discard this patch.
src/Validation/JsonApi/Rules/ExistInDbTableMultipleWithDoctrineRule.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,13 +83,12 @@
 block discarded – undo
83 83
                 ->where($builder->expr()->in($primaryName, $placeholders))
84 84
                 ->execute();
85 85
 
86
-            $count  = (int)$statement->fetchColumn();
86
+            $count  = (int) $statement->fetchColumn();
87 87
             $result = $count === count($values);
88 88
         }
89 89
 
90 90
         $reply = $result === true ?
91
-            static::createSuccessReply($values) :
92
-            static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
91
+            static::createSuccessReply($values) : static::createErrorReply($context, $values, ErrorCodes::EXIST_IN_DATABASE_MULTIPLE);
93 92
 
94 93
         return $reply;
95 94
     }
Please login to merge, or discard this patch.