Completed
Push — master ( 5f2a30...053cf7 )
by Michal
13:42
created
src/Handlers/OpenApiHandler.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
277 277
 
278 278
             $authorization = $api->getAuthorization();
279 279
 
280
-            if (!$authorization instanceof NoAuthorization) {
280
+            if ( ! $authorization instanceof NoAuthorization) {
281 281
                 $responses[IResponse::S401_Unauthorized] = [
282 282
                     'description' => 'Operation forbidden',
283 283
                     'content' => [
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'],
Please login to merge, or discard this patch.