@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param array $schemaArray |
| 89 | 89 | * @param string $body |
| 90 | 90 | * @param string $type |
| 91 | - * @return bool |
|
| 91 | + * @return null|boolean |
|
| 92 | 92 | * @throws NotMatchedException |
| 93 | 93 | */ |
| 94 | 94 | protected function matchString($name, $schemaArray, $body, $type) |
@@ -108,6 +108,9 @@ discard block |
||
| 108 | 108 | return true; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | + /** |
|
| 112 | + * @param string $name |
|
| 113 | + */ |
|
| 111 | 114 | private function checkPattern($name, $body, $pattern) |
| 112 | 115 | { |
| 113 | 116 | $isSuccess = (bool) preg_match($pattern, $body, $matches); |
@@ -123,7 +126,7 @@ discard block |
||
| 123 | 126 | * @param array $schemaArray |
| 124 | 127 | * @param string $body |
| 125 | 128 | * @param string $type |
| 126 | - * @return bool |
|
| 129 | + * @return null|boolean |
|
| 127 | 130 | */ |
| 128 | 131 | protected function matchFile($name, $schemaArray, $body, $type) |
| 129 | 132 | { |
@@ -138,7 +141,7 @@ discard block |
||
| 138 | 141 | * @param string $name |
| 139 | 142 | * @param string $body |
| 140 | 143 | * @param string $type |
| 141 | - * @return bool |
|
| 144 | + * @return null|boolean |
|
| 142 | 145 | * @throws NotMatchedException |
| 143 | 146 | */ |
| 144 | 147 | protected function matchNumber($name, $body, $type) |
@@ -162,7 +165,7 @@ discard block |
||
| 162 | 165 | * @param string $name |
| 163 | 166 | * @param string $body |
| 164 | 167 | * @param string $type |
| 165 | - * @return bool |
|
| 168 | + * @return null|boolean |
|
| 166 | 169 | * @throws NotMatchedException |
| 167 | 170 | */ |
| 168 | 171 | protected function matchBool($name, $body, $type) |
@@ -183,7 +186,7 @@ discard block |
||
| 183 | 186 | * @param array $schemaArray |
| 184 | 187 | * @param string $body |
| 185 | 188 | * @param string $type |
| 186 | - * @return bool |
|
| 189 | + * @return null|boolean |
|
| 187 | 190 | * @throws DefinitionNotFoundException |
| 188 | 191 | * @throws GenericSwaggerException |
| 189 | 192 | * @throws InvalidDefinitionException |
@@ -379,7 +382,7 @@ discard block |
||
| 379 | 382 | * @param string $body |
| 380 | 383 | * @param string $type |
| 381 | 384 | * @param bool $nullable |
| 382 | - * @return bool |
|
| 385 | + * @return null|boolean |
|
| 383 | 386 | * @throws NotMatchedException |
| 384 | 387 | */ |
| 385 | 388 | protected function matchNull($name, $body, $type, $nullable) |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | abstract class Body |
| 17 | 17 | { |
| 18 | - const SWAGGER_PROPERTIES="properties"; |
|
| 19 | - const SWAGGER_REQUIRED="required"; |
|
| 18 | + const SWAGGER_PROPERTIES = "properties"; |
|
| 19 | + const SWAGGER_REQUIRED = "required"; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * @var Schema |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return new OpenApiResponseBody($schema, $name, $structure, $allowNullValues); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - throw new GenericSwaggerException("Cannot get instance SwaggerBody or SchemaBody from " . get_class($schema)); |
|
| 81 | + throw new GenericSwaggerException("Cannot get instance SwaggerBody or SchemaBody from ".get_class($schema)); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | abstract public function match($body); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | private function checkPattern($name, $body, $pattern) |
| 112 | 112 | { |
| 113 | - $isSuccess = (bool) preg_match($pattern, $body, $matches); |
|
| 113 | + $isSuccess = (bool)preg_match($pattern, $body, $matches); |
|
| 114 | 114 | |
| 115 | 115 | if (!$isSuccess) { |
| 116 | 116 | throw new NotMatchedException("Value '$body' in '$name' not matched in pattern. ", $this->structure); |
@@ -221,32 +221,32 @@ discard block |
||
| 221 | 221 | $nullable = isset($schemaArray['nullable']) ? (bool)$schemaArray['nullable'] : $this->schema->isAllowNullValues(); |
| 222 | 222 | |
| 223 | 223 | $validators = [ |
| 224 | - function () use ($name, $body, $type, $nullable) |
|
| 224 | + function() use ($name, $body, $type, $nullable) |
|
| 225 | 225 | { |
| 226 | 226 | return $this->matchNull($name, $body, $type, $nullable); |
| 227 | 227 | }, |
| 228 | 228 | |
| 229 | - function () use ($name, $schemaArray, $body, $type) |
|
| 229 | + function() use ($name, $schemaArray, $body, $type) |
|
| 230 | 230 | { |
| 231 | 231 | return $this->matchString($name, $schemaArray, $body, $type); |
| 232 | 232 | }, |
| 233 | 233 | |
| 234 | - function () use ($name, $body, $type) |
|
| 234 | + function() use ($name, $body, $type) |
|
| 235 | 235 | { |
| 236 | 236 | return $this->matchNumber($name, $body, $type); |
| 237 | 237 | }, |
| 238 | 238 | |
| 239 | - function () use ($name, $body, $type) |
|
| 239 | + function() use ($name, $body, $type) |
|
| 240 | 240 | { |
| 241 | 241 | return $this->matchBool($name, $body, $type); |
| 242 | 242 | }, |
| 243 | 243 | |
| 244 | - function () use ($name, $schemaArray, $body, $type) |
|
| 244 | + function() use ($name, $schemaArray, $body, $type) |
|
| 245 | 245 | { |
| 246 | 246 | return $this->matchArray($name, $schemaArray, $body, $type); |
| 247 | 247 | }, |
| 248 | 248 | |
| 249 | - function () use ($name, $schemaArray, $body, $type) |
|
| 249 | + function() use ($name, $schemaArray, $body, $type) |
|
| 250 | 250 | { |
| 251 | 251 | return $this->matchFile($name, $schemaArray, $body, $type); |
| 252 | 252 | }, |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | return true; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if(!isset($schemaArray['$ref']) && isset($schemaArray['content'])) { |
|
| 349 | + if (!isset($schemaArray['$ref']) && isset($schemaArray['content'])) { |
|
| 350 | 350 | $schemaArray['$ref'] = $schemaArray['content'][key($schemaArray['content'])]['schema']['$ref']; |
| 351 | 351 | } |
| 352 | 352 | |