Passed
Push — master ( f697cc...d7bbf2 )
by Fran
03:27
created
src/services/DocumentorService.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
                     if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) {
56 56
                         $modules = [
57 57
                             'name' => $module,
58
-                            'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'),
58
+                            'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'),
59 59
                         ];
60 60
                     }
61
-                } catch (\Exception $e) {
61
+                }catch (\Exception $e) {
62 62
                     $modules[] = $e->getMessage();
63 63
                 }
64 64
             }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function extractApiEndpoints(array $module)
78 78
     {
79
-        $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api';
79
+        $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api';
80 80
         $module_name = $module['name'];
81 81
         $endpoints = [];
82 82
         if (file_exists($module_path)) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             if (count($finder)) {
86 86
                 /** @var \SplFileInfo $file */
87 87
                 foreach ($finder as $file) {
88
-                    $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename());
88
+                    $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename());
89 89
                     $info = $this->extractApiInfo($namespace, $module_name);
90 90
                     if (!empty($info)) {
91 91
                         $endpoints[$namespace] = $info;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                     if (NULL !== $mInfo) {
115 115
                         $info[] = $mInfo;
116 116
                     }
117
-                } catch (\Exception $e) {
117
+                }catch (\Exception $e) {
118 118
                     Logger::getInstance()->errorLog($e->getMessage());
119 119
                 }
120 120
             }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             $payload = $this->extractModelFields($namespace);
242 242
             $reflector = new \ReflectionClass($namespace);
243 243
             $namespace = $reflector->getShortName();
244
-        } else {
244
+        }else {
245 245
             $namespace = $model;
246 246
         }
247 247
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
             } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
334 334
                 $payload = $this->extractDtoProperties($namespace);
335 335
             }
336
-        } catch (\Exception $e) {
336
+        }catch (\Exception $e) {
337 337
             Logger::getInstance()->errorLog($e->getMessage());
338 338
         }
339 339
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                     $return = $this->extractReturn($modelNamespace, $docComments);
365 365
                     $url = array_pop($route);
366 366
                     $methodInfo = [
367
-                        'url' => str_replace("/" . $module . "/api", '', $url),
367
+                        'url' => str_replace("/".$module."/api", '', $url),
368 368
                         'method' => $info['http'],
369 369
                         'description' => $info['label'],
370 370
                         'return' => $return,
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                     $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments);
376 376
                     $this->setQueryParams($method, $methodInfo);
377 377
                     $this->setRequestHeaders($reflection, $methodInfo);
378
-                } catch (\Exception $e) {
378
+                }catch (\Exception $e) {
379 379
                     Logger::getInstance()->errorLog($e->getMessage());
380 380
                 }
381 381
             }
@@ -524,10 +524,10 @@  discard block
 block discarded – undo
524 524
         $formatted = [
525 525
             "swagger" => "2.0",
526 526
             "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)),
527
-            "basePath" => '/' . $module['name'] . '/api',
527
+            "basePath" => '/'.$module['name'].'/api',
528 528
             "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"],
529 529
             "info" => [
530
-                "title" => _('Documentación API módulo ') . $module['name'],
530
+                "title" => _('Documentación API módulo ').$module['name'],
531 531
                 "version" => Config::getParam('api.version', '1.0'),
532 532
                 "contact" => [
533 533
                     "name" => Config::getParam("author", "Fran López"),
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
         foreach ($endpoints as $model) {
541 541
             foreach ($model as $endpoint) {
542 542
                 if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) {
543
-                    $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']);
543
+                    $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']);
544 544
                     $description = $endpoint['description'];
545 545
                     $method = strtolower($endpoint['method']);
546 546
                     $paths[$url][$method] = [
@@ -575,16 +575,16 @@  discard block
 block discarded – undo
575 575
                     foreach ($endpoint['objects'] as $name => $object) {
576 576
                         if (class_exists($name)) {
577 577
                             $class = GeneratorHelper::extractClassFromNamespace($name);
578
-                            if(array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) {
578
+                            if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) {
579 579
                                 $classDefinition = [
580 580
                                     'type' => 'object',
581
-                                    '$ref' => '#/definitions/' . $class,
581
+                                    '$ref' => '#/definitions/'.$class,
582 582
                                 ];
583
-                            } else {
583
+                            }else {
584 584
                                 $classDefinition = [
585 585
                                     'type' => 'array',
586 586
                                     'items' => [
587
-                                        '$ref' => '#/definitions/' . $class,
587
+                                        '$ref' => '#/definitions/'.$class,
588 588
                                     ],
589 589
                                 ];
590 590
                             }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
                                     'required' => true,
603 603
                                     'schema' => [
604 604
                                         'type' => 'object',
605
-                                        '$ref' => '#/definitions/' . $endpoint['payload']['type'],
605
+                                        '$ref' => '#/definitions/'.$endpoint['payload']['type'],
606 606
                                     ],
607 607
                                 ];
608 608
                             }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
     protected function extractDtoName($dto, $isArray = false)
630 630
     {
631 631
         $dto = explode('\\', $dto);
632
-        $modelDto = array_pop($dto) . "Dto";
632
+        $modelDto = array_pop($dto)."Dto";
633 633
         if ($isArray) {
634 634
             $modelDto .= "List";
635 635
         }
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
     {
680 680
 
681 681
         $methodInfo['headers'] = [];
682
-        foreach($reflection->getProperties() as $property) {
682
+        foreach ($reflection->getProperties() as $property) {
683 683
             $doc = $property->getDocComment();
684 684
             preg_match('/@header\ (.*)\n/i', $doc, $headers);
685
-            if(count($headers)) {
685
+            if (count($headers)) {
686 686
                 $header = [
687 687
                     "name" => $headers[1],
688 688
                     "in" => "header",
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 
695 695
                 // Extract description
696 696
                 preg_match('/@label\ (.*)\n/i', $doc, $label);
697
-                if(count($label)) {
697
+                if (count($label)) {
698 698
                     $header['description'] = _($label[1]);
699 699
                 }
700 700
 
701 701
                 // Extract default value
702 702
                 preg_match('/@default\ (.*)\n/i', $doc, $default);
703
-                if(count($default)) {
703
+                if (count($default)) {
704 704
                     $header['default'] = $default[1];
705 705
                 }
706 706
                 $methodInfo['headers'][] = $header;
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
             foreach ($method->getParameters() as $parameter) {
731 731
                 $parameterName = $parameter->getName();
732 732
                 $types = [];
733
-                preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types);
733
+                preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types);
734 734
                 if (count($types) > 1) {
735 735
                     $methodInfo['parameters'][$parameterName] = $types[1][0];
736 736
                 }
Please login to merge, or discard this patch.