@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | assert(array_key_exists(SchemaInterface::class, class_implements($schemeClass)) === true); |
49 | 49 | $subUri = $type = $schemeClass::TYPE; |
50 | 50 | |
51 | - $indexSlug = '/{' . BaseController::ROUTE_KEY_INDEX . '}'; |
|
52 | - $params = function ($method) use ($type) { |
|
53 | - return [RouteInterface::PARAM_NAME => $type . '_' . $method]; |
|
51 | + $indexSlug = '/{'.BaseController::ROUTE_KEY_INDEX.'}'; |
|
52 | + $params = function($method) use ($type) { |
|
53 | + return [RouteInterface::PARAM_NAME => $type.'_'.$method]; |
|
54 | 54 | }; |
55 | - $handler = function ($method) use ($controllerClass) { |
|
55 | + $handler = function($method) use ($controllerClass) { |
|
56 | 56 | return [$controllerClass, $method]; |
57 | 57 | }; |
58 | 58 | |
59 | 59 | return $group |
60 | 60 | ->get($subUri, $handler(CI::METHOD_INDEX), $params(CI::METHOD_INDEX)) |
61 | 61 | ->post($subUri, $handler(CI::METHOD_CREATE), $params(CI::METHOD_CREATE)) |
62 | - ->get($subUri . $indexSlug, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)) |
|
63 | - ->patch($subUri . $indexSlug, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)) |
|
64 | - ->delete($subUri . $indexSlug, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
|
62 | + ->get($subUri.$indexSlug, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)) |
|
63 | + ->patch($subUri.$indexSlug, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)) |
|
64 | + ->delete($subUri.$indexSlug, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | |
85 | 85 | /** @var SchemaInterface $schemaClass */ |
86 | 86 | assert(array_key_exists(SchemaInterface::class, class_implements($schemaClass)) === true); |
87 | - $subUri = $schemaClass::TYPE; |
|
87 | + $subUri = $schemaClass::TYPE; |
|
88 | 88 | |
89 | 89 | /** @var string $controllerClass */ |
90 | 90 | /** @var string $schemaClass */ |
91 | 91 | |
92 | - $resourceIdUri = $subUri . '/{' . BaseController::ROUTE_KEY_INDEX . '}/'; |
|
93 | - $selfUri = $resourceIdUri . DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName; |
|
92 | + $resourceIdUri = $subUri.'/{'.BaseController::ROUTE_KEY_INDEX.'}/'; |
|
93 | + $selfUri = $resourceIdUri.DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName; |
|
94 | 94 | |
95 | 95 | return $group |
96 | 96 | // `self` |
97 | 97 | ->get($selfUri, [$controllerClass, $selfGetMethod]) |
98 | 98 | // `related` |
99 | - ->get($resourceIdUri . $relationshipName, [$controllerClass, $selfGetMethod]); |
|
99 | + ->get($resourceIdUri.$relationshipName, [$controllerClass, $selfGetMethod]); |
|
100 | 100 | } |
101 | 101 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @return null|SortParameterInterface[] |
176 | 176 | */ |
177 | - protected function mapSortParameters(ErrorCollection $errors, array $parameters = null): ?array |
|
177 | + protected function mapSortParameters(ErrorCollection $errors, array $parameters = null): ? array |
|
178 | 178 | { |
179 | 179 | $sorts = null; |
180 | 180 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return null|IncludeParameterInterface[] |
201 | 201 | */ |
202 | - protected function mapIncludeParameters(ErrorCollection $errors, array $parameters = null): ?array |
|
202 | + protected function mapIncludeParameters(ErrorCollection $errors, array $parameters = null): ? array |
|
203 | 203 | { |
204 | 204 | $includes = null; |
205 | 205 |
@@ -124,7 +124,7 @@ |
||
124 | 124 | * |
125 | 125 | * @return array|null |
126 | 126 | */ |
127 | - public function readRow($index): ?array; |
|
127 | + public function readRow($index): ? array; |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @param FilterParameterCollection|null $filterParams |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * |
35 | 35 | * @return self |
36 | 36 | */ |
37 | - public function setRelationshipStorage(?RelationshipStorageInterface $storage): self; |
|
37 | + public function setRelationshipStorage(?RelationshipStorageInterface $storage) : self; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @param string $schemaClass |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | /** |
282 | 282 | * @inheritdoc |
283 | 283 | */ |
284 | - public function readRow($index): ?array |
|
284 | + public function readRow($index): ? array |
|
285 | 285 | { |
286 | 286 | $modelClass = $this->getModelClass(); |
287 | 287 | $builder = $this->getRepository() |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | $deleted = $builder->execute(); |
307 | 307 | |
308 | - return (int)$deleted; |
|
308 | + return (int) $deleted; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $saveMain = $this->getRepository()->create($modelClass, $allowedChanges); |
321 | 321 | $saveMain = $this->builderSaveResourceOnCreate($saveMain); |
322 | 322 | $saveMain->getSQL(); // prepare |
323 | - $this->inTransaction(function () use ($modelClass, $saveMain, $toMany, &$index) { |
|
323 | + $this->inTransaction(function() use ($modelClass, $saveMain, $toMany, &$index) { |
|
324 | 324 | $saveMain->execute(); |
325 | 325 | // if no index given will use last insert ID as index |
326 | 326 | $index !== null ?: $index = $saveMain->getConnection()->lastInsertId(); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $saveMain = $this->getRepository()->update($modelClass, $index, $allowedChanges); |
354 | 354 | $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
355 | 355 | $saveMain->getSQL(); // prepare |
356 | - $this->inTransaction(function () use ($modelClass, $saveMain, $toMany, $index, &$updated) { |
|
356 | + $this->inTransaction(function() use ($modelClass, $saveMain, $toMany, $index, &$updated) { |
|
357 | 357 | $updated = $saveMain->execute(); |
358 | 358 | foreach ($toMany as $name => $values) { |
359 | 359 | $indexBind = ':index'; |
@@ -368,12 +368,12 @@ discard block |
||
368 | 368 | $saveToMany = $this->builderSaveRelationshipOnUpdate($name, $saveToMany); |
369 | 369 | $saveToMany->setParameter($indexBind, $index); |
370 | 370 | foreach ($values as $value) { |
371 | - $updated += (int)$saveToMany->setParameter($otherIndexBind, $value)->execute(); |
|
371 | + $updated += (int) $saveToMany->setParameter($otherIndexBind, $value)->execute(); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | }); |
375 | 375 | |
376 | - return (int)$updated; |
|
376 | + return (int) $updated; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @return array|null |
488 | 488 | */ |
489 | - protected function fetchRow(QueryBuilder $builder, string $class): ?array |
|
489 | + protected function fetchRow(QueryBuilder $builder, string $class): ? array |
|
490 | 490 | { |
491 | 491 | $statement = $builder->execute(); |
492 | 492 | $statement->setFetchMode(PDOConnection::FETCH_ASSOC); |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | foreach ($path->getPath() as $pathPiece) { |
799 | 799 | $parent = $tmpPath; |
800 | 800 | $tmpPath = empty($tmpPath) === true ? |
801 | - $pathPiece : $tmpPath . static::$pathSeparator . $pathPiece; |
|
801 | + $pathPiece : $tmpPath.static::$pathSeparator.$pathPiece; |
|
802 | 802 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
803 | 803 | $pathsDepths[$parent] = $parentDepth++; |
804 | 804 | } |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | // $models. |
850 | 850 | |
851 | 851 | foreach ($childRelationships as $name) { |
852 | - $childrenPath = $parentsPath !== static::$rootPath ? $parentsPath . static::$pathSeparator . $name : $name; |
|
852 | + $childrenPath = $parentsPath !== static::$rootPath ? $parentsPath.static::$pathSeparator.$name : $name; |
|
853 | 853 | |
854 | 854 | /** @var QueryBuilder $builder */ |
855 | 855 | list ($builder, $class, $relationshipType) = |
@@ -61,7 +61,7 @@ |
||
61 | 61 | /** |
62 | 62 | * @inheritdoc |
63 | 63 | */ |
64 | - public function setRelationshipStorage(?RelationshipStorageInterface $storage): JsonSchemesInterface |
|
64 | + public function setRelationshipStorage(?RelationshipStorageInterface $storage) : JsonSchemesInterface |
|
65 | 65 | { |
66 | 66 | $this->relationshipStorage = $storage; |
67 | 67 |