Passed
Push — master ( e25047...d6dcc5 )
by Fran
04:44
created
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.
src/base/Router.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     }
180 180
 
181 181
     /**
182
-     * @param $route
182
+     * @param string|null $route
183 183
      * @throws AccessDeniedException
184 184
      * @throws AdminCredentialsException
185 185
      * @throws RouterException
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     /**
536 536
      * @param bool $hydrateRoute
537 537
      * @param $modulePath
538
-     * @param $externalModulePath
538
+     * @param string $externalModulePath
539 539
      */
540 540
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath)
541 541
     {
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     }
551 551
 
552 552
     /**
553
-     * @param $hydrateRoute
553
+     * @param boolean $hydrateRoute
554 554
      * @param $module
555 555
      * @return mixed
556 556
      */
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function init()
77 77
     {
78
-        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE);
78
+        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE);
79 79
         if (empty($this->routing) || Config::getInstance()->getDebugMode()) {
80 80
             $this->debugLoad();
81
-        } else {
82
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE);
81
+        }else {
82
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE);
83 83
         }
84 84
         $this->checkExternalModules(false);
85 85
         $this->setLoaded();
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
         }
118 118
 
119 119
         $not_found_route = Config::getParam('route.404');
120
-        if(null !== $not_found_route) {
120
+        if (null !== $not_found_route) {
121 121
             Request::getInstance()->redirect($this->getRoute($not_found_route, true));
122
-        } else {
122
+        }else {
123 123
             return $template->render('error.html.twig', array(
124 124
                 'exception' => $e,
125 125
                 'trace' => $e->getTraceAsString(),
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
         try {
171 171
             //Search action and execute
172 172
             $this->searchAction($route);
173
-        } catch (AccessDeniedException $e) {
174
-            Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
173
+        }catch (AccessDeniedException $e) {
174
+            Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']);
175 175
             return Admin::staticAdminLogon($route);
176
-        } catch (RouterException $r) {
176
+        }catch (RouterException $r) {
177 177
             Logger::log($r->getMessage(), LOG_WARNING);
178
-        } catch (\Exception $e) {
178
+        }catch (\Exception $e) {
179 179
             Logger::log($e->getMessage(), LOG_ERR);
180 180
             throw $e;
181 181
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function searchAction($route)
194 194
     {
195
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
195
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
196 196
         //Revisamos si tenemos la ruta registrada
197 197
         $parts = parse_url($route);
198 198
         $path = array_key_exists('path', $parts) ? $parts['path'] : $route;
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
                 /** @var $class \PSFS\base\types\Controller */
208 208
                 $class = RouterHelper::getClassToCall($action);
209 209
                 try {
210
-                    if($this->checkRequirements($action, $get)) {
210
+                    if ($this->checkRequirements($action, $get)) {
211 211
                         $this->executeCachedRoute($route, $action, $class, $get);
212
-                    } else {
212
+                    }else {
213 213
                         throw new RouterException(_('La ruta no es válida'), 400);
214 214
                     }
215
-                } catch (\Exception $e) {
215
+                }catch (\Exception $e) {
216 216
                     Logger::log($e->getMessage(), LOG_ERR);
217 217
                     throw $e;
218 218
                 }
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
      * @return bool
228 228
      */
229 229
     private function checkRequirements(array $action, $params = []) {
230
-        if(!empty($params) && !empty($action['requirements'])) {
230
+        if (!empty($params) && !empty($action['requirements'])) {
231 231
             $checked = 0;
232
-            foreach(array_keys($params) as $key) {
233
-                if(in_array($key, $action['requirements'], true)) {
232
+            foreach (array_keys($params) as $key) {
233
+                if (in_array($key, $action['requirements'], true)) {
234 234
                     $checked++;
235 235
                 }
236 236
             }
237 237
             $valid = count($action['requirements']) === $checked;
238
-        } else {
238
+        }else {
239 239
             $valid = true;
240 240
         }
241 241
         return $valid;
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $this->checkExternalModules();
286 286
         if (file_exists($modulesPath)) {
287 287
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
288
-            if($modules->hasResults()) {
288
+            if ($modules->hasResults()) {
289 289
                 foreach ($modules->getIterator() as $modulePath) {
290 290
                     $module = $modulePath->getBasename();
291
-                    $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
291
+                    $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
292 292
                 }
293 293
             }
294 294
         }
295
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE);
295
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE);
296 296
     }
297 297
 
298 298
     /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             $home_params = NULL;
309 309
             foreach ($this->routing as $pattern => $params) {
310 310
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
311
-                if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) {
311
+                if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) {
312 312
                     $home_params = $params;
313 313
                 }
314 314
             }
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
     private function inspectDir($origen, $namespace = 'PSFS', $routing = [])
330 330
     {
331 331
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php');
332
-        if($files->hasResults()) {
332
+        if ($files->hasResults()) {
333 333
             foreach ($files->getIterator() as $file) {
334
-                if(method_exists($file, 'getRelativePathname') && $namespace !== 'PSFS') {
335
-                    $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
336
-                } else {
334
+                if (method_exists($file, 'getRelativePathname') && $namespace !== 'PSFS') {
335
+                    $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
336
+                }else {
337 337
                     $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname()));
338 338
                 }
339
-                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
339
+                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
340 340
             }
341 341
         }
342 342
         $this->finder = new Finder();
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     private function addRouting($namespace, &$routing, $module = 'PSFS')
366 366
     {
367 367
         if (self::exists($namespace)) {
368
-            if(I18nHelper::checkI18Class($namespace)) {
368
+            if (I18nHelper::checkI18Class($namespace)) {
369 369
                 return $routing;
370 370
             }
371 371
             $reflection = new \ReflectionClass($namespace);
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
             if (!$this->domains) {
408 408
                 $this->domains = [];
409 409
             }
410
-            $domain = '@' . $class->getConstant('DOMAIN') . '/';
410
+            $domain = '@'.$class->getConstant('DOMAIN').'/';
411 411
             if (!array_key_exists($domain, $this->domains)) {
412 412
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
413 413
             }
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
      */
424 424
     public function simpatize()
425 425
     {
426
-        $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php';
427
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
426
+        $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php';
427
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
428 428
         $this->generateSlugs($absoluteTranslationFileName);
429 429
         GeneratorHelper::createDir(CONFIG_DIR);
430
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
430
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
431 431
 
432 432
         return $this;
433 433
     }
@@ -443,18 +443,18 @@  discard block
 block discarded – undo
443 443
     public function getRoute($slug = '', $absolute = FALSE, array $params = [])
444 444
     {
445 445
         if ('' === $slug) {
446
-            return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/';
446
+            return $absolute ? Request::getInstance()->getRootUrl().'/' : '/';
447 447
         }
448 448
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
449 449
             throw new RouterException(_('No existe la ruta especificada'));
450 450
         }
451
-        $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
451
+        $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
452 452
         if (!empty($params)) {
453 453
             foreach ($params as $key => $value) {
454
-                $url = str_replace('{' . $key . '}', $value, $url);
454
+                $url = str_replace('{'.$key.'}', $value, $url);
455 455
             }
456 456
         } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
457
-            $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
457
+            $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
458 458
         }
459 459
 
460 460
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -496,17 +496,17 @@  discard block
 block discarded – undo
496 496
      */
497 497
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
498 498
     {
499
-        Logger::log('Executing route ' . $route, LOG_INFO);
499
+        Logger::log('Executing route '.$route, LOG_INFO);
500 500
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
501 501
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
502 502
         $cache = Cache::needCache();
503 503
         $execute = TRUE;
504 504
         if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) {
505 505
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
506
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName,
506
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName,
507 507
                 $cache);
508 508
             if (NULL !== $cachedData) {
509
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers',
509
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers',
510 510
                     $cache, null, Cache::JSON);
511 511
                 Template::getInstance()->renderCache($cachedData, $headers);
512 512
                 $execute = FALSE;
@@ -549,11 +549,11 @@  discard block
 block discarded – undo
549 549
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath)
550 550
     {
551 551
         $extModule = $modulePath->getBasename();
552
-        $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
553
-        if(file_exists($moduleAutoloader)) {
552
+        $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
553
+        if (file_exists($moduleAutoloader)) {
554 554
             include_once $moduleAutoloader;
555 555
             if ($hydrateRoute) {
556
-                $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
556
+                $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
557 557
             }
558 558
         }
559 559
     }
@@ -567,16 +567,16 @@  discard block
 block discarded – undo
567 567
     {
568 568
         try {
569 569
             $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
570
-            $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
571
-            if(file_exists($externalModulePath)) {
570
+            $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
571
+            if (file_exists($externalModulePath)) {
572 572
                 $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
573
-                if($externalModule->hasResults()) {
573
+                if ($externalModule->hasResults()) {
574 574
                     foreach ($externalModule->getIterator() as $modulePath) {
575 575
                         $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath);
576 576
                     }
577 577
                 }
578 578
             }
579
-        } catch (\Exception $e) {
579
+        }catch (\Exception $e) {
580 580
             Logger::log($e->getMessage(), LOG_WARNING);
581 581
             $module = null;
582 582
         }
Please login to merge, or discard this patch.