@@ -20,7 +20,7 @@ |
||
20 | 20 | protected function readAuthorizationToken(): ?string |
21 | 21 | { |
22 | 22 | $apiKey = $_COOKIE[$this->cookieName] ?? null; |
23 | - if (!$apiKey) { |
|
23 | + if ( ! $apiKey) { |
|
24 | 24 | $this->errorMessage = 'API key is not set'; |
25 | 25 | return null; |
26 | 26 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | protected function readAuthorizationToken(): ?string |
30 | 30 | { |
31 | - if (!isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
31 | + if ( ! isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
32 | 32 | $this->errorMessage = 'Authorization header HTTP_Authorization is not set'; |
33 | 33 | return null; |
34 | 34 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | class BearerTokenAuthorization extends TokenAuthorization |
11 | 11 | { |
12 | - /** |
|
12 | + /** |
|
13 | 13 | * BearerTokenAuthorization constructor. |
14 | 14 | * |
15 | 15 | * @param TokenRepositoryInterface $tokenRepository |
@@ -21,7 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | $headerName = 'HTTP_' . strtoupper(str_replace('-', '_', $this->headerName)); |
23 | 23 | $apiKey = $_SERVER[$headerName] ?? null; |
24 | - if (!$apiKey) { |
|
24 | + if ( ! $apiKey) { |
|
25 | 25 | $this->errorMessage = 'API key is not set'; |
26 | 26 | return null; |
27 | 27 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | protected function readAuthorizationToken(): ?string |
21 | 21 | { |
22 | 22 | $apiKey = $_GET[$this->queryParamName] ?? null; |
23 | - if (!$apiKey) { |
|
23 | + if ( ! $apiKey) { |
|
24 | 24 | $this->errorMessage = 'API key is not set'; |
25 | 25 | return null; |
26 | 26 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | $result = $this->tokenRepository->validToken($token); |
49 | - if (!$result) { |
|
49 | + if ( ! $result) { |
|
50 | 50 | $this->errorMessage = 'Token doesn\'t exists or isn\'t active'; |
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | |
54 | - if (!$this->isValidIp($this->tokenRepository->ipRestrictions($token))) { |
|
54 | + if ( ! $this->isValidIp($this->tokenRepository->ipRestrictions($token))) { |
|
55 | 55 | $this->errorMessage = 'Invalid IP'; |
56 | 56 | return false; |
57 | 57 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | list($range, $netmask) = explode('/', $range, 2); |
115 | 115 | $range_decimal = ip2long($range); |
116 | 116 | $ipDecimal = ip2long($ip); |
117 | - $wildcard_decimal = pow(2, (32 - (int)$netmask)) - 1; |
|
117 | + $wildcard_decimal = pow(2, (32 - (int) $netmask)) - 1; |
|
118 | 118 | $netmask_decimal = ~ $wildcard_decimal; |
119 | 119 | return (($ipDecimal & $netmask_decimal) === ($range_decimal & $netmask_decimal)); |
120 | 120 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | } elseif ($param->getType() === InputParam::TYPE_COOKIE) { |
170 | 170 | $cookieFields[$key][] = $valueData; |
171 | 171 | } else { |
172 | - $getFields[$key][] = urlencode((string)$valueData); |
|
172 | + $getFields[$key][] = urlencode((string) $valueData); |
|
173 | 173 | } |
174 | 174 | } else { |
175 | 175 | if (in_array($param->getType(), [InputParam::TYPE_POST, InputParam::TYPE_FILE])) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } elseif ($param->getType() === InputParam::TYPE_COOKIE) { |
180 | 180 | $cookieFields[$key] = $valueData; |
181 | 181 | } else { |
182 | - $getFields[$key] = urlencode((string)$valueData); |
|
182 | + $getFields[$key] = urlencode((string) $valueData); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | { |
224 | 224 | $result = []; |
225 | 225 | foreach ($values as $key => $value) { |
226 | - if (!is_array($value)) { |
|
226 | + if ( ! is_array($value)) { |
|
227 | 227 | $result[$key] = $value; |
228 | 228 | continue; |
229 | 229 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | if (count($args) < 3) { |
31 | 31 | $message = "Invalid link destination, too few arguments."; |
32 | - if (!Debugger::$productionMode) { |
|
32 | + if ( ! Debugger::$productionMode) { |
|
33 | 33 | throw new InvalidLinkException($message); |
34 | 34 | } |
35 | 35 | Debugger::log($message, Debugger::EXCEPTION); |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | ]; |
46 | 46 | |
47 | 47 | return $writer->write('echo ($this->filters->apiLink)((new Tomaj\NetteApi\EndpointIdentifier(' . |
48 | - $arguments['method'] . ', ' . |
|
49 | - $arguments['version'] . ', ' . |
|
48 | + $arguments['method'] . ', ' . |
|
49 | + $arguments['version'] . ', ' . |
|
50 | 50 | $arguments['package'] . ', ' . |
51 | 51 | $arguments['action'] . ')), ' . $arguments['params'] . ')'); |
52 | 52 | } |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | private function getApiList(string $version): array |
57 | 57 | { |
58 | - $versionApis = array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) { |
|
58 | + $versionApis = array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) { |
|
59 | 59 | return $version === $api->getEndpoint()->getVersion(); |
60 | 60 | }); |
61 | 61 | |
62 | - return array_map(function (Api $api) { |
|
62 | + return array_map(function(Api $api) { |
|
63 | 63 | return [ |
64 | 64 | 'method' => $api->getEndpoint()->getMethod(), |
65 | 65 | 'version' => $api->getEndpoint()->getVersion(), |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | private function createParamsList(ApiHandlerInterface $handler): array |
83 | 83 | { |
84 | - return array_map(function (InputParam $param) { |
|
84 | + return array_map(function(InputParam $param) { |
|
85 | 85 | $parameter = [ |
86 | 86 | 'type' => $param->getType(), |
87 | 87 | 'key' => $param->getKey(), |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $data = [ |
153 | 153 | 'openapi' => '3.0.0', |
154 | 154 | 'info' => [ |
155 | - 'version' => (string)$version, |
|
155 | + 'version' => (string) $version, |
|
156 | 156 | 'title' => 'Nette API', |
157 | 157 | ], |
158 | 158 | 'servers' => [ |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | 'paths' => $this->getPaths($apis, $baseUrl, $basePath), |
212 | 212 | ]; |
213 | 213 | |
214 | - if (!$securitySchemes) { |
|
214 | + if ( ! $securitySchemes) { |
|
215 | 215 | unset($data['components']['securitySchemes']); |
216 | 216 | } |
217 | 217 | |
218 | - if (!empty($this->definitions)) { |
|
218 | + if ( ! empty($this->definitions)) { |
|
219 | 219 | $data['components']['schemas'] = array_merge($this->definitions, $data['components']['schemas']); |
220 | 220 | } |
221 | 221 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | private function getApis(string $version): array |
231 | 231 | { |
232 | - return array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) { |
|
232 | + return array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) { |
|
233 | 233 | return $version === $api->getEndpoint()->getVersion(); |
234 | 234 | }); |
235 | 235 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $parameters = $this->createParamsList($handler); |
263 | 263 | $requestBody = $this->createRequestBody($handler); |
264 | 264 | |
265 | - if (!empty($parameters) || !empty($requestBody)) { |
|
265 | + if ( ! empty($parameters) || ! empty($requestBody)) { |
|
266 | 266 | $responses[IResponse::S400_BAD_REQUEST] = [ |
267 | 267 | 'description' => 'Bad request', |
268 | 268 | 'content' => [ |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | $authorization = $api->getAuthorization(); |
279 | 279 | |
280 | - if (!$authorization instanceof NoAuthorization) { |
|
280 | + if ( ! $authorization instanceof NoAuthorization) { |
|
281 | 281 | $responses[IResponse::S403_FORBIDDEN] = [ |
282 | 282 | 'description' => 'Operation forbidden', |
283 | 283 | 'content' => [ |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | foreach ($handler->outputs() as $output) { |
305 | 305 | if ($output instanceof JsonOutput) { |
306 | 306 | $schema = $this->transformSchema(json_decode($output->getSchema(), true)); |
307 | - if (!isset($responses[$output->getCode()])) { |
|
307 | + if ( ! isset($responses[$output->getCode()])) { |
|
308 | 308 | $responses[$output->getCode()] = [ |
309 | 309 | 'description' => $output->getDescription(), |
310 | 310 | 'content' => [ |
@@ -313,19 +313,19 @@ discard block |
||
313 | 313 | ], |
314 | 314 | ] |
315 | 315 | ]; |
316 | - if (!empty($examples = $output->getExamples())) { |
|
316 | + if ( ! empty($examples = $output->getExamples())) { |
|
317 | 317 | if (count($examples) === 1) { |
318 | - $example = is_array($output->getExample())? $output->getExample() : json_decode($output->getExample(), true); |
|
318 | + $example = is_array($output->getExample()) ? $output->getExample() : json_decode($output->getExample(), true); |
|
319 | 319 | $responses[$output->getCode()]['content']['application/json; charset=utf-8']['example'] = $example; |
320 | 320 | } else { |
321 | 321 | foreach ($examples as $exampleKey => $example) { |
322 | - $example = is_array($example)? $example : json_decode($example, true); |
|
322 | + $example = is_array($example) ? $example : json_decode($example, true); |
|
323 | 323 | $responses[$output->getCode()]['content']['application/json; charset=utf-8']['examples'][$exampleKey] = $example; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | } |
327 | 327 | } else { |
328 | - if (!isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) { |
|
328 | + if ( ! isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) { |
|
329 | 329 | $tmp = $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']; |
330 | 330 | unset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']); |
331 | 331 | $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema'] = [ |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | - if (!empty($parameters)) { |
|
355 | + if ( ! empty($parameters)) { |
|
356 | 356 | $settings['parameters'] = $parameters; |
357 | 357 | } |
358 | 358 | |
359 | - if (!empty($requestBody)) { |
|
359 | + if ( ! empty($requestBody)) { |
|
360 | 360 | $settings['requestBody'] = $requestBody; |
361 | 361 | } |
362 | 362 | |
@@ -487,12 +487,12 @@ discard block |
||
487 | 487 | foreach ($handler->params() as $param) { |
488 | 488 | if ($param instanceof JsonInputParam) { |
489 | 489 | $schema = json_decode($param->getSchema(), true); |
490 | - if (!empty($examples = $param->getExamples())) { |
|
490 | + if ( ! empty($examples = $param->getExamples())) { |
|
491 | 491 | if (count($examples) === 1) { |
492 | - $schema['example'] = is_array($param->getExample())? $param->getExample() : json_decode($param->getExample(), true); |
|
492 | + $schema['example'] = is_array($param->getExample()) ? $param->getExample() : json_decode($param->getExample(), true); |
|
493 | 493 | } else { |
494 | 494 | foreach ($examples as $exampleKey => $example) { |
495 | - $schema['examples'][$exampleKey] = is_array($example)? $example : json_decode($example, true); |
|
495 | + $schema['examples'][$exampleKey] = is_array($example) ? $example : json_decode($example, true); |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | $schema = [ |
511 | 511 | 'type' => 'string', |
512 | 512 | ]; |
513 | - if (!empty($examples = $param->getExamples())) { |
|
513 | + if ( ! empty($examples = $param->getExamples())) { |
|
514 | 514 | if (count($examples) === 1) { |
515 | 515 | $schema['example'] = $param->getExample(); |
516 | 516 | } else { |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | - if (!empty($requestBody['properties'])) { |
|
582 | + if ( ! empty($requestBody['properties'])) { |
|
583 | 583 | $requestBodySchema = [ |
584 | 584 | 'type' => 'object', |
585 | 585 | 'properties' => $requestBody['properties'], |