Passed
Push — master ( 1dadf3...61c4e2 )
by Fran
03:43
created
src/base/Cache.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace PSFS\base;
3 3
 
4
-use PSFS\base\config\Config;
5 4
 use PSFS\base\exception\ConfigException;
6 5
 use PSFS\base\types\helpers\GeneratorHelper;
7
-use PSFS\base\types\helpers\RequestHelper;
8 6
 use PSFS\base\types\SingletonTrait;
9 7
 
10 8
 /**
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     private function saveTextToFile($data, $path, $absolute = false)
33 33
     {
34
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
34
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
35 35
         $filename = basename($absolutePath);
36 36
         GeneratorHelper::createDir(str_replace($filename, "", $absolutePath));
37 37
         if (false === file_put_contents($absolutePath, $data)) {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
51 51
     {
52 52
         $data = null;
53
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
53
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
54 54
         if (file_exists($absolutePath)) {
55 55
             $data = file_get_contents($absolutePath);
56 56
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
68 68
     {
69
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
69
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
70 70
         $lasModificationDate = filemtime($absolutePath);
71 71
         return ($lasModificationDate + $expires <= time());
72 72
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 break;
90 90
             case Cache::GZIP:
91 91
                 // TODO implementar
92
-                if(function_exists('gzuncompress')) {
92
+                if (function_exists('gzuncompress')) {
93 93
                     $data = gzuncompress($data ?: '');
94 94
                 }
95 95
                 break;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 $data = Cache::transformData($data, Cache::GZIP);
115 115
                 break;
116 116
             case Cache::GZIP:
117
-                if(function_exists('gzcompress')) {
117
+                if (function_exists('gzcompress')) {
118 118
                     $data = gzcompress($data ?: '');
119 119
                 }
120 120
                 break;
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
147 147
     {
148 148
         $data = null;
149
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
149
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
150 150
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
151 151
                 $data = call_user_func($function);
152 152
                 $this->storeData($path, $data, $transform);
153
-            } else {
153
+            }else {
154 154
                 $data = $this->getDataFromFile($path, $transform);
155 155
             }
156 156
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     private static function checkAdminSite() {
164 164
         $isAdminRequest = false;
165 165
         $lastRequest = Security::getInstance()->getSessionKey("lastRequest");
166
-        if(null !== $lastRequest) {
166
+        if (null !== $lastRequest) {
167 167
             $url = str_replace(Request::getInstance()->getRootUrl(true), '', $lastRequest['url']);
168 168
             $isAdminRequest = preg_match('/^\/admin\//i', $url);
169 169
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     public static function needCache()
178 178
     {
179 179
         $needCache = false;
180
-        if(!self::checkAdminSite()) {
180
+        if (!self::checkAdminSite()) {
181 181
             $action = Security::getInstance()->getSessionKey("__CACHE__");
182 182
             if (null !== $action && array_key_exists("cache", $action) && $action["cache"] > 0) {
183 183
                 $needCache = $action["cache"];
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         $hash = "";
196 196
         $action = Security::getInstance()->getSessionKey("__CACHE__");
197 197
         if (null !== $action && $action["cache"] > 0) {
198
-            $hash = $action["http"] . " " . $action["slug"];
198
+            $hash = $action["http"]." ".$action["slug"];
199 199
         }
200 200
         return sha1($hash);
201 201
     }
Please login to merge, or discard this patch.
src/base/config/Config.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     /**
183 183
      * Method that returns a config value
184 184
      * @param string $param
185
-     * @param mixed $defaultValue
185
+     * @param boolean $defaultValue
186 186
      *
187 187
      * @return mixed|null
188 188
      */
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     /**
223 223
      * Static wrapper for extracting params
224 224
      * @param string $key
225
-     * @param mixed|null $defaultValue
225
+     * @param boolean|string $defaultValue
226 226
      * @return mixed|null
227 227
      */
228 228
     public static function getParam($key, $defaultValue = null) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     protected function init()
74 74
     {
75
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
75
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) {
76 76
             $this->loadConfigData();
77 77
         }
78 78
         return $this;
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
         $final_data = self::saveExtraParams($data);
171 171
         $saved = false;
172 172
         try {
173
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, $final_data, Cache::JSON, true);
173
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, $final_data, Cache::JSON, true);
174 174
             Config::getInstance()->loadConfigData();
175 175
             $saved = true;
176
-        } catch (ConfigException $e) {
176
+        }catch (ConfigException $e) {
177 177
             Logger::log($e->getMessage(), LOG_ERR);
178 178
         }
179 179
         return $saved;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function loadConfigData()
207 207
     {
208
-        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE,
208
+        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE,
209 209
             Cache::JSON,
210 210
             TRUE) ?: [];
211 211
         $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE;
Please login to merge, or discard this patch.
src/base/Template.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -8,10 +8,7 @@
 block discarded – undo
8 8
 use PSFS\base\extension\TemplateFunctions;
9 9
 use PSFS\base\types\helpers\GeneratorHelper;
10 10
 use PSFS\base\types\helpers\ResponseHelper;
11
-use PSFS\base\types\helpers\SecurityHelper;
12
-use PSFS\base\types\helpers\TemplateHelper;
13 11
 use PSFS\base\types\SingletonTrait;
14
-use PSFS\Dispatcher;
15 12
 
16 13
 
17 14
 class Template
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         ResponseHelper::setStatusHeader($this->status_code);
132 132
         ResponseHelper::setAuthHeaders($this->public_zone);
133 133
         ResponseHelper::setCookieHeaders($cookies);
134
-        header('Content-type: ' . $contentType);
134
+        header('Content-type: '.$contentType);
135 135
 
136 136
     }
137 137
 
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
         Logger::log('Start output response');
148 148
         ob_start();
149 149
         $this->setReponseHeaders($contentType, $cookies);
150
-        header('Content-length: ' . strlen($output));
150
+        header('Content-length: '.strlen($output));
151 151
 
152 152
         $cache = Cache::needCache();
153 153
         if (false !== $cache && $this->status_code === Template::STATUS_OK && $this->debug === false) {
154 154
             Logger::log('Saving output response into cache');
155 155
             $cacheName = $this->cache->getRequestCacheHash();
156
-            $tmpDir = substr($cacheName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheName, 2, 2) . DIRECTORY_SEPARATOR;
157
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheName, $output);
158
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheName . ".headers", headers_list(), Cache::JSON);
156
+            $tmpDir = substr($cacheName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheName, 2, 2).DIRECTORY_SEPARATOR;
157
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheName, $output);
158
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheName.".headers", headers_list(), Cache::JSON);
159 159
         }
160 160
         echo $output;
161 161
 
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
     {
173 173
         Logger::log('Close template render');
174 174
         Security::getInstance()->setSessionKey("lastRequest", array(
175
-            "url" => Request::getInstance()->getRootUrl() . Request::requestUri(),
175
+            "url" => Request::getInstance()->getRootUrl().Request::requestUri(),
176 176
             "ts" => microtime(true),
177 177
         ));
178 178
         Security::getInstance()->updateSession();
179
-        Logger::log('End request: ' . Request::requestUri(), LOG_INFO);
179
+        Logger::log('End request: '.Request::requestUri(), LOG_INFO);
180 180
         exit;
181 181
     }
182 182
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         $dump = '';
227 227
         try {
228 228
             $dump = $this->tpl->render($tpl, $vars);
229
-        } catch (\Exception $e) {
229
+        }catch (\Exception $e) {
230 230
             Logger::log($e->getMessage(), LOG_ERR);
231 231
         }
232 232
         return $dump;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     public function regenerateTemplates()
341 341
     {
342 342
         $this->generateTemplatesCache();
343
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true);
343
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true);
344 344
         $translations = [];
345 345
         if (is_array($domains)) {
346 346
             $translations = $this->parsePathTranslations($domains);
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
             // force compilation
363 363
             if ($file->isFile()) {
364 364
                 try {
365
-                    $this->tpl->load(str_replace($tplDir . '/', '', $file));
366
-                } catch (\Exception $e) {
365
+                    $this->tpl->load(str_replace($tplDir.'/', '', $file));
366
+                }catch (\Exception $e) {
367 367
                     Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]);
368 368
                 }
369 369
             }
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
      */
438 438
     private function loadDomains()
439 439
     {
440
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true);
441
-        if(null !== $domains) {
442
-            foreach($domains as $domain => $paths) {
440
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true);
441
+        if (null !== $domains) {
442
+            foreach ($domains as $domain => $paths) {
443 443
                 $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain));
444 444
             }
445 445
         }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
         $this->cache = Cache::getInstance();
455 455
         $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath());
456 456
         $this->tpl = new \Twig_Environment($loader, array(
457
-            'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig',
457
+            'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig',
458 458
             'debug' => (bool)$this->debug,
459 459
             'auto_reload' => Config::getParam('twig.auto_reload', TRUE),
460 460
         ));
Please login to merge, or discard this patch.
src/base/types/Controller.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace PSFS\base\types;
4 4
 
5
-use PSFS\base\config\Config;
6 5
 use PSFS\base\exception\RouterException;
7 6
 use PSFS\base\Request;
8 7
 use PSFS\base\Router;
Please login to merge, or discard this patch.
src/controller/ConfigController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      * @route /admin/config/params
23 23
      * @label Parámetros de configuración de PSGS
24 24
      * @visible false
25
-     * @return mixed
25
+     * @return string|null
26 26
      */
27 27
     public function getConfigParams()
28 28
     {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         foreach ($domains as $domain => $routes) {
32 32
             $pDomain = str_replace('@', '', $domain);
33 33
             $pDomain = str_replace('/', '', $pDomain);
34
-            $response[] = strtolower($pDomain) . '.api.secret';
34
+            $response[] = strtolower($pDomain).'.api.secret';
35 35
         }
36 36
         return $this->json($response);
37 37
     }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function config()
47 47
     {
48
-        Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri());
48
+        Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri());
49 49
         /* @var $form \PSFS\base\config\ConfigForm */
50 50
         $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig());
51 51
         $form->build();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 }
83 83
                 Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente"));
84 84
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true));
85
-            } else {
85
+            }else {
86 86
                 throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403);
87 87
             }
88 88
         }
Please login to merge, or discard this patch.
src/controller/RouteController.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      * @route /admin/routes/show
31 31
      * @label Servicio de rutas del sistema
32 32
      * @visible false
33
-     * @return mixed
33
+     * @return string|null
34 34
      */
35 35
     public function getRouting()
36 36
     {
Please login to merge, or discard this patch.
src/controller/UserController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 Logger::log('Configuration saved successful');
64 64
                 Security::getInstance()->setFlash("callback_message", _("Usuario agregado correctamente"));
65 65
                 Security::getInstance()->setFlash("callback_route", Router::getInstance()->getRoute("admin", true));
66
-            } else {
66
+            }else {
67 67
                 throw new ConfigException(_('Error al guardar los administradores, prueba a cambiar los permisos'));
68 68
             }
69 69
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         if ($this->isAdmin()) {
101 101
             return $this->redirect('admin');
102
-        } else {
102
+        }else {
103 103
             return Admin::staticAdminLogon($route);
104 104
         }
105 105
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                 $cookies = array(
132 132
                     array(
133 133
                         "name" => Security::getInstance()->getHash(),
134
-                        "value" => base64_encode($form->getFieldValue("user") . ":" . $form->getFieldValue("pass")),
134
+                        "value" => base64_encode($form->getFieldValue("user").":".$form->getFieldValue("pass")),
135 135
                         "expire" => time() + 3600,
136 136
                         "http" => true,
137 137
                     )
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                     'status_message' => _("Acceso permitido... redirigiendo!!"),
143 143
                     'delay' => 1,
144 144
                 );
145
-            } else {
145
+            }else {
146 146
                 $form->setError("user", _("El usuario no tiene acceso a la web"));
147 147
             }
148 148
         }
Please login to merge, or discard this patch.
src/controller/GeneratorController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function generateModule()
32 32
     {
33
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
33
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
34 34
         /* @var $form \PSFS\base\config\ConfigForm */
35 35
         $form = new ModuleForm();
36 36
         $form->build();
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
                 $this->gen->createStructureModule($module, false, $type, (bool)$is_module);
62 62
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
63 63
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
64
-            } catch (\Exception $e) {
65
-                Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
64
+            }catch (\Exception $e) {
65
+                Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
66 66
                 throw new ConfigException(_('Error al generar el módulo, prueba a cambiar los permisos'), 403);
67 67
             }
68 68
         }
Please login to merge, or discard this patch.
src/controller/base/Admin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public static function staticAdminLogon($route = null)
50 50
     {
51
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
51
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
52 52
             if ('login' !== Config::getInstance()->get('admin_login')) {
53 53
                 return AdminServices::getInstance()->setAdminHeaders();
54
-            } else {
54
+            }else {
55 55
                 $form = new LoginForm();
56 56
                 $form->setData(array("route" => $route));
57 57
                 $form->build();
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                     'form' => $form,
62 62
                 ));
63 63
             }
64
-        } else {
64
+        }else {
65 65
             return UserController::showAdminManager();
66 66
         }
67 67
     }
Please login to merge, or discard this patch.