Passed
Push — master ( fd31ea...8a1c29 )
by Fran
09:11
created
src/base/types/traits/Security/ProfileTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
     public static function save($user)
90 90
     {
91 91
         $saved = true;
92
-        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
93
-        $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
92
+        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
93
+        $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
94 94
         $admins[$user['username']]['profile'] = $user['profile'];
95 95
 
96
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
96
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
97 97
         return $saved;
98 98
     }
99 99
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function deleteUser($user)
115 115
     {
116
-        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
116
+        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
117 117
         unset($admins[$user]);
118
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
118
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
119 119
     }
120 120
 
121 121
     /**
Please login to merge, or discard this patch.
src/base/types/traits/CurlTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
         $this->params = [];
101 101
         $this->headers = [];
102 102
         $this->debug = 'debug' === strtolower(Config::getParam('log.level', 'notice'));
103
-        Logger::log('Context service for ' . static::class . ' cleared!');
103
+        Logger::log('Context service for '.static::class.' cleared!');
104 104
         $this->closeConnection();
105 105
     }
106 106
 
Please login to merge, or discard this patch.
src/base/types/traits/Helper/ServerTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@
 block discarded – undo
54 54
     public function getServerName()
55 55
     {
56 56
         $serverName = $this->getServer('SERVER_NAME');
57
-        if(empty($serverName)) {
57
+        if (empty($serverName)) {
58 58
             $serverName = $this->getServer('HTTP_HOST');
59 59
         }
60
-        if(str_contains($serverName ?? '', ':')) {
60
+        if (str_contains($serverName ?? '', ':')) {
61 61
             $pieces = explode(':', $serverName);
62 62
             $serverName = $pieces[0];
63 63
         }
Please login to merge, or discard this patch.
src/base/dto/JsonResponse.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@
 block discarded – undo
33 33
     private function parseData($data) {
34 34
         if ($data instanceof \Generator) {
35 35
             $generatedData = [];
36
-            foreach($data as $datum) {
36
+            foreach ($data as $datum) {
37 37
                 $generatedData[] = $datum;
38 38
             }
39
-        } else {
39
+        }else {
40 40
             $generatedData = $data;
41 41
         }
42 42
         return $generatedData;
Please login to merge, or discard this patch.
src/autoload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
         if (str_starts_with($class, 'PSFS\\')) {
23 23
             $relativeClass = substr($class, strlen('PSFS\\'));
24 24
 
25
-            $file = SOURCE_DIR . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php';
25
+            $file = SOURCE_DIR.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass).'.php';
26 26
 
27 27
             if (file_exists($file)) {
28 28
                 require_once $file;
29
-            } else if (class_exists('PSFS\\base\\Logger')) {
29
+            }else if (class_exists('PSFS\\base\\Logger')) {
30 30
                 \PSFS\base\Logger::log("[Autoloader] Class $class not found at $file", LOG_WARNING);
31 31
             }
32 32
         }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 // Registro automático del autoloader (puedes comentarlo si lo haces desde bootstrap)
37 37
 if (!defined('SOURCE_DIR')) {
38
-    define('SOURCE_DIR', dirname(__DIR__) . '/src');
38
+    define('SOURCE_DIR', dirname(__DIR__).'/src');
39 39
 }
40 40
 
41 41
 Autoloader::register();
Please login to merge, or discard this patch.
src/base/types/traits/Generator/StructureTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         // Creates the src folder
27 27
         GeneratorHelper::createDir($modPath);
28 28
         // Create module path
29
-        GeneratorHelper::createDir($modPath . $module);
29
+        GeneratorHelper::createDir($modPath.$module);
30 30
     }
31 31
 
32 32
     /**
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
         Logger::log("Generamos la estructura");
43 43
         $paths = [
44 44
             "Api", "Config", "Controller", "Models", "Public", "Templates", "Services", "Test", "Doc",
45
-            "Locale", "Locale/" . Config::getParam('default.locale', 'es_ES'), "Locale/" . Config::getParam('default.locale', 'es_ES') . "/LC_MESSAGES"
45
+            "Locale", "Locale/".Config::getParam('default.locale', 'es_ES'), "Locale/".Config::getParam('default.locale', 'es_ES')."/LC_MESSAGES"
46 46
         ];
47
-        $modulePath = $modPath . $module;
47
+        $modulePath = $modPath.$module;
48 48
         foreach ($paths as $path) {
49
-            GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . $path);
49
+            GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR.$path);
50 50
         }
51 51
         //Creamos las carpetas de los assets
52 52
         $htmlPaths = array("css", "js", "img", "media", "font");
53 53
         foreach ($htmlPaths as $path) {
54
-            GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path);
54
+            GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path);
55 55
         }
56 56
     }
57 57
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
         //Generamos el fichero de configuración
67 67
         Logger::log("Generamos ficheros para assets base");
68 68
         $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n",
69
-            $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css",
69
+            $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css",
70 70
             $force);
71 71
         $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();",
72
-            $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js",
72
+            $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js",
73 73
             $force);
74 74
         return ($css && $js);
75 75
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             "class" => $class,
92 92
         ));
93 93
         return $this->writeTemplateToFile($controller,
94
-            $modPath . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php",
94
+            $modPath.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php",
95 95
             $force);
96 96
     }
97 97
 
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
             "autoloader" => preg_replace('/(\\\|\/)/', '_', $module),
111 111
             "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module),
112 112
         ));
113
-        $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", true);
113
+        $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", true);
114 114
 
115 115
         Logger::log("Generamos el phpunit");
116 116
         $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array(
117 117
             "module" => $module,
118 118
         ));
119
-        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force);
119
+        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force);
120 120
         return $autoload && $phpunit;
121 121
     }
122 122
 }
Please login to merge, or discard this patch.
src/base/types/helpers/ResponseHelper.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     {
24 24
         if (str_contains($header, ':')) {
25 25
             list($key, $value) = explode(':', $header);
26
-        } else {
26
+        }else {
27 27
             $key = 'Http Status';
28 28
             $value = $header;
29 29
         }
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
             Logger::log('Adding debug headers to render response');
102 102
             $vars["__DEBUG__"]["includes"] = get_included_files();
103 103
             $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
104
-            self::setHeader('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s');
105
-            self::setHeader('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes');
106
-            self::setHeader('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened');
104
+            self::setHeader('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s');
105
+            self::setHeader('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes');
106
+            self::setHeader('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened');
107 107
         }
108 108
 
109 109
         return $vars;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @return int|string
116 116
      * @throws GeneratorException
117 117
      */
118
-    public static function httpNotFound(\Throwable $exception = null, bool $isJson = false): int|string
118
+    public static function httpNotFound(\Throwable $exception = null, bool $isJson = false): int | string
119 119
     {
120 120
         if (self::isTest()) {
121 121
             return 404;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $notFoundRoute = Config::getParam('route.404');
135 135
         if (null !== $notFoundRoute) {
136 136
             Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true));
137
-        } else {
137
+        }else {
138 138
             return $template->render('error.html.twig', array(
139 139
                 'exception' => $exception,
140 140
                 'trace' => $exception->getTraceAsString(),
Please login to merge, or discard this patch.
src/base/types/AuthApi.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@
 block discarded – undo
32 32
     {
33 33
         $namespace = explode('\\', $this->getModelTableMap());
34 34
         $module = strtolower($namespace[0]);
35
-        $secret = Config::getInstance()->get($module . '.api.secret');
35
+        $secret = Config::getInstance()->get($module.'.api.secret');
36 36
         if (null === $secret) {
37 37
             $secret = Config::getInstance()->get("api.secret");
38 38
         }
39 39
         if (null === $secret) {
40 40
             $auth = true;
41
-        } else {
41
+        }else {
42 42
             $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN');
43 43
             if (array_key_exists('API_TOKEN', $this->query)) {
44 44
                 $token = $this->query['API_TOKEN'];
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function init()
66 66
     {
67
-        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, true);
68
-        $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, true);
67
+        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, true);
68
+        $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, true);
69 69
         if (empty($this->routing) || Config::getParam('debug', true)) {
70 70
             $this->debugLoad();
71 71
         }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             $this->hydrateRouting();
87 87
             $this->simpatize();
88 88
             Logger::log('End routes load');
89
-        } else {
89
+        }else {
90 90
             Logger::log('Routes generation skipped');
91 91
         }
92 92
     }
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
         try {
104 104
             //Search action and execute
105 105
             return $this->searchAction($route);
106
-        } catch (AccessDeniedException $e) {
107
-            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
106
+        }catch (AccessDeniedException $e) {
107
+            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']);
108 108
             return Admin::staticAdminLogon();
109
-        } catch (RouterException $r) {
109
+        }catch (RouterException $r) {
110 110
             Logger::log($r->getMessage(), LOG_WARNING);
111 111
             $code = $r->getCode();
112
-        } catch (Exception $e) {
112
+        }catch (Exception $e) {
113 113
             Logger::log($e->getMessage(), LOG_ERR);
114 114
             throw $e;
115 115
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     protected function searchAction($route)
129 129
     {
130
-        Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG);
130
+        Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG);
131 131
         //Revisamos si tenemos la ruta registrada
132 132
         $parts = parse_url($route);
133 133
         $path = array_key_exists('path', $parts) ? $parts['path'] : $route;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                     }
149 149
 
150 150
                     throw new RouterException(t('Preconditions failed'), 412);
151
-                } catch (Exception $e) {
151
+                }catch (Exception $e) {
152 152
                     Logger::log($e->getMessage(), LOG_ERR);
153 153
                     throw $e;
154 154
                 }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                 }
174 174
             }
175 175
             $valid = count($action['requirements']) === $checked;
176
-        } else {
176
+        }else {
177 177
             $valid = true;
178 178
         }
179 179
         return $valid;
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
             if ($modules->hasResults()) {
197 197
                 foreach ($modules->getIterator() as $modulePath) {
198 198
                     $module = $modulePath->getBasename();
199
-                    $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
199
+                    $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
200 200
                 }
201 201
             }
202 202
         }
203
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, true);
203
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, true);
204 204
     }
205 205
 
206 206
     /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             $homeParams = null;
218 218
             foreach ($this->routing as $pattern => $params) {
219 219
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
220
-                if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) {
220
+                if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) {
221 221
                     $homeParams = $params;
222 222
                 }
223 223
                 unset($method);
@@ -249,18 +249,18 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : '';
251 251
         if ('' === $slug) {
252
-            return $baseUrl . '/';
252
+            return $baseUrl.'/';
253 253
         }
254 254
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
255 255
             throw new RouterException(t('No existe la ruta especificada'));
256 256
         }
257
-        $url = $baseUrl . $this->slugs[$slug];
257
+        $url = $baseUrl.$this->slugs[$slug];
258 258
         if (!empty($params)) {
259 259
             foreach ($params as $key => $value) {
260
-                $url = str_replace('{' . $key . '}', $value, $url);
260
+                $url = str_replace('{'.$key.'}', $value, $url);
261 261
             }
262 262
         } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
263
-            $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default'];
263
+            $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default'];
264 264
         }
265 265
 
266 266
         return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         if ($this->hasToRunPreChecks($class)) {
276 276
             self::run($class, '__check', true);
277 277
         }
278
-        $preAction = 'pre' . ucfirst($method);
278
+        $preAction = 'pre'.ucfirst($method);
279 279
         if (method_exists($class, $preAction)) {
280 280
             self::run($class, $preAction);
281 281
         }
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public static function run($class, $method, $throwExceptions = false): void
292 292
     {
293
-        Inspector::stats("[Router] Pre action invoked " . get_class($class) . "::{$method}", Inspector::SCOPE_DEBUG);
293
+        Inspector::stats("[Router] Pre action invoked ".get_class($class)."::{$method}", Inspector::SCOPE_DEBUG);
294 294
         try {
295 295
             if (false === call_user_func_array([$class, $method], [])) {
296
-                Logger::log(t("[Router] action " . get_class($class) . "::{$method} failed"), LOG_ERR, [error_get_last()]);
296
+                Logger::log(t("[Router] action ".get_class($class)."::{$method} failed"), LOG_ERR, [error_get_last()]);
297 297
                 error_clear_last();
298 298
             }
299
-        } catch (Exception $e) {
299
+        }catch (Exception $e) {
300 300
             Logger::log($e->getMessage(), LOG_ERR, [$class, $method]);
301 301
             if ($throwExceptions) {
302 302
                 throw $e;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      */
326 326
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
327 327
     {
328
-        Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG);
328
+        Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG);
329 329
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
330 330
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
331 331
         $cache = Cache::needCache();
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
         $return = null;
334 334
         if (false !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === false) {
335 335
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
336
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache);
336
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache);
337 337
             if (NULL !== $cachedData) {
338
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON);
338
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON);
339 339
                 Template::getInstance()->renderCache($cachedData, $headers);
340 340
                 $execute = false;
341 341
             }
342 342
         }
343 343
         if ($execute) {
344
-            Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG);
344
+            Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG);
345 345
             $this->checkPreActions($class, $action['method']);
346 346
             $return = call_user_func_array([$class, $action['method']], $params);
347 347
             if (false === $return) {
Please login to merge, or discard this patch.