@@ -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 | } |
@@ -1,20 +1,20 @@ |
||
| 1 | 1 | <?php namespace Limoncello\Flute\Contracts\Models; |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Copyright 2015-2018 [email protected] |
|
| 5 | - * |
|
| 6 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 7 | - * you may not use this file except in compliance with the License. |
|
| 8 | - * You may obtain a copy of the License at |
|
| 9 | - * |
|
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | - * |
|
| 12 | - * Unless required by applicable law or agreed to in writing, software |
|
| 13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | - * See the License for the specific language governing permissions and |
|
| 16 | - * limitations under the License. |
|
| 17 | - */ |
|
| 4 | + * Copyright 2015-2018 [email protected] |
|
| 5 | + * |
|
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 7 | + * you may not use this file except in compliance with the License. |
|
| 8 | + * You may obtain a copy of the License at |
|
| 9 | + * |
|
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | + * |
|
| 12 | + * Unless required by applicable law or agreed to in writing, software |
|
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | + * See the License for the specific language governing permissions and |
|
| 16 | + * limitations under the License. |
|
| 17 | + */ |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @package Limoncello\Flute |
@@ -1,20 +1,20 @@ |
||
| 1 | 1 | <?php namespace Limoncello\Flute\Contracts\Models; |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Copyright 2015-2018 [email protected] |
|
| 5 | - * |
|
| 6 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 7 | - * you may not use this file except in compliance with the License. |
|
| 8 | - * You may obtain a copy of the License at |
|
| 9 | - * |
|
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | - * |
|
| 12 | - * Unless required by applicable law or agreed to in writing, software |
|
| 13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | - * See the License for the specific language governing permissions and |
|
| 16 | - * limitations under the License. |
|
| 17 | - */ |
|
| 4 | + * Copyright 2015-2018 [email protected] |
|
| 5 | + * |
|
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 7 | + * you may not use this file except in compliance with the License. |
|
| 8 | + * You may obtain a copy of the License at |
|
| 9 | + * |
|
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | + * |
|
| 12 | + * Unless required by applicable law or agreed to in writing, software |
|
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | + * See the License for the specific language governing permissions and |
|
| 16 | + * limitations under the License. |
|
| 17 | + */ |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @package Limoncello\Flute |
@@ -1,20 +1,20 @@ |
||
| 1 | 1 | <?php namespace Limoncello\Flute\Contracts\Models; |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Copyright 2015-2018 [email protected] |
|
| 5 | - * |
|
| 6 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 7 | - * you may not use this file except in compliance with the License. |
|
| 8 | - * You may obtain a copy of the License at |
|
| 9 | - * |
|
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | - * |
|
| 12 | - * Unless required by applicable law or agreed to in writing, software |
|
| 13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | - * See the License for the specific language governing permissions and |
|
| 16 | - * limitations under the License. |
|
| 17 | - */ |
|
| 4 | + * Copyright 2015-2018 [email protected] |
|
| 5 | + * |
|
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 7 | + * you may not use this file except in compliance with the License. |
|
| 8 | + * You may obtain a copy of the License at |
|
| 9 | + * |
|
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | + * |
|
| 12 | + * Unless required by applicable law or agreed to in writing, software |
|
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | + * See the License for the specific language governing permissions and |
|
| 16 | + * limitations under the License. |
|
| 17 | + */ |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @package Limoncello\Flute |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface; |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | - * @param QueryBuilder|null $builder |
|
| 123 | + * @param QueryBuilder $builder |
|
| 124 | 124 | * @param string|null $modelClass |
| 125 | 125 | * |
| 126 | 126 | * @return mixed|null |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param string $modelClass |
| 141 | 141 | * @param string $columnName |
| 142 | 142 | * |
| 143 | - * @return iterable |
|
| 143 | + * @return \Generator |
|
| 144 | 144 | */ |
| 145 | 145 | public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable; |
| 146 | 146 | |
@@ -161,7 +161,7 @@ |
||
| 161 | 161 | public static function readRulesEndIndexes(array $arrayRuleIndexes): array; |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | - * @param array $arrayRuleIndexes |
|
| 164 | + * @param integer[] $arrayRuleIndexes |
|
| 165 | 165 | * @param string $name |
| 166 | 166 | * |
| 167 | 167 | * @return array |
@@ -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; |
@@ -279,7 +279,7 @@ |
||
| 279 | 279 | * @param string $messagesNamespace |
| 280 | 280 | * @param string $errorMessage |
| 281 | 281 | * |
| 282 | - * @return ResponseInterface |
|
| 282 | + * @return string |
|
| 283 | 283 | */ |
| 284 | 284 | protected static function defaultCreate( |
| 285 | 285 | string $requestBody, |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | $modelClass = $schemaClass::MODEL; |
| 647 | 647 | assert($schemaInfo->hasRelationship($modelClass, $modelRelName)); |
| 648 | 648 | assert( |
| 649 | - ($type =$schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
| 649 | + ($type = $schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO || |
|
| 650 | 650 | $type === RelationshipTypes::BELONGS_TO_MANY |
| 651 | 651 | ); |
| 652 | 652 | |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | ): string { |
| 903 | 903 | $schema = $jsonSchemas->getSchema($model); |
| 904 | 904 | $selfLink = $schema->getSelfLink($model); |
| 905 | - $urlPrefix = (string)$requestUri->withPath('')->withQuery('')->withFragment(''); |
|
| 905 | + $urlPrefix = (string) $requestUri->withPath('')->withQuery('')->withFragment(''); |
|
| 906 | 906 | $fullUrl = $selfLink->getStringRepresentation($urlPrefix); |
| 907 | 907 | |
| 908 | 908 | return $fullUrl; |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | private static function assertClassValueDefined(?string $value): void |
| 917 | 917 | { |
| 918 | - assert(empty($value) === false, 'Value should be defined in `' . static::class . '`.'); |
|
| 918 | + assert(empty($value) === false, 'Value should be defined in `'.static::class.'`.'); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | /** |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | { |
| 929 | 929 | assert( |
| 930 | 930 | array_key_exists($interface, class_implements($class)) === true, |
| 931 | - "Class `$class` should implement `" . $interface . '` interface.' |
|
| 931 | + "Class `$class` should implement `".$interface.'` interface.' |
|
| 932 | 932 | ); |
| 933 | 933 | } |
| 934 | 934 | } |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | assert(class_exists($controllerClass) === true); |
| 49 | 49 | |
| 50 | 50 | $groupPrefix = $group->getUriPrefix(); |
| 51 | - $indexSlug = '/{' . JCI::ROUTE_KEY_INDEX . '}'; |
|
| 52 | - $params = function (string $method) use ($groupPrefix, $resourceName): array { |
|
| 51 | + $indexSlug = '/{'.JCI::ROUTE_KEY_INDEX.'}'; |
|
| 52 | + $params = function(string $method) use ($groupPrefix, $resourceName): array { |
|
| 53 | 53 | return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $resourceName, $method)]; |
| 54 | 54 | }; |
| 55 | - $handler = function (string $method) use ($controllerClass): array { |
|
| 55 | + $handler = function(string $method) use ($controllerClass): array { |
|
| 56 | 56 | return [$controllerClass, $method]; |
| 57 | 57 | }; |
| 58 | 58 | |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | $group->post($resourceName, $handler(JCI::METHOD_CREATE), $params(JCI::METHOD_CREATE)); |
| 66 | 66 | } |
| 67 | 67 | if (in_array(ControllerReadInterface::class, $classInterfaces) === true) { |
| 68 | - $group->get($resourceName . $indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ)); |
|
| 68 | + $group->get($resourceName.$indexSlug, $handler(JCI::METHOD_READ), $params(JCI::METHOD_READ)); |
|
| 69 | 69 | } |
| 70 | 70 | if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) { |
| 71 | - $group->patch($resourceName . $indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE)); |
|
| 71 | + $group->patch($resourceName.$indexSlug, $handler(JCI::METHOD_UPDATE), $params(JCI::METHOD_UPDATE)); |
|
| 72 | 72 | } |
| 73 | 73 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
| 74 | - $group->delete($resourceName . $indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE)); |
|
| 74 | + $group->delete($resourceName.$indexSlug, $handler(JCI::METHOD_DELETE), $params(JCI::METHOD_DELETE)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return $group; |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $groupPrefix = $group->getUriPrefix(); |
| 100 | - $slugged = $subUri . '/{' . FCI::ROUTE_KEY_INDEX . '}'; |
|
| 101 | - $params = function (string $method) use ($groupPrefix, $subUri) : array { |
|
| 100 | + $slugged = $subUri.'/{'.FCI::ROUTE_KEY_INDEX.'}'; |
|
| 101 | + $params = function(string $method) use ($groupPrefix, $subUri) : array { |
|
| 102 | 102 | return [RouteInterface::PARAM_NAME => static::routeName($groupPrefix, $subUri, $method)]; |
| 103 | 103 | }; |
| 104 | - $handler = function (string $method) use ($controllerClass): array { |
|
| 104 | + $handler = function(string $method) use ($controllerClass): array { |
|
| 105 | 105 | return [$controllerClass, $method]; |
| 106 | 106 | }; |
| 107 | 107 | |
@@ -112,10 +112,10 @@ discard block |
||
| 112 | 112 | $group->get($subUri, $handler(FCI::METHOD_INDEX), $params(FCI::METHOD_INDEX)); |
| 113 | 113 | } |
| 114 | 114 | if (in_array(ControllerInstanceInterface::class, $classInterfaces) === true) { |
| 115 | - $group->get($subUri . $createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE)); |
|
| 115 | + $group->get($subUri.$createSubUrl, $handler(FCI::METHOD_INSTANCE), $params(FCI::METHOD_INSTANCE)); |
|
| 116 | 116 | } |
| 117 | 117 | if (in_array(ControllerCreateInterface::class, $classInterfaces) === true) { |
| 118 | - $group->post($subUri . $createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE)); |
|
| 118 | + $group->post($subUri.$createSubUrl, $handler(FCI::METHOD_CREATE), $params(FCI::METHOD_CREATE)); |
|
| 119 | 119 | } |
| 120 | 120 | if (in_array(ControllerReadInterface::class, $classInterfaces) === true) { |
| 121 | 121 | $group->get($slugged, $handler(FCI::METHOD_READ), $params(FCI::METHOD_READ)); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $group->post($slugged, $handler(FCI::METHOD_UPDATE), $params(FCI::METHOD_UPDATE)); |
| 125 | 125 | } |
| 126 | 126 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
| 127 | - $deleteUri = $slugged . '/' . FCI::METHOD_DELETE; |
|
| 127 | + $deleteUri = $slugged.'/'.FCI::METHOD_DELETE; |
|
| 128 | 128 | $group->post($deleteUri, $handler(FCI::METHOD_DELETE), $params(FCI::METHOD_DELETE)); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | string $controllerClass, |
| 148 | 148 | string $selfGetMethod |
| 149 | 149 | ): GroupInterface { |
| 150 | - $resourceIdUri = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/'; |
|
| 151 | - $selfUri = $resourceIdUri . DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName; |
|
| 150 | + $resourceIdUri = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/'; |
|
| 151 | + $selfUri = $resourceIdUri.DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName; |
|
| 152 | 152 | |
| 153 | 153 | return $group |
| 154 | 154 | // `self` |
| 155 | 155 | ->get($selfUri, [$controllerClass, $selfGetMethod]) |
| 156 | 156 | // `related` |
| 157 | - ->get($resourceIdUri . $relationshipName, [$controllerClass, $selfGetMethod]); |
|
| 157 | + ->get($resourceIdUri.$relationshipName, [$controllerClass, $selfGetMethod]); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | string $controllerClass, |
| 174 | 174 | string $addMethod |
| 175 | 175 | ): GroupInterface { |
| 176 | - $url = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/' . |
|
| 177 | - DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName; |
|
| 176 | + $url = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/'. |
|
| 177 | + DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName; |
|
| 178 | 178 | |
| 179 | 179 | return $group->post($url, [$controllerClass, $addMethod]); |
| 180 | 180 | } |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | string $controllerClass, |
| 196 | 196 | string $deleteMethod |
| 197 | 197 | ): GroupInterface { |
| 198 | - $url = $resourceName . '/{' . JCI::ROUTE_KEY_INDEX . '}/' . |
|
| 199 | - DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName; |
|
| 198 | + $url = $resourceName.'/{'.JCI::ROUTE_KEY_INDEX.'}/'. |
|
| 199 | + DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName; |
|
| 200 | 200 | |
| 201 | 201 | return $group->delete($url, [$controllerClass, $deleteMethod]); |
| 202 | 202 | } |
@@ -222,6 +222,6 @@ discard block |
||
| 222 | 222 | $subUri = substr($subUri, 0, -1); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - return $prefix . $subUri . '::' . $method; |
|
| 225 | + return $prefix.$subUri.'::'.$method; |
|
| 226 | 226 | } |
| 227 | 227 | } |