@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | throw new InvalidArgumentException('schema must be given as array or JSON string'); |
30 | 30 | } |
31 | 31 | $this->jsonFile = $data; |
32 | - $this->allowNullValues = (bool) $allowNullValues; |
|
32 | + $this->allowNullValues = (bool)$allowNullValues; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function getHttpSchema() |
@@ -121,6 +121,6 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function setAllowNullValues($value) |
123 | 123 | { |
124 | - $this->allowNullValues = (bool) $value; |
|
124 | + $this->allowNullValues = (bool)$value; |
|
125 | 125 | } |
126 | 126 | } |
@@ -285,8 +285,9 @@ |
||
285 | 285 | |
286 | 286 | // loop data blocks |
287 | 287 | foreach ($blocks as $id => $block) { |
288 | - if (empty($block)) |
|
289 | - continue; |
|
288 | + if (empty($block)) { |
|
289 | + continue; |
|
290 | + } |
|
290 | 291 | |
291 | 292 | if (strpos($block, 'application/octet-stream') !== false) { |
292 | 293 | preg_match("/name=\"([^\"]*)\".*stream[\n|\r]+([^\n\r].*)?$/s", $block, $matches); |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | ->withScheme($uriSchema->getScheme()) |
212 | 212 | ->withHost($uriSchema->getHost()) |
213 | 213 | ->withPort($uriSchema->getPort()) |
214 | - ->withPath($uriSchema->getPath() . $this->psr7Request->getUri()->getPath()); |
|
214 | + ->withPath($uriSchema->getPath().$this->psr7Request->getUri()->getPath()); |
|
215 | 215 | |
216 | - if (!preg_match("~^{$this->schema->getBasePath()}~", $uri->getPath())) { |
|
217 | - $uri = $uri->withPath($this->schema->getBasePath() . $uri->getPath()); |
|
216 | + if (!preg_match("~^{$this->schema->getBasePath()}~", $uri->getPath())) { |
|
217 | + $uri = $uri->withPath($this->schema->getBasePath().$uri->getPath()); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | $this->psr7Request = $this->psr7Request->withUri($uri); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | // Handle Request |
242 | 242 | $response = $this->handleRequest($this->psr7Request); |
243 | 243 | $responseHeader = $response->getHeaders(); |
244 | - $responseBodyStr = (string) $response->getBody(); |
|
244 | + $responseBodyStr = (string)$response->getBody(); |
|
245 | 245 | $responseBody = json_decode($responseBodyStr, true); |
246 | 246 | $statusReturned = $response->getStatusCode(); |
247 | 247 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | { |
25 | 25 | if (!isset($this->structure['schema'])) { |
26 | 26 | if (!empty($body)) { |
27 | - throw new NotMatchedException("Expected empty body for " . $this->name); |
|
27 | + throw new NotMatchedException("Expected empty body for ".$this->name); |
|
28 | 28 | } |
29 | 29 | return true; |
30 | 30 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | { |
14 | 14 | $this->body = $body; |
15 | 15 | if (!empty($body)) { |
16 | - $message = $message . " ->\n" . json_encode($body, JSON_PRETTY_PRINT) . "\n"; |
|
16 | + $message = $message." ->\n".json_encode($body, JSON_PRETTY_PRINT)."\n"; |
|
17 | 17 | } |
18 | 18 | parent::__construct($message, $code, $previous); |
19 | 19 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | $method = strtolower($method); |
80 | 80 | |
81 | - $path = preg_replace('~^' . $this->getBasePath() . '~', '', $path); |
|
81 | + $path = preg_replace('~^'.$this->getBasePath().'~', '', $path); |
|
82 | 82 | |
83 | 83 | $uri = new Uri($path); |
84 | 84 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - $pathItemPattern = '~^' . preg_replace('~{(.*?)}~', '(?<\1>[^/]+)', $pathItem) . '$~'; |
|
99 | + $pathItemPattern = '~^'.preg_replace('~{(.*?)}~', '(?<\1>[^/]+)', $pathItem).'$~'; |
|
100 | 100 | |
101 | 101 | $matches = []; |
102 | 102 | if (preg_match($pathItemPattern, $uri->getPath(), $matches)) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | - throw new PathNotFoundException('Path "' . $path . '" not found'); |
|
125 | + throw new PathNotFoundException('Path "'.$path.'" not found'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -24,12 +24,12 @@ |
||
24 | 24 | { |
25 | 25 | if (empty($this->structure['content']) && !isset($this->structure['$ref'])) { |
26 | 26 | if (!empty($body)) { |
27 | - throw new NotMatchedException("Expected empty body for " . $this->name); |
|
27 | + throw new NotMatchedException("Expected empty body for ".$this->name); |
|
28 | 28 | } |
29 | 29 | return true; |
30 | 30 | } |
31 | 31 | |
32 | - if(!isset($this->structure['content']) && isset($this->structure['$ref'])){ |
|
32 | + if (!isset($this->structure['content']) && isset($this->structure['$ref'])) { |
|
33 | 33 | $defintion = $this->schema->getDefinition($this->structure['$ref']); |
34 | 34 | return $this->matchSchema($this->name, $defintion, $body); |
35 | 35 | } |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | |
16 | 16 | abstract class Body |
17 | 17 | { |
18 | - const SWAGGER_PROPERTIES="properties"; |
|
19 | - const SWAGGER_ADDITIONAL_PROPERTIES="additionalProperties"; |
|
20 | - const SWAGGER_REQUIRED="required"; |
|
18 | + const SWAGGER_PROPERTIES = "properties"; |
|
19 | + const SWAGGER_ADDITIONAL_PROPERTIES = "additionalProperties"; |
|
20 | + const SWAGGER_REQUIRED = "required"; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @var Schema |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return new OpenApiResponseBody($schema, $name, $structure, $allowNullValues); |
80 | 80 | } |
81 | 81 | |
82 | - throw new GenericSwaggerException("Cannot get instance SwaggerBody or SchemaBody from " . get_class($schema)); |
|
82 | + throw new GenericSwaggerException("Cannot get instance SwaggerBody or SchemaBody from ".get_class($schema)); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | abstract public function match($body); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | if (!is_string($body)) { |
110 | - throw new NotMatchedException("Value '" . var_export($body, true) . "' in '$name' is not string. ", $this->structure); |
|
110 | + throw new NotMatchedException("Value '".var_export($body, true)."' in '$name' is not string. ", $this->structure); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return true; |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | |
116 | 116 | private function checkPattern($name, $body, $pattern) |
117 | 117 | { |
118 | - $pattern = '/' . rtrim(ltrim($pattern, '/'), '/') . '/'; |
|
119 | - $isSuccess = (bool) preg_match($pattern, $body, $matches); |
|
118 | + $pattern = '/'.rtrim(ltrim($pattern, '/'), '/').'/'; |
|
119 | + $isSuccess = (bool)preg_match($pattern, $body, $matches); |
|
120 | 120 | |
121 | 121 | if (!$isSuccess) { |
122 | 122 | throw new NotMatchedException("Value '$body' in '$name' not matched in pattern. ", $this->structure); |
@@ -226,32 +226,32 @@ discard block |
||
226 | 226 | $nullable = isset($schemaArray['nullable']) ? (bool)$schemaArray['nullable'] : $this->schema->isAllowNullValues(); |
227 | 227 | |
228 | 228 | $validators = [ |
229 | - function () use ($name, $body, $type, $nullable) |
|
229 | + function() use ($name, $body, $type, $nullable) |
|
230 | 230 | { |
231 | 231 | return $this->matchNull($name, $body, $type, $nullable); |
232 | 232 | }, |
233 | 233 | |
234 | - function () use ($name, $schemaArray, $body, $type) |
|
234 | + function() use ($name, $schemaArray, $body, $type) |
|
235 | 235 | { |
236 | 236 | return $this->matchString($name, $schemaArray, $body, $type); |
237 | 237 | }, |
238 | 238 | |
239 | - function () use ($name, $body, $type) |
|
239 | + function() use ($name, $body, $type) |
|
240 | 240 | { |
241 | 241 | return $this->matchNumber($name, $body, $type); |
242 | 242 | }, |
243 | 243 | |
244 | - function () use ($name, $body, $type) |
|
244 | + function() use ($name, $body, $type) |
|
245 | 245 | { |
246 | 246 | return $this->matchBool($name, $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->matchArray($name, $schemaArray, $body, $type); |
252 | 252 | }, |
253 | 253 | |
254 | - function () use ($name, $schemaArray, $body, $type) |
|
254 | + function() use ($name, $schemaArray, $body, $type) |
|
255 | 255 | { |
256 | 256 | return $this->matchFile($name, $schemaArray, $body, $type); |
257 | 257 | }, |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | return true; |
361 | 361 | } |
362 | 362 | |
363 | - if(!isset($schemaArray['$ref']) && isset($schemaArray['content'])) { |
|
363 | + if (!isset($schemaArray['$ref']) && isset($schemaArray['content'])) { |
|
364 | 364 | $schemaArray['$ref'] = $schemaArray['content'][key($schemaArray['content'])]['schema']['$ref']; |
365 | 365 | } |
366 | 366 |