| @@ -41,10 +41,10 @@ discard block | ||
| 41 | 41 |                      if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) { | 
| 42 | 42 | $modules = [ | 
| 43 | 43 | 'name' => $module, | 
| 44 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), | |
| 44 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), | |
| 45 | 45 | ]; | 
| 46 | 46 | } | 
| 47 | -                } catch (\Exception $e) { | |
| 47 | +                }catch (\Exception $e) { | |
| 48 | 48 | $modules[] = $e->getMessage(); | 
| 49 | 49 | } | 
| 50 | 50 | } | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 | */ | 
| 63 | 63 | public function extractApiEndpoints(array $module) | 
| 64 | 64 |      { | 
| 65 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; | |
| 65 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; | |
| 66 | 66 | $module_name = $module['name']; | 
| 67 | 67 | $endpoints = []; | 
| 68 | 68 |          if (file_exists($module_path)) { | 
| @@ -71,7 +71,7 @@ discard block | ||
| 71 | 71 |              if (count($finder)) { | 
| 72 | 72 | /** @var \SplFileInfo $file */ | 
| 73 | 73 |                  foreach ($finder as $file) { | 
| 74 | -                    $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); | |
| 74 | +                    $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); | |
| 75 | 75 | $info = $this->extractApiInfo($namespace, $module_name); | 
| 76 | 76 |                      if (!empty($info)) { | 
| 77 | 77 | $endpoints[$namespace] = $info; | 
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 |                      if (NULL !== $mInfo) { | 
| 101 | 101 | $info[] = $mInfo; | 
| 102 | 102 | } | 
| 103 | -                } catch (\Exception $e) { | |
| 103 | +                }catch (\Exception $e) { | |
| 104 | 104 | Logger::getInstance()->errorLog($e->getMessage()); | 
| 105 | 105 | } | 
| 106 | 106 | } | 
| @@ -312,7 +312,7 @@ discard block | ||
| 312 | 312 |              } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { | 
| 313 | 313 | $payload = $this->extractDtoProperties($namespace); | 
| 314 | 314 | } | 
| 315 | -        } catch (\Exception $e) { | |
| 315 | +        }catch (\Exception $e) { | |
| 316 | 316 | Logger::getInstance()->errorLog($e->getMessage()); | 
| 317 | 317 | } | 
| 318 | 318 | |
| @@ -351,18 +351,18 @@ discard block | ||
| 351 | 351 | unset($methodInfo['return']['objects']); | 
| 352 | 352 |                      if (in_array($methodInfo['method'], ['POST', 'PUT'])) { | 
| 353 | 353 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); | 
| 354 | -                    } elseif($method->getNumberOfParameters() > 0) { | |
| 354 | +                    } elseif ($method->getNumberOfParameters() > 0) { | |
| 355 | 355 | $methodInfo['parameters'] = []; | 
| 356 | -                        foreach($method->getParameters() as $parameter) { | |
| 356 | +                        foreach ($method->getParameters() as $parameter) { | |
| 357 | 357 | $parameterName = $parameter->getName(); | 
| 358 | 358 | $types = []; | 
| 359 | 359 |                              preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); | 
| 360 | -                            if(count($types) > 1) { | |
| 360 | +                            if (count($types) > 1) { | |
| 361 | 361 | $methodInfo['parameters'][$parameterName] = $types[1][0]; | 
| 362 | 362 | } | 
| 363 | 363 | } | 
| 364 | 364 | } | 
| 365 | -                } catch (\Exception $e) { | |
| 365 | +                }catch (\Exception $e) { | |
| 366 | 366 | jpre($e->getMessage()); | 
| 367 | 367 | Logger::getInstance()->errorLog($e->getMessage()); | 
| 368 | 368 | } | 
| @@ -444,13 +444,13 @@ discard block | ||
| 444 | 444 | ]]); | 
| 445 | 445 |                  if (array_key_exists($subDtoName, $subDto)) { | 
| 446 | 446 | $definitions = $subDto; | 
| 447 | -                } else { | |
| 447 | +                }else { | |
| 448 | 448 | $definitions[$subDtoName] = $subDto; | 
| 449 | 449 | } | 
| 450 | 450 | $definition[$name]['properties'][$field] = [ | 
| 451 | - '$ref' => "#/definitions/" . $subDtoName, | |
| 451 | + '$ref' => "#/definitions/".$subDtoName, | |
| 452 | 452 | ]; | 
| 453 | -            } else { | |
| 453 | +            }else { | |
| 454 | 454 | list($type, $format) = self::translateSwaggerFormats($format); | 
| 455 | 455 | $dto['properties'][$field] = [ | 
| 456 | 456 | "type" => $type, | 
| @@ -472,8 +472,8 @@ discard block | ||
| 472 | 472 |      private static function swaggerResponses() { | 
| 473 | 473 | $codes = [200, 400, 404, 500]; | 
| 474 | 474 | $responses = []; | 
| 475 | -        foreach($codes as $code) { | |
| 476 | -            switch($code) { | |
| 475 | +        foreach ($codes as $code) { | |
| 476 | +            switch ($code) { | |
| 477 | 477 | default: | 
| 478 | 478 | case 200: | 
| 479 | 479 |                      $message = _('Successful response'); | 
| @@ -524,9 +524,9 @@ discard block | ||
| 524 | 524 |      { | 
| 525 | 525 | $formatted = [ | 
| 526 | 526 | "swagger" => "2.0", | 
| 527 | -            "host" => Router::getInstance()->getRoute('', true) . $module['name'] . '/api', | |
| 527 | +            "host" => Router::getInstance()->getRoute('', true).$module['name'].'/api', | |
| 528 | 528 | "info" => [ | 
| 529 | -                "title" => _('Documentación API módulo ') . $module['name'], | |
| 529 | +                "title" => _('Documentación API módulo ').$module['name'], | |
| 530 | 530 |                  "version" => Config::getParam('api.version', '1.0'), | 
| 531 | 531 | "contact" => [ | 
| 532 | 532 |                      "name" => Config::getParam("author", "Fran López"), | 
| @@ -538,7 +538,7 @@ discard block | ||
| 538 | 538 | $endpoints = DocumentorService::getInstance()->extractApiEndpoints($module); | 
| 539 | 539 |          foreach ($endpoints as $model) { | 
| 540 | 540 |              foreach ($model as $endpoint) { | 
| 541 | -                if(!preg_match('/^\/admin\//i', $endpoint['url']) && strlen($endpoint['url'])) { | |
| 541 | +                if (!preg_match('/^\/admin\//i', $endpoint['url']) && strlen($endpoint['url'])) { | |
| 542 | 542 |                      $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); | 
| 543 | 543 | $description = $endpoint['description']; | 
| 544 | 544 | $method = strtolower($endpoint['method']); | 
| @@ -549,8 +549,8 @@ discard block | ||
| 549 | 549 | 'responses' => self::swaggerResponses(), | 
| 550 | 550 | 'parameters' => [], | 
| 551 | 551 | ]; | 
| 552 | -                    if(array_key_exists('parameters', $endpoint)) { | |
| 553 | -                        foreach($endpoint['parameters'] as $parameter => $type) { | |
| 552 | +                    if (array_key_exists('parameters', $endpoint)) { | |
| 553 | +                        foreach ($endpoint['parameters'] as $parameter => $type) { | |
| 554 | 554 | list($type, $format) = self::translateSwaggerFormats($type); | 
| 555 | 555 | $paths[$url][$method]['parameters'][] = [ | 
| 556 | 556 | 'in' => 'path', | 
| @@ -562,19 +562,19 @@ discard block | ||
| 562 | 562 | } | 
| 563 | 563 | |
| 564 | 564 | } | 
| 565 | -                    foreach($endpoint['objects'] as $name => $object) { | |
| 566 | -                        if(class_exists($name)) { | |
| 565 | +                    foreach ($endpoint['objects'] as $name => $object) { | |
| 566 | +                        if (class_exists($name)) { | |
| 567 | 567 | $class = GeneratorHelper::extractClassFromNamespace($name); | 
| 568 | 568 | $classDefinition = [ | 
| 569 | 569 | 'type' => 'object', | 
| 570 | - '$ref' => '#/definitions/' . $class, | |
| 570 | + '$ref' => '#/definitions/'.$class, | |
| 571 | 571 | ]; | 
| 572 | 572 | $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition; | 
| 573 | 573 | $dtos += self::extractSwaggerDefinition($class, $object); | 
| 574 | -                            if(!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { | |
| 574 | +                            if (!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { | |
| 575 | 575 | $paths[$url][$method]['tags'][] = $class; | 
| 576 | 576 | } | 
| 577 | -                            if(array_key_exists('payload', $endpoint)) { | |
| 577 | +                            if (array_key_exists('payload', $endpoint)) { | |
| 578 | 578 | $paths[$url][$method]['parameters'][] = [ | 
| 579 | 579 | 'in' => 'body', | 
| 580 | 580 | 'name' => $class, | 
| @@ -602,7 +602,7 @@ discard block | ||
| 602 | 602 | protected function extractDtoName($dto, $isArray = false) | 
| 603 | 603 |      { | 
| 604 | 604 |          $dto = explode('\\', $dto); | 
| 605 | - $modelDto = array_pop($dto) . "Dto"; | |
| 605 | + $modelDto = array_pop($dto)."Dto"; | |
| 606 | 606 |          if ($isArray) { | 
| 607 | 607 | $modelDto .= "List"; | 
| 608 | 608 | } |