Passed
Push — master ( 926ba1...14f6bb )
by Fran
06:34 queued 03:13
created
src/services/DocumentorService.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
                     if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) {
53 53
                         $modules = [
54 54
                             'name' => $module,
55
-                            'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'),
55
+                            'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'),
56 56
                         ];
57 57
                     }
58
-                } catch (\Exception $e) {
58
+                }catch (\Exception $e) {
59 59
                     $modules[] = $e->getMessage();
60 60
                 }
61 61
             }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function extractApiEndpoints(array $module)
75 75
     {
76
-        $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api';
76
+        $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api';
77 77
         $module_name = $module['name'];
78 78
         $endpoints = [];
79 79
         if (file_exists($module_path)) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             if (count($finder)) {
83 83
                 /** @var \SplFileInfo $file */
84 84
                 foreach ($finder as $file) {
85
-                    $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename());
85
+                    $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename());
86 86
                     $info = $this->extractApiInfo($namespace, $module_name);
87 87
                     if (!empty($info)) {
88 88
                         $endpoints[$namespace] = $info;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                     if (NULL !== $mInfo) {
112 112
                         $info[] = $mInfo;
113 113
                     }
114
-                } catch (\Exception $e) {
114
+                }catch (\Exception $e) {
115 115
                     Logger::getInstance()->errorLog($e->getMessage());
116 116
                 }
117 117
             }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             $payload = $this->extractModelFields($namespace);
239 239
             $reflector = new \ReflectionClass($namespace);
240 240
             $namespace = $reflector->getShortName();
241
-        } else {
241
+        }else {
242 242
             $namespace = $model;
243 243
         }
244 244
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
329 329
                 $payload = $this->extractDtoProperties($namespace);
330 330
             }
331
-        } catch (\Exception $e) {
331
+        }catch (\Exception $e) {
332 332
             Logger::getInstance()->errorLog($e->getMessage());
333 333
         }
334 334
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
                     $return = $this->extractReturn($modelNamespace, $docComments);
360 360
                     $url = array_pop($route);
361 361
                     $methodInfo = [
362
-                        'url' => str_replace("/" . $module . "/api", '', $url),
362
+                        'url' => str_replace("/".$module."/api", '', $url),
363 363
                         'method' => $info['http'],
364 364
                         'description' => $info['label'],
365 365
                         'return' => $return,
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                     $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments);
371 371
                     $this->setQueryParams($method, $methodInfo);
372 372
                     $this->setRequestHeaders($reflection, $methodInfo);
373
-                } catch (\Exception $e) {
373
+                }catch (\Exception $e) {
374 374
                     jpre($e->getMessage());
375 375
                     Logger::getInstance()->errorLog($e->getMessage());
376 376
                 }
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
         $formatted = [
521 521
             "swagger" => "2.0",
522 522
             "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)),
523
-            "basePath" => '/' . $module['name'] . '/api',
523
+            "basePath" => '/'.$module['name'].'/api',
524 524
             "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"],
525 525
             "info" => [
526
-                "title" => _('Documentación API módulo ') . $module['name'],
526
+                "title" => _('Documentación API módulo ').$module['name'],
527 527
                 "version" => Config::getParam('api.version', '1.0'),
528 528
                 "contact" => [
529 529
                     "name" => Config::getParam("author", "Fran López"),
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         foreach ($endpoints as $model) {
537 537
             foreach ($model as $endpoint) {
538 538
                 if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) {
539
-                    $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']);
539
+                    $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']);
540 540
                     $description = $endpoint['description'];
541 541
                     $method = strtolower($endpoint['method']);
542 542
                     $paths[$url][$method] = [
@@ -571,16 +571,16 @@  discard block
 block discarded – undo
571 571
                     foreach ($endpoint['objects'] as $name => $object) {
572 572
                         if (class_exists($name)) {
573 573
                             $class = GeneratorHelper::extractClassFromNamespace($name);
574
-                            if(array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) {
574
+                            if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) {
575 575
                                 $classDefinition = [
576 576
                                     'type' => 'object',
577
-                                    '$ref' => '#/definitions/' . $class,
577
+                                    '$ref' => '#/definitions/'.$class,
578 578
                                 ];
579
-                            } else {
579
+                            }else {
580 580
                                 $classDefinition = [
581 581
                                     'type' => 'array',
582 582
                                     'items' => [
583
-                                        '$ref' => '#/definitions/' . $class,
583
+                                        '$ref' => '#/definitions/'.$class,
584 584
                                     ],
585 585
                                 ];
586 586
                             }
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
                                     'required' => true,
599 599
                                     'schema' => [
600 600
                                         'type' => 'object',
601
-                                        '$ref' => '#/definitions/' . $endpoint['payload']['type'],
601
+                                        '$ref' => '#/definitions/'.$endpoint['payload']['type'],
602 602
                                     ],
603 603
                                 ];
604 604
                             }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
     protected function extractDtoName($dto, $isArray = false)
626 626
     {
627 627
         $dto = explode('\\', $dto);
628
-        $modelDto = array_pop($dto) . "Dto";
628
+        $modelDto = array_pop($dto)."Dto";
629 629
         if ($isArray) {
630 630
             $modelDto .= "List";
631 631
         }
@@ -675,10 +675,10 @@  discard block
 block discarded – undo
675 675
     {
676 676
 
677 677
         $methodInfo['headers'] = [];
678
-        foreach($reflection->getProperties() as $property) {
678
+        foreach ($reflection->getProperties() as $property) {
679 679
             $doc = $property->getDocComment();
680 680
             preg_match('/@header\ (.*)\n/i', $doc, $headers);
681
-            if(count($headers)) {
681
+            if (count($headers)) {
682 682
                 $header = [
683 683
                     "name" => $headers[1],
684 684
                     "in" => "header",
@@ -690,13 +690,13 @@  discard block
 block discarded – undo
690 690
 
691 691
                 // Extract description
692 692
                 preg_match('/@label\ (.*)\n/i', $doc, $label);
693
-                if(count($label)) {
693
+                if (count($label)) {
694 694
                     $header['description'] = _($label[1]);
695 695
                 }
696 696
 
697 697
                 // Extract default value
698 698
                 preg_match('/@default\ (.*)\n/i', $doc, $default);
699
-                if(count($default)) {
699
+                if (count($default)) {
700 700
                     $header['default'] = $default[1];
701 701
                 }
702 702
                 $methodInfo['headers'][] = $header;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
             foreach ($method->getParameters() as $parameter) {
727 727
                 $parameterName = $parameter->getName();
728 728
                 $types = [];
729
-                preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types);
729
+                preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types);
730 730
                 if (count($types) > 1) {
731 731
                     $methodInfo['parameters'][$parameterName] = $types[1][0];
732 732
                 }
Please login to merge, or discard this patch.