@@ -865,8 +865,8 @@ |
||
| 865 | 865 | |
| 866 | 866 | /** |
| 867 | 867 | * @param array $models |
| 868 | - * @param int|string|null $offset |
|
| 869 | - * @param int|string|null $limit |
|
| 868 | + * @param integer $offset |
|
| 869 | + * @param integer $limit |
|
| 870 | 870 | * |
| 871 | 871 | * @return array |
| 872 | 872 | * |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | /** |
| 285 | 285 | * @inheritdoc |
| 286 | 286 | */ |
| 287 | - public function readRow($index): ?array |
|
| 287 | + public function readRow($index): ? array |
|
| 288 | 288 | { |
| 289 | 289 | if ($index !== null && is_scalar($index) === false) { |
| 290 | 290 | throw new InvalidArgumentException($this->getMessage(Messages::MSG_ERR_INVALID_ARGUMENT)); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | $deleted = $builder->execute(); |
| 318 | 318 | |
| 319 | - return (int)$deleted; |
|
| 319 | + return (int) $deleted; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $saveMain = $this->getRepository()->create($modelClass, $allowedChanges); |
| 336 | 336 | $saveMain = $this->builderSaveResourceOnCreate($saveMain); |
| 337 | 337 | $saveMain->getSQL(); // prepare |
| 338 | - $this->inTransaction(function () use ($modelClass, $saveMain, $toMany, &$index) { |
|
| 338 | + $this->inTransaction(function() use ($modelClass, $saveMain, $toMany, &$index) { |
|
| 339 | 339 | $saveMain->execute(); |
| 340 | 340 | // if no index given will use last insert ID as index |
| 341 | 341 | $index !== null ?: $index = $saveMain->getConnection()->lastInsertId(); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $saveMain = $this->getRepository()->update($modelClass, $index, $allowedChanges); |
| 373 | 373 | $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
| 374 | 374 | $saveMain->getSQL(); // prepare |
| 375 | - $this->inTransaction(function () use ($modelClass, $saveMain, $toMany, $index, &$updated) { |
|
| 375 | + $this->inTransaction(function() use ($modelClass, $saveMain, $toMany, $index, &$updated) { |
|
| 376 | 376 | $updated = $saveMain->execute(); |
| 377 | 377 | foreach ($toMany as $name => $values) { |
| 378 | 378 | $indexBind = ':index'; |
@@ -387,12 +387,12 @@ discard block |
||
| 387 | 387 | $saveToMany = $this->builderSaveRelationshipOnUpdate($name, $saveToMany); |
| 388 | 388 | $saveToMany->setParameter($indexBind, $index); |
| 389 | 389 | foreach ($values as $value) { |
| 390 | - $updated += (int)$saveToMany->setParameter($otherIndexBind, $value)->execute(); |
|
| 390 | + $updated += (int) $saveToMany->setParameter($otherIndexBind, $value)->execute(); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | }); |
| 394 | 394 | |
| 395 | - return (int)$updated; |
|
| 395 | + return (int) $updated; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * |
| 492 | 492 | * @return array|null |
| 493 | 493 | */ |
| 494 | - protected function fetchRow(QueryBuilder $builder, string $class): ?array |
|
| 494 | + protected function fetchRow(QueryBuilder $builder, string $class): ? array |
|
| 495 | 495 | { |
| 496 | 496 | $statement = $builder->execute(); |
| 497 | 497 | $statement->setFetchMode(PDOConnection::FETCH_ASSOC); |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | * |
| 705 | 705 | * @SuppressWarnings(PHPMD.ElseExpression) |
| 706 | 706 | */ |
| 707 | - protected function loadRelationships(PaginatedDataInterface $data, ?array $paths): void |
|
| 707 | + protected function loadRelationships(PaginatedDataInterface $data, ? array $paths) : void |
|
| 708 | 708 | { |
| 709 | 709 | if (empty($data->getData()) === false && empty($paths) === false) { |
| 710 | 710 | $modelStorage = $this->getFactory()->createModelStorage($this->getModelSchemes()); |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | foreach ($path->getPath() as $pathPiece) { |
| 763 | 763 | $parent = $tmpPath; |
| 764 | 764 | $tmpPath = empty($tmpPath) === true ? |
| 765 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
| 765 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
| 766 | 766 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
| 767 | 767 | $pathsDepths[$parent] = $parentDepth++; |
| 768 | 768 | } |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | // $models. |
| 812 | 812 | |
| 813 | 813 | foreach ($childRelationships as $name) { |
| 814 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
| 814 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
| 815 | 815 | |
| 816 | 816 | /** @var QueryBuilder $builder */ |
| 817 | 817 | list ($builder, $class, $relationshipType) = |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | parse_str($this->getOriginalUri()->getQuery(), $queryParams); |
| 127 | 127 | |
| 128 | - return function ($offset) use ($pageSize, $queryParams) { |
|
| 128 | + return function($offset) use ($pageSize, $queryParams) { |
|
| 129 | 129 | $paramsWithPaging = array_merge($queryParams, [ |
| 130 | 130 | QueryParametersParserInterface::PARAM_PAGE => [ |
| 131 | 131 | PaginationStrategyInterface::PARAM_PAGING_SKIP => $offset, |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | ], |
| 134 | 134 | ]); |
| 135 | 135 | $newUri = $this->getOriginalUri()->withQuery(http_build_query($paramsWithPaging)); |
| 136 | - $fullUrl = (string)$newUri; |
|
| 136 | + $fullUrl = (string) $newUri; |
|
| 137 | 137 | $link = $this->getFactory()->createLink($fullUrl, null, true); |
| 138 | 138 | |
| 139 | 139 | return $link; |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | assert(array_key_exists(SchemaInterface::class, class_implements($schemeClass)) === true); |
| 54 | 54 | $type = $schemeClass::TYPE; |
| 55 | 55 | |
| 56 | - $indexSlug = '/{' . CI::ROUTE_KEY_INDEX . '}'; |
|
| 57 | - $params = function ($method) use ($type) { |
|
| 58 | - return [RouteInterface::PARAM_NAME => $type . '_' . $method]; |
|
| 56 | + $indexSlug = '/{'.CI::ROUTE_KEY_INDEX.'}'; |
|
| 57 | + $params = function($method) use ($type) { |
|
| 58 | + return [RouteInterface::PARAM_NAME => $type.'_'.$method]; |
|
| 59 | 59 | }; |
| 60 | - $handler = function ($method) use ($controllerClass) { |
|
| 60 | + $handler = function($method) use ($controllerClass) { |
|
| 61 | 61 | return [$controllerClass, $method]; |
| 62 | 62 | }; |
| 63 | 63 | |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | $group->post($type, $handler(CI::METHOD_CREATE), $params(CI::METHOD_CREATE)); |
| 71 | 71 | } |
| 72 | 72 | if (in_array(ControllerReadInterface::class, $classInterfaces) === true) { |
| 73 | - $group->get($type . $indexSlug, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)); |
|
| 73 | + $group->get($type.$indexSlug, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)); |
|
| 74 | 74 | } |
| 75 | 75 | if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) { |
| 76 | - $group->patch($type . $indexSlug, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)); |
|
| 76 | + $group->patch($type.$indexSlug, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)); |
|
| 77 | 77 | } |
| 78 | 78 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
| 79 | - $group->delete($type . $indexSlug, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
|
| 79 | + $group->delete($type.$indexSlug, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return $group; |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | protected static function controller(GroupInterface $group, string $subUri, string $controllerClass): GroupInterface |
| 93 | 93 | { |
| 94 | - $slugged = $subUri . '/{' . CI::ROUTE_KEY_INDEX . '}'; |
|
| 95 | - $params = function ($method) use ($subUri) { |
|
| 96 | - return [RouteInterface::PARAM_NAME => $subUri . '_' . $method]; |
|
| 94 | + $slugged = $subUri.'/{'.CI::ROUTE_KEY_INDEX.'}'; |
|
| 95 | + $params = function($method) use ($subUri) { |
|
| 96 | + return [RouteInterface::PARAM_NAME => $subUri.'_'.$method]; |
|
| 97 | 97 | }; |
| 98 | - $handler = function ($method) use ($controllerClass) { |
|
| 98 | + $handler = function($method) use ($controllerClass) { |
|
| 99 | 99 | return [$controllerClass, $method]; |
| 100 | 100 | }; |
| 101 | 101 | |
@@ -112,11 +112,11 @@ discard block |
||
| 112 | 112 | $group->get($slugged, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)); |
| 113 | 113 | } |
| 114 | 114 | if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) { |
| 115 | - $updateUri = $slugged . '/' . CI::METHOD_UPDATE; |
|
| 115 | + $updateUri = $slugged.'/'.CI::METHOD_UPDATE; |
|
| 116 | 116 | $group->post($updateUri, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)); |
| 117 | 117 | } |
| 118 | 118 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
| 119 | - $deleteUri = $slugged . '/' . CI::METHOD_DELETE; |
|
| 119 | + $deleteUri = $slugged.'/'.CI::METHOD_DELETE; |
|
| 120 | 120 | $group->post($deleteUri, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | /** @var string $controllerClass */ |
| 149 | 149 | /** @var string $schemaClass */ |
| 150 | 150 | |
| 151 | - $resourceIdUri = $subUri . '/{' . CI::ROUTE_KEY_INDEX . '}/'; |
|
| 152 | - $selfUri = $resourceIdUri . DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName; |
|
| 151 | + $resourceIdUri = $subUri.'/{'.CI::ROUTE_KEY_INDEX.'}/'; |
|
| 152 | + $selfUri = $resourceIdUri.DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName; |
|
| 153 | 153 | |
| 154 | 154 | return $group |
| 155 | 155 | // `self` |
| 156 | 156 | ->get($selfUri, [$controllerClass, $selfGetMethod]) |
| 157 | 157 | // `related` |
| 158 | - ->get($resourceIdUri . $relationshipName, [$controllerClass, $selfGetMethod]); |
|
| 158 | + ->get($resourceIdUri.$relationshipName, [$controllerClass, $selfGetMethod]); |
|
| 159 | 159 | } |
| 160 | 160 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | ): ResponseInterface { |
| 118 | 118 | $schemeParams = self::parseQueryParameters($container, $request); |
| 119 | 119 | |
| 120 | - list ($filters, , $includes) = |
|
| 120 | + list ($filters,, $includes) = |
|
| 121 | 121 | static::mapSchemeToModelParameters($container, $schemeParams, static::SCHEMA_CLASS); |
| 122 | 122 | |
| 123 | 123 | $index = $routeParams[static::ROUTE_KEY_INDEX]; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ContainerInterface $container, |
| 141 | 141 | ServerRequestInterface $request |
| 142 | 142 | ): ResponseInterface { |
| 143 | - $jsonData = static::normalizeIndexValueOnUpdate( |
|
| 143 | + $jsonData = static::normalizeIndexValueOnUpdate( |
|
| 144 | 144 | $routeParams, |
| 145 | 145 | $container, |
| 146 | 146 | static::readJsonFromRequest($container, $request) |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | protected static function readJsonFromRequest(ContainerInterface $container, ServerRequestInterface $request): array |
| 269 | 269 | { |
| 270 | - $body = (string)$request->getBody(); |
|
| 270 | + $body = (string) $request->getBody(); |
|
| 271 | 271 | if (empty($body) === true || ($json = json_decode($body, true)) === null) { |
| 272 | 272 | /** @var FactoryInterface $factory */ |
| 273 | 273 | $factory = $container->get(FactoryInterface::class); |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | { |
| 398 | 398 | assert( |
| 399 | 399 | empty(static::ON_CREATE_VALIDATION_RULES_SET_CLASS) === false, |
| 400 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
| 400 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
| 401 | 401 | ); |
| 402 | 402 | |
| 403 | 403 | return static::createJsonApiValidator($container, static::ON_CREATE_VALIDATION_RULES_SET_CLASS); |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | { |
| 413 | 413 | assert( |
| 414 | 414 | empty(static::ON_UPDATE_VALIDATION_RULES_SET_CLASS) === false, |
| 415 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
| 415 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
| 416 | 416 | ); |
| 417 | 417 | |
| 418 | 418 | return static::createJsonApiValidator($container, static::ON_UPDATE_VALIDATION_RULES_SET_CLASS); |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | /** @var JsonSchemesInterface $jsonSchemes */ |
| 524 | 524 | $jsonSchemes = $container->get(JsonSchemesInterface::class); |
| 525 | 525 | $targetSchema = $jsonSchemes->getRelationshipSchema(static::SCHEMA_CLASS, $relationshipName); |
| 526 | - list ($filters, $sorts, , $paging) = |
|
| 526 | + list ($filters, $sorts,, $paging) = |
|
| 527 | 527 | static::mapSchemeToModelParameters($container, $encodingParams, get_class($targetSchema)); |
| 528 | 528 | |
| 529 | 529 | /** @var SchemaInterface $schemaClass */ |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * @inheritdoc |
| 70 | 70 | */ |
| 71 | - public function parseParameters(?array $parameters): array |
|
| 71 | + public function parseParameters(? array $parameters) : array |
|
| 72 | 72 | { |
| 73 | 73 | if ($parameters === null) { |
| 74 | 74 | return [0, $this->getDefaultPageSize()]; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | 0, |
| 82 | 82 | PHP_INT_MAX |
| 83 | 83 | ); |
| 84 | - $size = $this->getValue( |
|
| 84 | + $size = $this->getValue( |
|
| 85 | 85 | $parameters, |
| 86 | 86 | static::PARAM_PAGING_SIZE, |
| 87 | 87 | $this->getDefaultPageSize(), |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | continue; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $relUri = $this->getRelationshipSelfUrl($model, $jsonRelName); |
|
| 153 | + $relUri = $this->getRelationshipSelfUrl($model, $jsonRelName); |
|
| 154 | 154 | $relationships[$jsonRelName] = $this->getRelationshipDescription($model->{$modelRelName}, $relUri); |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | return [static::DATA => $data->getData()]; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $buildUrl = function ($offset) use ($data, $uri) { |
|
| 181 | + $buildUrl = function($offset) use ($data, $uri) { |
|
| 182 | 182 | $paramsWithPaging = [ |
| 183 | 183 | PaginationStrategyInterface::PARAM_PAGING_SKIP => $offset, |
| 184 | 184 | PaginationStrategyInterface::PARAM_PAGING_SIZE => $data->getLimit(), |
| 185 | 185 | ]; |
| 186 | - $fullUrl = $uri . '?' . http_build_query($paramsWithPaging); |
|
| 186 | + $fullUrl = $uri.'?'.http_build_query($paramsWithPaging); |
|
| 187 | 187 | |
| 188 | 188 | return $fullUrl; |
| 189 | 189 | }; |