@@ -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 | } |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | foreach ($operationsWithArgs as $operation => $arguments) { |
| 531 | 531 | assert( |
| 532 | 532 | is_iterable($arguments) === true || is_array($arguments) === true, |
| 533 | - "Operation arguments are missing for `$columnName` column. " . |
|
| 533 | + "Operation arguments are missing for `$columnName` column. ". |
|
| 534 | 534 | 'Use an empty array as an empty argument list.' |
| 535 | 535 | ); |
| 536 | 536 | $expression->add($this->createFilterExpression($fullColumnName, $operation, $arguments)); |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | */ |
| 566 | 566 | public function buildColumnName(string $table, string $column): string |
| 567 | 567 | { |
| 568 | - return $this->quoteTableName($table) . '.' . $this->quoteColumnName($column); |
|
| 568 | + return $this->quoteTableName($table).'.'.$this->quoteColumnName($column); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | */ |
| 608 | 608 | public function createAlias(string $tableName): string |
| 609 | 609 | { |
| 610 | - $alias = $tableName . (++$this->aliasIdCounter); |
|
| 610 | + $alias = $tableName.(++$this->aliasIdCounter); |
|
| 611 | 611 | $this->knownAliases[$tableName] = $alias; |
| 612 | 612 | |
| 613 | 613 | return $alias; |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | string $targetColumn |
| 662 | 662 | ): string { |
| 663 | 663 | $targetAlias = $this->createAlias($targetTable); |
| 664 | - $joinCondition = $this->buildColumnName($fromAlias, $fromColumn) . '=' . |
|
| 664 | + $joinCondition = $this->buildColumnName($fromAlias, $fromColumn).'='. |
|
| 665 | 665 | $this->buildColumnName($targetAlias, $targetColumn); |
| 666 | 666 | |
| 667 | 667 | $this->innerJoin( |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | } else { |
| 860 | 860 | assert( |
| 861 | 861 | $value !== null, |
| 862 | - 'It seems you are trying to use `null` with =, >, <, or etc operator. ' . |
|
| 862 | + 'It seems you are trying to use `null` with =, >, <, or etc operator. '. |
|
| 863 | 863 | 'Use `is null` or `not null` instead.' |
| 864 | 864 | ); |
| 865 | 865 | assert(is_string($value), "Only strings, booleans and integers are supported."); |
@@ -208,7 +208,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -1036,8 +1036,7 @@ discard block |
||
| 1036 | 1036 | $filters = $this->getFilters(); |
| 1037 | 1037 | $sorts = $this->getSorts(); |
| 1038 | 1038 | $this->areFiltersWithAnd() ? |
| 1039 | - $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : |
|
| 1040 | - $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
| 1039 | + $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
| 1041 | 1040 | } |
| 1042 | 1041 | // ... and the input filters to actual data we select |
| 1043 | 1042 | if ($relationshipFilters !== null) { |
@@ -1067,7 +1066,7 @@ discard block |
||
| 1067 | 1066 | ) { |
| 1068 | 1067 | assert( |
| 1069 | 1068 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
| 1070 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
| 1069 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
| 1071 | 1070 | ); |
| 1072 | 1071 | |
| 1073 | 1072 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1096,7 +1095,7 @@ discard block |
||
| 1096 | 1095 | ): array { |
| 1097 | 1096 | assert( |
| 1098 | 1097 | $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name), |
| 1099 | - "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`' |
|
| 1098 | + "Relationship `$name` do not exist in model `".$this->getModelClass().'`' |
|
| 1100 | 1099 | ); |
| 1101 | 1100 | |
| 1102 | 1101 | // depending on the relationship type we expect the result to be either single resource or a collection |
@@ -1172,7 +1171,7 @@ discard block |
||
| 1172 | 1171 | |
| 1173 | 1172 | $this->clearFetchParameters(); |
| 1174 | 1173 | |
| 1175 | - return (int)$deleted; |
|
| 1174 | + return (int) $deleted; |
|
| 1176 | 1175 | } |
| 1177 | 1176 | |
| 1178 | 1177 | /** |
@@ -1188,7 +1187,7 @@ discard block |
||
| 1188 | 1187 | |
| 1189 | 1188 | $this->clearFetchParameters(); |
| 1190 | 1189 | |
| 1191 | - return (int)$deleted > 0; |
|
| 1190 | + return (int) $deleted > 0; |
|
| 1192 | 1191 | } |
| 1193 | 1192 | |
| 1194 | 1193 | /** |
@@ -1213,7 +1212,7 @@ discard block |
||
| 1213 | 1212 | |
| 1214 | 1213 | $this->clearBuilderParameters()->clearFetchParameters(); |
| 1215 | 1214 | |
| 1216 | - $this->inTransaction(function () use ($saveMain, $toMany, &$index) { |
|
| 1215 | + $this->inTransaction(function() use ($saveMain, $toMany, &$index) { |
|
| 1217 | 1216 | $saveMain->execute(); |
| 1218 | 1217 | |
| 1219 | 1218 | // if no index given will use last insert ID as index |
@@ -1254,12 +1253,12 @@ discard block |
||
| 1254 | 1253 | ->createBuilder($this->getModelClass()) |
| 1255 | 1254 | ->updateModels($allowedChanges) |
| 1256 | 1255 | ->addFiltersWithAndToTable($filters); |
| 1257 | - $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
| 1256 | + $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
|
| 1258 | 1257 | $saveMain->getSQL(); // prepare |
| 1259 | 1258 | |
| 1260 | 1259 | $this->clearBuilderParameters()->clearFetchParameters(); |
| 1261 | 1260 | |
| 1262 | - $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) { |
|
| 1261 | + $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) { |
|
| 1263 | 1262 | $updated = $saveMain->execute(); |
| 1264 | 1263 | |
| 1265 | 1264 | $builderHook = Closure::fromCallable([$this, 'builderSaveRelationshipOnUpdate']); |
@@ -1275,7 +1274,7 @@ discard block |
||
| 1275 | 1274 | )->execute(); |
| 1276 | 1275 | |
| 1277 | 1276 | // add new ones |
| 1278 | - $updated += $this->addInToManyRelationship( |
|
| 1277 | + $updated += $this->addInToManyRelationship( |
|
| 1279 | 1278 | $connection, |
| 1280 | 1279 | $index, |
| 1281 | 1280 | $relationshipName, |
@@ -1285,7 +1284,7 @@ discard block |
||
| 1285 | 1284 | } |
| 1286 | 1285 | }); |
| 1287 | 1286 | |
| 1288 | - return (int)$updated; |
|
| 1287 | + return (int) $updated; |
|
| 1289 | 1288 | } |
| 1290 | 1289 | |
| 1291 | 1290 | /** |
@@ -1300,9 +1299,9 @@ discard block |
||
| 1300 | 1299 | public function createInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int |
| 1301 | 1300 | { |
| 1302 | 1301 | // Check that relationship is `BelongsToMany` |
| 1303 | - assert(call_user_func(function () use ($name): bool { |
|
| 1302 | + assert(call_user_func(function() use ($name): bool { |
|
| 1304 | 1303 | $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name); |
| 1305 | - $errMsg = "Relationship `$name` of class `" . $this->getModelClass() . |
|
| 1304 | + $errMsg = "Relationship `$name` of class `".$this->getModelClass(). |
|
| 1306 | 1305 | '` either is not `belongsToMany` or do not exist in the class.'; |
| 1307 | 1306 | $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY; |
| 1308 | 1307 | |
@@ -1324,9 +1323,9 @@ discard block |
||
| 1324 | 1323 | public function removeInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int |
| 1325 | 1324 | { |
| 1326 | 1325 | // Check that relationship is `BelongsToMany` |
| 1327 | - assert(call_user_func(function () use ($name): bool { |
|
| 1326 | + assert(call_user_func(function() use ($name): bool { |
|
| 1328 | 1327 | $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name); |
| 1329 | - $errMsg = "Relationship `$name` of class `" . $this->getModelClass() . |
|
| 1328 | + $errMsg = "Relationship `$name` of class `".$this->getModelClass(). |
|
| 1330 | 1329 | '` either is not `belongsToMany` or do not exist in the class.'; |
| 1331 | 1330 | $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY; |
| 1332 | 1331 | |
@@ -1494,7 +1493,7 @@ discard block |
||
| 1494 | 1493 | { |
| 1495 | 1494 | $countBuilder = $this->createBuilder($this->getModelClass()); |
| 1496 | 1495 | $countBuilder->setParameters($builder->getParameters()); |
| 1497 | - $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT'); |
|
| 1496 | + $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT'); |
|
| 1498 | 1497 | |
| 1499 | 1498 | return $countBuilder; |
| 1500 | 1499 | } |
@@ -1526,7 +1525,7 @@ discard block |
||
| 1526 | 1525 | |
| 1527 | 1526 | foreach ($secondaryIdentities as $secondaryId) { |
| 1528 | 1527 | try { |
| 1529 | - $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
| 1528 | + $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute(); |
|
| 1530 | 1529 | } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UcvException $exception) { |
| 1531 | 1530 | // Spec: If all of the specified resources can be added to, or are already present in, |
| 1532 | 1531 | // the relationship then the server MUST return a successful response. |
@@ -1773,7 +1772,7 @@ discard block |
||
| 1773 | 1772 | |
| 1774 | 1773 | $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass); |
| 1775 | 1774 | |
| 1776 | - $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
| 1775 | + $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) { |
|
| 1777 | 1776 | return self::registerModelAtPath( |
| 1778 | 1777 | $model, |
| 1779 | 1778 | $path, |
@@ -1785,7 +1784,7 @@ discard block |
||
| 1785 | 1784 | }; |
| 1786 | 1785 | |
| 1787 | 1786 | foreach ($childRelationships as $name) { |
| 1788 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
| 1787 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
| 1789 | 1788 | |
| 1790 | 1789 | $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name); |
| 1791 | 1790 | list ($targetModelClass, $reverseRelName) = |
@@ -1840,7 +1839,7 @@ discard block |
||
| 1840 | 1839 | [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]], |
| 1841 | 1840 | [] |
| 1842 | 1841 | ); |
| 1843 | - $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
| 1842 | + $children = $this->fetchPaginatedResourcesWithoutRelationships( |
|
| 1844 | 1843 | $clonedBuilder, |
| 1845 | 1844 | $clonedBuilder->getModelClass() |
| 1846 | 1845 | ); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | private $serializedRules = []; |
| 36 | 36 | |
| 37 | 37 | /** Index key */ |
| 38 | - protected const IDENTITY_RULE= 0; |
|
| 38 | + protected const IDENTITY_RULE = 0; |
|
| 39 | 39 | |
| 40 | 40 | /** Index key */ |
| 41 | 41 | protected const FILTER_RULES = self::IDENTITY_RULE + 1; |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | $modelClass = $schemaClass::MODEL; |
| 650 | 650 | assert($schemaInfo->hasRelationship($modelClass, $modelRelName)); |
| 651 | 651 | assert( |
| 652 | - ($type =$schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
| 652 | + ($type = $schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
| 653 | 653 | $type === RelationshipTypes::BELONGS_TO_MANY |
| 654 | 654 | ); |
| 655 | 655 | |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | */ |
| 905 | 905 | private static function assertClassValueDefined(?string $value): void |
| 906 | 906 | { |
| 907 | - assert(empty($value) === false, 'Value should be defined in `' . static::class . '`.'); |
|
| 907 | + assert(empty($value) === false, 'Value should be defined in `'.static::class.'`.'); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | /** |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | { |
| 918 | 918 | assert( |
| 919 | 919 | array_key_exists($interface, class_implements($class)) === true, |
| 920 | - "Class `$class` should implement `" . $interface . '` interface.' |
|
| 920 | + "Class `$class` should implement `".$interface.'` interface.' |
|
| 921 | 921 | ); |
| 922 | 922 | } |
| 923 | 923 | } |
@@ -242,12 +242,11 @@ discard block |
||
| 242 | 242 | $this->executeStarts($this->getSerializer()::readRuleStartIndexes($ruleIndexes)); |
| 243 | 243 | $ruleIndex = $this->getSerializer()::readRuleIndex($ruleIndexes); |
| 244 | 244 | $isFoundInToOne === true ? |
| 245 | - $this->validateAsToOneRelationship($ruleIndex, $name, $jsonData) : |
|
| 246 | - $this->validateAsToManyRelationship($ruleIndex, $name, $jsonData); |
|
| 245 | + $this->validateAsToOneRelationship($ruleIndex, $name, $jsonData) : $this->validateAsToManyRelationship($ruleIndex, $name, $jsonData); |
|
| 247 | 246 | $this->executeEnds($this->getSerializer()::readRuleEndIndexes($ruleIndexes)); |
| 248 | 247 | |
| 249 | 248 | if (count($this->getErrorAggregator()) > 0) { |
| 250 | - $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 249 | + $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 251 | 250 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 252 | 251 | $this->getJsonApiErrorCollection()->addValidationRelationshipError($error, $status); |
| 253 | 252 | $this->addErrorStatus($status); |
@@ -364,7 +363,7 @@ discard block |
||
| 364 | 363 | |
| 365 | 364 | if (count($this->getErrorAggregator()) > 0) { |
| 366 | 365 | $title = $this->formatMessage(ErrorCodes::INVALID_VALUE); |
| 367 | - $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 366 | + $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 368 | 367 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 369 | 368 | $details = $this->getMessage($error); |
| 370 | 369 | $this->getJsonApiErrorCollection()->addDataTypeError($title, $details, $status); |
@@ -459,7 +458,7 @@ discard block |
||
| 459 | 458 | $this->executeEnds($ends); |
| 460 | 459 | |
| 461 | 460 | if (count($this->getErrorAggregator()) > 0) { |
| 462 | - $status = JsonApiResponse::HTTP_UNPROCESSABLE_ENTITY; |
|
| 461 | + $status = JsonApiResponse::HTTP_UNPROCESSABLE_ENTITY; |
|
| 463 | 462 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 464 | 463 | $this->getJsonApiErrorCollection()->addValidationAttributeError($error, $status); |
| 465 | 464 | } |
@@ -528,7 +527,7 @@ discard block |
||
| 528 | 527 | $this->executeEnds($ends); |
| 529 | 528 | |
| 530 | 529 | if (count($this->getErrorAggregator()) > 0) { |
| 531 | - $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 530 | + $status = JsonApiResponse::HTTP_CONFLICT; |
|
| 532 | 531 | foreach ($this->getErrorAggregator()->get() as $error) { |
| 533 | 532 | $this->getJsonApiErrorCollection()->addValidationRelationshipError($error, $status); |
| 534 | 533 | } |
@@ -212,12 +212,12 @@ |
||
| 212 | 212 | return [static::DATA => $data->getData()]; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - $buildUrl = function ($offset) use ($data, $uri) { |
|
| 215 | + $buildUrl = function($offset) use ($data, $uri) { |
|
| 216 | 216 | $paramsWithPaging = [ |
| 217 | 217 | JsonApiQueryParserInterface::PARAM_PAGING_OFFSET => $offset, |
| 218 | 218 | JsonApiQueryParserInterface::PARAM_PAGING_LIMIT => $data->getLimit(), |
| 219 | 219 | ]; |
| 220 | - $fullUrl = $uri . '?' . http_build_query($paramsWithPaging); |
|
| 220 | + $fullUrl = $uri.'?'.http_build_query($paramsWithPaging); |
|
| 221 | 221 | |
| 222 | 222 | return $fullUrl; |
| 223 | 223 | }; |