@@ -71,8 +71,7 @@ |
||
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 | } |
@@ -77,7 +77,6 @@ |
||
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 | } |
@@ -76,7 +76,6 @@ |
||
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 | } |
@@ -86,8 +86,7 @@ |
||
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 | } |
@@ -81,8 +81,7 @@ |
||
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 | } |
@@ -82,8 +82,7 @@ |
||
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 | } |
@@ -62,8 +62,7 @@ |
||
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 | } |
@@ -207,7 +207,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | ); |