@@ -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 | } |
@@ -157,6 +157,9 @@ discard block |
||
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
160 | + /** |
|
161 | + * @param integer $code |
|
162 | + */ |
|
160 | 163 | public function assertResponseCode($code) |
161 | 164 | { |
162 | 165 | $this->statusExpected = $code; |
@@ -266,6 +269,10 @@ discard block |
||
266 | 269 | return $response; |
267 | 270 | } |
268 | 271 | |
272 | + /** |
|
273 | + * @param string $contentType |
|
274 | + * @param string $body |
|
275 | + */ |
|
269 | 276 | protected function parseMultiPartForm($contentType, $body) |
270 | 277 | { |
271 | 278 | $matchRequest = []; |
@@ -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 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param $schema |
83 | 83 | * @param $body |
84 | 84 | * @param $type |
85 | - * @return bool |
|
85 | + * @return null|boolean |
|
86 | 86 | * @throws NotMatchedException |
87 | 87 | */ |
88 | 88 | protected function matchString($name, $schema, $body, $type) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param $schema |
104 | 104 | * @param $body |
105 | 105 | * @param $type |
106 | - * @return bool |
|
106 | + * @return null|boolean |
|
107 | 107 | * @throws NotMatchedException |
108 | 108 | */ |
109 | 109 | protected function matchFile($name, $schema, $body, $type) |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param $name |
120 | 120 | * @param $body |
121 | 121 | * @param $type |
122 | - * @return bool |
|
122 | + * @return null|boolean |
|
123 | 123 | * @throws NotMatchedException |
124 | 124 | */ |
125 | 125 | protected function matchNumber($name, $body, $type) |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param $name |
140 | 140 | * @param $body |
141 | 141 | * @param $type |
142 | - * @return bool |
|
142 | + * @return null|boolean |
|
143 | 143 | * @throws NotMatchedException |
144 | 144 | */ |
145 | 145 | protected function matchBool($name, $body, $type) |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param $schema |
161 | 161 | * @param $body |
162 | 162 | * @param $type |
163 | - * @return bool |
|
163 | + * @return null|boolean |
|
164 | 164 | * @throws DefinitionNotFoundException |
165 | 165 | * @throws GenericSwaggerException |
166 | 166 | * @throws InvalidDefinitionException |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | - * @param $name |
|
237 | + * @param string $name |
|
238 | 238 | * @param $schema |
239 | 239 | * @param $body |
240 | 240 | * @return bool|null |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @param $body |
351 | 351 | * @param $type |
352 | 352 | * @param $nullable |
353 | - * @return bool |
|
353 | + * @return null|boolean |
|
354 | 354 | * @throws NotMatchedException |
355 | 355 | */ |
356 | 356 | 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 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | return new OpenApiResponseBody($schema, $name, $structure, $allowNullValues); |
73 | 73 | } |
74 | 74 | |
75 | - throw new GenericSwaggerException("Cannot get instance SwaggerBody or SchemaBody from " . get_class($schema)); |
|
75 | + throw new GenericSwaggerException("Cannot get instance SwaggerBody or SchemaBody from ".get_class($schema)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | abstract public function match($body); |
@@ -192,32 +192,32 @@ discard block |
||
192 | 192 | $nullable = isset($schema['nullable']) ? (bool)$schema['nullable'] : $this->schema->isAllowNullValues(); |
193 | 193 | |
194 | 194 | $validators = [ |
195 | - function () use ($name, $body, $type, $nullable) |
|
195 | + function() use ($name, $body, $type, $nullable) |
|
196 | 196 | { |
197 | 197 | return $this->matchNull($name, $body, $type, $nullable); |
198 | 198 | }, |
199 | 199 | |
200 | - function () use ($name, $schema, $body, $type) |
|
200 | + function() use ($name, $schema, $body, $type) |
|
201 | 201 | { |
202 | 202 | return $this->matchString($name, $schema, $body, $type); |
203 | 203 | }, |
204 | 204 | |
205 | - function () use ($name, $body, $type) |
|
205 | + function() use ($name, $body, $type) |
|
206 | 206 | { |
207 | 207 | return $this->matchNumber($name, $body, $type); |
208 | 208 | }, |
209 | 209 | |
210 | - function () use ($name, $body, $type) |
|
210 | + function() use ($name, $body, $type) |
|
211 | 211 | { |
212 | 212 | return $this->matchBool($name, $body, $type); |
213 | 213 | }, |
214 | 214 | |
215 | - function () use ($name, $schema, $body, $type) |
|
215 | + function() use ($name, $schema, $body, $type) |
|
216 | 216 | { |
217 | 217 | return $this->matchArray($name, $schema, $body, $type); |
218 | 218 | }, |
219 | 219 | |
220 | - function () use ($name, $schema, $body, $type) |
|
220 | + function() use ($name, $schema, $body, $type) |
|
221 | 221 | { |
222 | 222 | return $this->matchFile($name, $schema, $body, $type); |
223 | 223 | }, |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | return true; |
318 | 318 | } |
319 | 319 | |
320 | - if(!isset($schema['$ref']) && isset($schema['content'])) { |
|
320 | + if (!isset($schema['$ref']) && isset($schema['content'])) { |
|
321 | 321 | $schema['$ref'] = $schema['content'][key($schema['content'])]['schema']['$ref']; |
322 | 322 | } |
323 | 323 |
@@ -61,7 +61,7 @@ |
||
61 | 61 | * @param array|null $query |
62 | 62 | * @param array|null $requestBody |
63 | 63 | * @param array $requestHeader |
64 | - * @return mixed |
|
64 | + * @return \Psr\Http\Message\ResponseInterface |
|
65 | 65 | * @throws DefinitionNotFoundException |
66 | 66 | * @throws GenericSwaggerException |
67 | 67 | * @throws HttpMethodNotFoundException |
@@ -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 | } |