Passed
Push — master ( 1a4459...3c70c1 )
by Fran
05:00
created
src/controller/GeneratorController.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
                 GeneratorHelper::checkCustomNamespaceApi($apiClass);
65 65
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
66 66
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
67
-               // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
67
+                // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
68 68
             } catch (\Exception $e) {
69 69
                 Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
70 70
                 Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage()));
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function generateModule()
36 36
     {
37
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
37
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
38 38
         /* @var $form \PSFS\base\config\ConfigForm */
39 39
         $form = new ModuleForm();
40 40
         $form->build();
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
66 66
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
67 67
                // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
68
-            } catch (\Exception $e) {
69
-                Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
68
+            }catch (\Exception $e) {
69
+                Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
70 70
                 Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage()));
71 71
             }
72 72
         }
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 
78 78
     public static function createRoot($path = WEB_DIR, OutputInterface $output = null) {
79 79
 
80
-        if(null === $output) {
80
+        if (null === $output) {
81 81
             $output = new ConsoleOutput();
82 82
         }
83 83
 
84 84
         GeneratorHelper::createDir($path);
85 85
         $paths = array("js", "css", "img", "media", "font");
86 86
         foreach ($paths as $htmlPath) {
87
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
87
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
88 88
         }
89 89
 
90 90
         // Generates the root needed files
@@ -96,18 +96,18 @@  discard block
 block discarded – undo
96 96
             'robots' => 'robots.txt',
97 97
         ];
98 98
         foreach ($files as $templates => $filename) {
99
-            $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig');
100
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
101
-                $output->writeln('Can\t create the file ' . $filename);
102
-            } else {
103
-                $output->writeln($filename . ' created successfully');
99
+            $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
100
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
101
+                $output->writeln('Can\t create the file '.$filename);
102
+            }else {
103
+                $output->writeln($filename.' created successfully');
104 104
             }
105 105
         }
106 106
 
107 107
         //Export base locale translations
108
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
109
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
110
-            GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
108
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
109
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
110
+            GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
111 111
         }
112 112
     }
113 113
 }
114 114
\ No newline at end of file
Please login to merge, or discard this patch.
src/services/DocumentorService.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 use PSFS\base\Router;
10 10
 use PSFS\base\Service;
11 11
 use PSFS\base\types\helpers\DocumentorHelper;
12
-use PSFS\base\types\helpers\GeneratorHelper;
13 12
 use PSFS\base\types\helpers\I18nHelper;
14 13
 use PSFS\base\types\helpers\InjectorHelper;
15 14
 use PSFS\base\types\helpers\RouterHelper;
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
                     if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) {
58 58
                         $modules = [
59 59
                             'name' => $module,
60
-                            'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'),
60
+                            'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'),
61 61
                         ];
62 62
                     }
63
-                } catch (\Exception $e) {
63
+                }catch (\Exception $e) {
64 64
                     $modules[] = $e->getMessage();
65 65
                 }
66 66
             }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function extractApiEndpoints(array $module)
80 80
     {
81
-        $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api';
81
+        $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api';
82 82
         $module_name = $module['name'];
83 83
         $endpoints = [];
84 84
         if (file_exists($module_path)) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             if (count($finder)) {
88 88
                 /** @var \SplFileInfo $file */
89 89
                 foreach ($finder as $file) {
90
-                    $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename());
90
+                    $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename());
91 91
                     $info = $this->extractApiInfo($namespace, $module_name);
92 92
                     if (!empty($info)) {
93 93
                         $endpoints[$namespace] = $info;
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
         if (Router::exists($namespace) && !I18nHelper::checkI18Class($namespace)) {
112 112
             $reflection = new \ReflectionClass($namespace);
113 113
             $visible = InjectorHelper::checkIsVisible($reflection->getDocComment());
114
-            if($visible) {
114
+            if ($visible) {
115 115
                 foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
116 116
                     try {
117 117
                         $mInfo = $this->extractMethodInfo($namespace, $method, $reflection, $module);
118 118
                         if (NULL !== $mInfo) {
119 119
                             $info[] = $mInfo;
120 120
                         }
121
-                    } catch (\Exception $e) {
121
+                    }catch (\Exception $e) {
122 122
                         Logger::getInstance()->errorLog($e->getMessage());
123 123
                     }
124 124
                 }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
             $payload = $this->extractModelFields($namespace);
252 252
             $reflector = new \ReflectionClass($namespace);
253 253
             $shortName = $reflector->getShortName();
254
-        } else {
254
+        }else {
255 255
             $namespace = $model;
256 256
             $shortName = $model;
257 257
         }
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
                         "required" => $field->isNotNull(),
341 341
                         'format' => $format,
342 342
                     ];
343
-                    if(count($field->getValueSet())) {
343
+                    if (count($field->getValueSet())) {
344 344
                         $info['enum'] = array_values($field->getValueSet());
345 345
                     }
346
-                    if(null !== $field->getDefaultValue()) {
346
+                    if (null !== $field->getDefaultValue()) {
347 347
                         $info['default'] = $field->getDefaultValue();
348 348
                     }
349 349
                     $payload[$field->getPhpName()] = $info;
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
352 352
                 $payload = $this->extractDtoProperties($namespace);
353 353
             }
354
-        } catch (\Exception $e) {
354
+        }catch (\Exception $e) {
355 355
             Logger::getInstance()->errorLog($e->getMessage());
356 356
         }
357 357
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
                     $return = $this->extractReturn($modelNamespace, $docComments);
383 383
                     $url = array_pop($route);
384 384
                     $methodInfo = [
385
-                        'url' => str_replace("/" . $module . "/api", '', $url),
385
+                        'url' => str_replace("/".$module."/api", '', $url),
386 386
                         'method' => $info['http'],
387 387
                         'description' => $info['label'],
388 388
                         'return' => $return,
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
                     $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments);
394 394
                     $this->setQueryParams($method, $methodInfo);
395 395
                     $this->setRequestHeaders($reflection, $methodInfo);
396
-                } catch (\Exception $e) {
396
+                }catch (\Exception $e) {
397 397
                     Logger::getInstance()->errorLog($e->getMessage());
398 398
                 }
399 399
             }
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
         $formatted = [
463 463
             "swagger" => "2.0",
464 464
             "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)),
465
-            "basePath" => '/' . $module['name'] . '/api',
465
+            "basePath" => '/'.$module['name'].'/api',
466 466
             "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"],
467 467
             "info" => [
468
-                "title" => _('Documentación API módulo ') . $module['name'],
468
+                "title" => _('Documentación API módulo ').$module['name'],
469 469
                 "version" => Config::getParam('api.version', '1.0.0'),
470 470
                 "contact" => [
471 471
                     "name" => Config::getParam("author", "Fran López"),
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         foreach ($endpoints as $model) {
479 479
             foreach ($model as $endpoint) {
480 480
                 if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) {
481
-                    $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']);
481
+                    $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']);
482 482
                     $description = $endpoint['description'];
483 483
                     $method = strtolower($endpoint['method']);
484 484
                     $paths[$url][$method] = [
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
     protected function extractDtoName($dto, $isArray = false)
540 540
     {
541 541
         $dto = explode('\\', $dto);
542
-        $modelDto = array_pop($dto) . "Dto";
542
+        $modelDto = array_pop($dto)."Dto";
543 543
         if ($isArray) {
544 544
             $modelDto .= "List";
545 545
         }
@@ -589,10 +589,10 @@  discard block
 block discarded – undo
589 589
     {
590 590
 
591 591
         $methodInfo['headers'] = [];
592
-        foreach($reflection->getProperties() as $property) {
592
+        foreach ($reflection->getProperties() as $property) {
593 593
             $doc = $property->getDocComment();
594 594
             preg_match('/@header\ (.*)\n/i', $doc, $headers);
595
-            if(count($headers)) {
595
+            if (count($headers)) {
596 596
                 $header = [
597 597
                     "name" => $headers[1],
598 598
                     "in" => "header",
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
             foreach ($method->getParameters() as $parameter) {
638 638
                 $parameterName = $parameter->getName();
639 639
                 $types = [];
640
-                preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types);
640
+                preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types);
641 641
                 if (count($types) > 1) {
642 642
                     $methodInfo['parameters'][$parameterName] = $types[1][0];
643 643
                 }
@@ -659,21 +659,21 @@  discard block
 block discarded – undo
659 659
                     $modelDto['objects'][$dtoName][$param] = [
660 660
                         'type' => 'array',
661 661
                         'items' => [
662
-                            '$ref' => '#/definitions/' . $info['type'],
662
+                            '$ref' => '#/definitions/'.$info['type'],
663 663
                         ]
664 664
                     ];
665
-                } else {
665
+                }else {
666 666
                     $modelDto['objects'][$dtoName][$param] = [
667 667
                         'type' => 'object',
668
-                        '$ref' => '#/definitions/' . $info['type'],
668
+                        '$ref' => '#/definitions/'.$info['type'],
669 669
                     ];
670 670
                 }
671 671
                 $modelDto['objects'][$info['class']] = $info['properties'];
672 672
                 $paramDto = $this->checkDtoAttributes($info['properties'], $info['properties'], $info['class']);
673
-                if(array_key_exists('objects', $paramDto)) {
673
+                if (array_key_exists('objects', $paramDto)) {
674 674
                     $modelDto['objects'] = array_merge($modelDto['objects'], $paramDto['objects']);
675 675
                 }
676
-            } else {
676
+            }else {
677 677
                 $modelDto['objects'][$dtoName][$param] = $info;
678 678
             }
679 679
         }
Please login to merge, or discard this patch.
src/base/types/helpers/InjectorHelper.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
     /**
76 76
      * Method extract if a variable is required
77
-     * @param $doc
78
-     * @return null|string
77
+     * @param string $doc
78
+     * @return boolean
79 79
      */
80 80
     public static function checkIsRequired($doc)
81 81
     {
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 
89 89
     /**
90 90
      * Method extract if a class or variable is visible
91
-     * @param $doc
92
-     * @return null|string
91
+     * @param string $doc
92
+     * @return boolean
93 93
      */
94 94
     public static function checkIsVisible($doc)
95 95
     {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     }
102 102
 
103 103
     /**
104
-     * @param $doc
104
+     * @param string $doc
105 105
      * @return null|string
106 106
      */
107 107
     public static function getLabel($doc) {
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     /**
118
-     * @param $doc
119
-     * @return null
118
+     * @param string $doc
119
+     * @return string|null
120 120
      */
121 121
     public static function getDefaultValue($doc) {
122 122
         $default = null;
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use PSFS\base\Logger;
5 5
 use PSFS\base\Router;
6
-use PSFS\services\DocumentorService;
7 6
 
8 7
 /**
9 8
  * Class InjectorHelper
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
                 $isRequired = self::checkIsRequired($property->getDocComment());
28 28
                 $label = self::getLabel($property->getDocComment());
29 29
                 $isArray = (bool)preg_match('/\[\]$/', $instanceType);
30
-                if($isArray) {
30
+                if ($isArray) {
31 31
                     $instanceType = str_replace('[]', '', $instanceType);
32 32
                 }
33
-                if($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
33
+                if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
34 34
                     list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType);
35 35
                     $variables[$property->getName()] = [
36 36
                         'type' => $type,
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
                         'required' => $isRequired,
39 39
                         'description' => $label,
40 40
                     ];
41
-                } else {
41
+                }else {
42 42
                     $instance = new \ReflectionClass($instanceType);
43 43
                     $variables[$property->getName()] = [
44 44
                         'is_array' => $isArray,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         // Extract description
125 125
         $label = null;
126 126
         preg_match('/@label\ (.*)\n/i', $doc, $matches);
127
-        if(count($matches)) {
127
+        if (count($matches)) {
128 128
             $label = _($matches[1]);
129 129
         }
130 130
         return $label;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     public static function getDefaultValue($doc) {
138 138
         $default = null;
139 139
         preg_match('/@default\ (.*)\n/i', $doc, $matches);
140
-        if(count($matches)) {
140
+        if (count($matches)) {
141 141
             $default = $matches[1];
142 142
         }
143 143
         return $default;
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)
154 154
     {
155
-        Logger::log('Create inyectable instance for ' . $classNameSpace);
155
+        Logger::log('Create inyectable instance for '.$classNameSpace);
156 156
         $reflector = new \ReflectionClass($calledClass);
157 157
         $property = $reflector->getProperty($variable);
158 158
         $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace;
159 159
         if (true === $singleton && method_exists($varInstanceType, 'getInstance')) {
160 160
             $instance = $varInstanceType::getInstance();
161
-        } else {
161
+        }else {
162 162
             $instance = new $varInstanceType();
163 163
         }
164 164
         return $instance;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     public static function getClassProperties($class)
173 173
     {
174 174
         $properties = [];
175
-        Logger::log('Extracting annotations properties from class ' . $class);
175
+        Logger::log('Extracting annotations properties from class '.$class);
176 176
         $selfReflector = new \ReflectionClass($class);
177 177
         if (false !== $selfReflector->getParentClass()) {
178 178
             $properties = self::getClassProperties($selfReflector->getParentClass()->getName());
Please login to merge, or discard this patch.
src/base/types/helpers/DocumentorHelper.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param $object
48 48
      * @param $paths
49 49
      * @param $url
50
-     * @param $method
50
+     * @param string $method
51 51
      * @param $dtos
52 52
      * @param $isReturn
53 53
      * @return array
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * Translator from php types to swagger types
88 88
      * @param string $format
89 89
      *
90
-     * @return array
90
+     * @return string[]
91 91
      */
92 92
     public static function translateSwaggerFormats($format)
93 93
     {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
      */
15 15
     private static function searchPayloadParam($params, $variable) {
16 16
         $exists = false;
17
-        if(null !== $params && count($params)) {
18
-            foreach($params as $param) {
19
-                if($param['name'] === $variable) {
17
+        if (null !== $params && count($params)) {
18
+            foreach ($params as $param) {
19
+                if ($param['name'] === $variable) {
20 20
                     $exists = true;
21 21
                     break;
22 22
                 }
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
         ];
41 41
         if ($endpoint['payload']['is_array']) {
42 42
             $schema['items'] = [
43
-                '$ref' => '#/definitions/' . $endpoint['payload']['type'],
43
+                '$ref' => '#/definitions/'.$endpoint['payload']['type'],
44 44
             ];
45
-        } else {
46
-            $schema['$ref'] = '#/definitions/' . $endpoint['payload']['type'];
45
+        }else {
46
+            $schema['$ref'] = '#/definitions/'.$endpoint['payload']['type'];
47 47
         }
48
-        if(!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) {
48
+        if (!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) {
49 49
             $paths[$url][$method]['parameters'][] = [
50 50
                 'in' => 'body',
51 51
                 'name' => $endpoint['payload']['type'],
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
             if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) {
75 75
                 $classDefinition = [
76 76
                     'type' => 'object',
77
-                    '$ref' => '#/definitions/' . $class,
77
+                    '$ref' => '#/definitions/'.$class,
78 78
                 ];
79
-            } else {
79
+            }else {
80 80
                 $classDefinition = [
81 81
                     'type' => 'array',
82 82
                     'items' => [
83
-                        '$ref' => '#/definitions/' . $class,
83
+                        '$ref' => '#/definitions/'.$class,
84 84
                     ],
85 85
                 ];
86 86
             }
87 87
 
88
-            if($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') {
88
+            if ($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') {
89 89
                 $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition;
90 90
             }
91 91
             $dtos += self::extractSwaggerDefinition($class, $object);
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
             ],
164 164
         ];
165 165
         foreach ($fields as $field => $info) {
166
-            if(array_key_exists('type', $info) || in_array($info['type'], ['array', 'object'])) {
166
+            if (array_key_exists('type', $info) || in_array($info['type'], ['array', 'object'])) {
167 167
                 $definition[$name]['properties'][$field] = $info;
168
-            } else {
168
+            }else {
169 169
                 list($type, $format) = self::translateSwaggerFormats($info['type']);
170 170
                 $fieldData = [
171 171
                     "type" => $type,
172 172
                     "required" => $info['required'],
173 173
                 ];
174
-                if(array_key_exists('description', $info)) {
174
+                if (array_key_exists('description', $info)) {
175 175
                     $fieldData['description'] = $info['description'];
176 176
                 }
177
-                if(array_key_exists('format', $info)) {
177
+                if (array_key_exists('format', $info)) {
178 178
                     $fieldData['format'] = $info['format'];
179 179
                 }
180 180
                 $dto['properties'][$field] = $fieldData;
Please login to merge, or discard this patch.
src/Dispatcher.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,18 +73,18 @@
 block discarded – undo
73 73
                 if (!Request::getInstance()->isFile()) {
74 74
                     return $this->router->execute($this->actualUri);
75 75
                 }
76
-            } else {
76
+            }else {
77 77
                 return ConfigController::getInstance()->config();
78 78
             }
79
-        } catch (AdminCredentialsException $a) {
79
+        }catch (AdminCredentialsException $a) {
80 80
             return UserController::showAdminManager();
81
-        } catch (SecurityException $s) {
81
+        }catch (SecurityException $s) {
82 82
             return $this->security->notAuthorized($this->actualUri);
83
-        } catch (RouterException $r) {
83
+        }catch (RouterException $r) {
84 84
             return $this->router->httpNotFound($r);
85
-        } catch(ApiException $a) {
85
+        }catch (ApiException $a) {
86 86
             return $this->router->httpNotFound($a, true);
87
-        } catch (\Exception $e) {
87
+        }catch (\Exception $e) {
88 88
             return $this->dumpException($e);
89 89
         }
90 90
     }
Please login to merge, or discard this patch.
src/base/dto/Dto.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public function __construct($hydrate = true)
19 19
     {
20 20
         parent::__construct();
21
-        if($hydrate) {
21
+        if ($hydrate) {
22 22
             $this->fromArray(Request::getInstance()->getData());
23 23
         }
24 24
     }
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
                 /** @var \ReflectionProperty $property */
47 47
                 foreach ($properties as $property) {
48 48
                     $value = $property->getValue($this);
49
-                    if(is_object($value) && method_exists($value, 'toArray')) {
49
+                    if (is_object($value) && method_exists($value, 'toArray')) {
50 50
                         $dto[$property->getName()] = $value->toArray();
51
-                    } else {
51
+                    }else {
52 52
                         $dto[$property->getName()] = $property->getValue($this);
53 53
                     }
54 54
                 }
55 55
             }
56
-        } catch (\Exception $e) {
57
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
56
+        }catch (\Exception $e) {
57
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
58 58
         }
59 59
         return $dto;
60 60
     }
@@ -76,32 +76,32 @@  discard block
 block discarded – undo
76 76
     protected function parseDtoField(array $properties, $key, $value = null) {
77 77
         $type = 'string';
78 78
         $is_array = false;
79
-        if(array_key_exists($key, $properties)) {
79
+        if (array_key_exists($key, $properties)) {
80 80
             $type = $properties[$key];
81
-            if(preg_match('/(\[\]|Array)/i', $type)) {
81
+            if (preg_match('/(\[\]|Array)/i', $type)) {
82 82
                 $type = preg_replace('/(\[\]|Array)/i', '', $type);
83 83
                 $is_array = true;
84 84
             }
85 85
         }
86 86
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
87
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
88
-            if(null !== $value && is_array($value)) {
89
-                if($is_array) {
87
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
88
+            if (null !== $value && is_array($value)) {
89
+                if ($is_array) {
90 90
                     $this->$key = [];
91
-                    foreach($value as $data) {
92
-                        if(null !== $data && is_array($data)) {
91
+                    foreach ($value as $data) {
92
+                        if (null !== $data && is_array($data)) {
93 93
                             $dto = new $type(false);
94 94
                             $dto->fromArray($data);
95 95
                             array_push($this->$key, $dto);
96 96
                         }
97 97
                     }
98
-                } else {
98
+                }else {
99 99
                     $this->$key = new $type(false);
100 100
                     $this->$key->fromArray($value);
101 101
                 }
102 102
             }
103
-        } else {
104
-            switch($type) {
103
+        }else {
104
+            switch ($type) {
105 105
                 default:
106 106
                 case 'string':
107 107
                     $this->$key = $value;
Please login to merge, or discard this patch.
src/base/types/helpers/SecurityHelper.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         if (!Config::getInstance()->checkTryToSaveConfig()
30 30
             && (preg_match('/^\/(admin|setup\-admin)/i', $route) || Config::getParam('restricted', false))
31 31
         ) {
32
-            if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) {
32
+            if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) {
33 33
                 throw new AdminCredentialsException();
34 34
             }
35 35
             if (!Security::getInstance()->checkAdmin()) {
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
         $token = '';
50 50
         $ct = strlen($ts);
51 51
         for ($i = 0; $i < $ct; $i++) {
52
-            $token = substr($hash, $i, 1) .
53
-                    substr($ts, $i, 1) .
52
+            $token = substr($hash, $i, 1).
53
+                    substr($ts, $i, 1).
54 54
                     $token;
55 55
         }
56 56
         return $token;
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
         $charsLength = strlen(self::RAND_SEP) - 1;
69 69
         $tsLength = strlen($ts);
70 70
         $i = 0;
71
-        $ct = ceil($hashRest / 4);
72
-        $part = substr($hash, $tsLength + $ct * $i, $ct);
73
-        while(false !== $part) {
74
-            $mixedToken .= $part .
75
-                substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) .
71
+        $ct = ceil($hashRest/4);
72
+        $part = substr($hash, $tsLength + $ct*$i, $ct);
73
+        while (false !== $part) {
74
+            $mixedToken .= $part.
75
+                substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1).
76 76
                 substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1);
77
-            $part = substr($hash, $tsLength + $ct * $i, $ct);
77
+            $part = substr($hash, $tsLength + $ct*$i, $ct);
78 78
             $i++;
79 79
         }
80
-        return $mixedToken . $token;
80
+        return $mixedToken.$token;
81 81
     }
82 82
 
83 83
     /**
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private static function getTs($isOdd = null) {
88 88
         $ts = time();
89
-        $tsIsOdd = (bool)((int)substr($ts, -1) % 2);
90
-        if(false === $isOdd && !$tsIsOdd) {
89
+        $tsIsOdd = (bool)((int)substr($ts, -1)%2);
90
+        if (false === $isOdd && !$tsIsOdd) {
91 91
             $ts--;
92
-        } elseif(true === $isOdd && !$tsIsOdd) {
92
+        } elseif (true === $isOdd && !$tsIsOdd) {
93 93
             $ts--;
94 94
         }
95 95
         return $ts;
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
         $partToken = '';
122 122
         $ts = '';
123 123
         $part = strrev($part);
124
-        for($i = 0, $ct = strlen($part); $i < $ct; $i++) {
125
-            if($i % 2 == 0) {
124
+        for ($i = 0, $ct = strlen($part); $i < $ct; $i++) {
125
+            if ($i%2 == 0) {
126 126
                 $ts .= substr($part, $i, 1);
127
-            } else {
127
+            }else {
128 128
                 $partToken .= substr($part, $i, 1);
129 129
             }
130 130
         }
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
     private static function parseTokenParts(array $parts) {
140 140
         $token = '';
141 141
         list($partToken, $ts) = self::extractTs(array_pop($parts));
142
-        if($ts > 0) {
143
-            foreach($parts as $part) {
142
+        if ($ts > 0) {
143
+            foreach ($parts as $part) {
144 144
                 $token .= $part;
145 145
             }
146
-            $token = $partToken . $token;
146
+            $token = $partToken.$token;
147 147
         }
148 148
         return [$token, $ts];
149 149
     }
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
      * @return array
172 172
      */
173 173
     private static function extractTokenParts($token) {
174
-        for($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) {
175
-            $token = str_replace(substr(self::RAND_SEP,$i,1), "|", $token);
174
+        for ($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) {
175
+            $token = str_replace(substr(self::RAND_SEP, $i, 1), "|", $token);
176 176
         }
177 177
         return array_unique(explode('||', $token));
178 178
     }
Please login to merge, or discard this patch.
src/base/Request.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
     /**
51 51
      * Método que verifica si existe una cabecera concreta
52
-     * @param $header
52
+     * @param string $header
53 53
      *
54 54
      * @return boolean
55 55
      */
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @param string $queryParams
176 176
      *
177
-     * @return mixed
177
+     * @return string
178 178
      */
179 179
     public function getQuery($queryParams)
180 180
     {
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
     /**
236 236
      * Devuelve un parámetro de $_SERVER
237 237
      * @param string $param
238
-     * @param $default
238
+     * @param string $default
239 239
      * @return string|null
240 240
      */
241 241
     public function getServer($param, $default = null)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public static function header($name, $default = null)
147 147
     {
148
-        return self::getInstance()->getHeader($name,  $default);
148
+        return self::getInstance()->getHeader($name, $default);
149 149
     }
150 150
 
151 151
     /**
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
         $header = null;
159 159
         if ($this->hasHeader($name)) {
160 160
             $header = $this->header[$name];
161
-        } else if(array_key_exists('h_' . strtolower($name), $this->query)) {
162
-            $header = $this->query['h_' . strtolower($name)];
163
-        } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
-            $header = $this->server['HTTP_' . strtoupper(str_replace('-', '_', $name))];
161
+        }else if (array_key_exists('h_'.strtolower($name), $this->query)) {
162
+            $header = $this->query['h_'.strtolower($name)];
163
+        }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
+            $header = $this->server['HTTP_'.strtoupper(str_replace('-', '_', $name))];
165 165
         }
166 166
         return $header ?: $default;
167 167
     }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     {
259 259
         if (null === $url) $url = $this->getServer('HTTP_ORIGIN');
260 260
         ob_start();
261
-        header('Location: ' . $url);
261
+        header('Location: '.$url);
262 262
         ob_end_clean();
263 263
         Security::getInstance()->updateSession();
264 264
         exit(_('Redireccionando...'));
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
     {
303 303
         $url = $this->getServerName();
304 304
         $protocol = $protocol ? $this->getProtocol() : '';
305
-        if (!empty($protocol)) $url = $protocol . $url;
305
+        if (!empty($protocol)) $url = $protocol.$url;
306 306
         if (!in_array($this->getServer('SERVER_PORT'), [80, 443], true)) {
307
-            $url .= ':' . $this->getServer('SERVER_PORT');
307
+            $url .= ':'.$this->getServer('SERVER_PORT');
308 308
         }
309 309
         return $url;
310 310
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,7 +256,9 @@  discard block
 block discarded – undo
256 256
      */
257 257
     public function redirect($url = null)
258 258
     {
259
-        if (null === $url) $url = $this->getServer('HTTP_ORIGIN');
259
+        if (null === $url) {
260
+            $url = $this->getServer('HTTP_ORIGIN');
261
+        }
260 262
         ob_start();
261 263
         header('Location: ' . $url);
262 264
         ob_end_clean();
@@ -302,7 +304,9 @@  discard block
 block discarded – undo
302 304
     {
303 305
         $url = $this->getServerName();
304 306
         $protocol = $protocol ? $this->getProtocol() : '';
305
-        if (!empty($protocol)) $url = $protocol . $url;
307
+        if (!empty($protocol)) {
308
+            $url = $protocol . $url;
309
+        }
306 310
         if (!in_array($this->getServer('SERVER_PORT'), [80, 443], true)) {
307 311
             $url .= ':' . $this->getServer('SERVER_PORT');
308 312
         }
Please login to merge, or discard this patch.
src/base/Cache.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@
 block discarded – undo
188 188
     }
189 189
 
190 190
     /**
191
-     * @return integer|boolean
191
+     * @return integer
192 192
      */
193 193
     public static function needCache()
194 194
     {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         GeneratorHelper::createDir(dirname($path));
56 56
         if (false === FileHelper::writeFile($path, $data)) {
57
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
57
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
58 58
         }
59 59
     }
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]);
70 70
         $data = null;
71
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
71
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
72 72
         if (file_exists($absolutePath)) {
73 73
             $data = FileHelper::readFile($absolutePath);
74 74
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
85 85
     {
86 86
         Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]);
87
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
87
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
88 88
         $lasModificationDate = filemtime($absolutePath);
89 89
         return ($lasModificationDate + $expires <= time());
90 90
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]);
153 153
         $data = self::transformData($data, $transform);
154
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
154
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
155 155
         $this->saveTextToFile($data, $absolutePath);
156 156
     }
157 157
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $data = null;
170 170
         Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]);
171
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
172 172
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
173 173
                 $data = $function();
174 174
                 $this->storeData($path, $data, $transform, false, $expires);
175
-            } else {
175
+            }else {
176 176
                 $data = $this->getDataFromFile($path, $transform);
177 177
             }
178 178
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     public function flushCache() {
227
-        if(Config::getParam('cache.data.enable', false)) {
227
+        if (Config::getParam('cache.data.enable', false)) {
228 228
             Logger::log('Flushing cache', LOG_DEBUG);
229 229
             $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR);
230
-            if(is_array($action)) {
231
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
232
-                if(!file_exists($hashPath)) {
233
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
230
+            if (is_array($action)) {
231
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
232
+                if (!file_exists($hashPath)) {
233
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
234 234
                 }
235 235
                 FileHelper::deleteDir($hashPath);
236 236
             }
Please login to merge, or discard this patch.