Passed
Push — master ( bdf47a...45a71d )
by Fran
03:45
created
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, $apiClass);
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
                 Security::getInstance()->setFlash("callback_message", $e->getMessage());
67 67
             }
68 68
         }
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
             $objects = scandir($dir);
20 20
             foreach ($objects as $object) {
21 21
                 if ($object != "." && $object != "..") {
22
-                    if (filetype($dir . "/" . $object) == "dir") {
23
-                        self::deleteDir($dir . "/" . $object);
24
-                    } else {
25
-                        unlink($dir . "/" . $object);
22
+                    if (filetype($dir."/".$object) == "dir") {
23
+                        self::deleteDir($dir."/".$object);
24
+                    }else {
25
+                        unlink($dir."/".$object);
26 26
                     }
27 27
                 }
28 28
             }
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $rootDirs = array("css", "js", "media", "font");
40 40
         foreach ($rootDirs as $dir) {
41
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
41
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
42 42
                 try {
43
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
44
-                } catch (\Exception $e) {
43
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
44
+                }catch (\Exception $e) {
45 45
                     Logger::log($e->getMessage());
46 46
                 }
47 47
             }
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
     {
58 58
         try {
59 59
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
60
-                throw new \Exception(_('Can\'t create directory ') . $dir);
60
+                throw new \Exception(_('Can\'t create directory ').$dir);
61 61
             }
62
-        } catch (\Exception $e) {
62
+        }catch (\Exception $e) {
63 63
             Logger::log($e->getMessage(), LOG_WARNING);
64 64
             if (!file_exists(dirname($dir))) {
65
-                throw new GeneratorException($e->getMessage() . $dir);
65
+                throw new GeneratorException($e->getMessage().$dir);
66 66
             }
67 67
         }
68 68
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function getTemplatePath()
75 75
     {
76
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
76
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
77 77
         return realpath($path);
78 78
     }
79 79
 
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
      * @throws GeneratorException
92 92
      */
93 93
     public static function checkCustomNamespaceApi($namespace) {
94
-        if(!empty($namespace)) {
95
-            if(class_exists($namespace)) {
94
+        if (!empty($namespace)) {
95
+            if (class_exists($namespace)) {
96 96
                 $reflector = new \ReflectionClass($namespace);
97
-                if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
97
+                if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
98 98
                     throw new GeneratorException(_('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501);
99
-                } elseif(!$reflector->isAbstract()) {
99
+                } elseif (!$reflector->isAbstract()) {
100 100
                     throw new GeneratorException(_('La clase definida debe ser abstracta'), 501);
101 101
                 }
102
-            } else {
102
+            }else {
103 103
                 throw new GeneratorException(_('La clase definida para extender la API no existe'), 501);
104 104
             }
105 105
         }
Please login to merge, or discard this patch.
src/base/Cache.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     /**
148 148
      * Método que guarda en fichero los datos pasados
149
-     * @param $path
149
+     * @param string $path
150 150
      * @param $data
151 151
      * @param int $transform
152 152
      * @param boolean $absolute
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
     /**
203 203
      * Método estático que revisa si se necesita cachear la respuesta de un servicio o no
204
-     * @return integer|boolean
204
+     * @return integer
205 205
      */
206 206
     public static function needCache()
207 207
     {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         GeneratorHelper::createDir(dirname($path));
47 47
         if (false === FileHelper::writeFile($path, $data)) {
48
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
48
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
49 49
         }
50 50
     }
51 51
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
60 60
     {
61 61
         $data = null;
62
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
62
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
63 63
         if (file_exists($absolutePath)) {
64 64
             $data = FileHelper::readFile($absolutePath);
65 65
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
77 77
     {
78
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
78
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
79 79
         $lasModificationDate = filemtime($absolutePath);
80 80
         return ($lasModificationDate + $expires <= time());
81 81
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     public function storeData($path, $data, $transform = Cache::TEXT, $absolute = false, $expires = 600)
142 142
     {
143 143
         $data = Cache::transformData($data, $transform);
144
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
144
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
145 145
         $this->saveTextToFile($data, $absolutePath);
146 146
     }
147 147
 
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
157 157
     {
158 158
         $data = null;
159
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
159
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
160 160
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
161 161
                 $data = call_user_func($function);
162 162
                 $this->storeData($path, $data, $transform, false, $expires);
163
-            } else {
163
+            }else {
164 164
                 $data = $this->getDataFromFile($path, $transform);
165 165
             }
166 166
         }
Please login to merge, or discard this patch.
src/base/config/Config.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected function init()
76 76
     {
77
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
77
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) {
78 78
             $this->loadConfigData();
79 79
         }
80 80
         return $this;
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
             $final_data = array_filter($final_data, function($key, $value) {
183 183
                 return in_array($key, Config::$required) || !empty($value);
184 184
             }, ARRAY_FILTER_USE_BOTH);
185
-            $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT)));
185
+            $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT)));
186 186
             Config::getInstance()->loadConfigData();
187 187
             $saved = true;
188
-        } catch (ConfigException $e) {
188
+        }catch (ConfigException $e) {
189 189
             Logger::log($e->getMessage(), LOG_ERR);
190 190
         }
191 191
         return $saved;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function loadConfigData()
219 219
     {
220
-        $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: [];
220
+        $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: [];
221 221
         $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE;
222 222
     }
223 223
 
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     /**
193 193
      * Method that returns a config value
194 194
      * @param string $param
195
-     * @param mixed $defaultValue
195
+     * @param string $defaultValue
196 196
      *
197 197
      * @return mixed|null
198 198
      */
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     /**
231 231
      * Static wrapper for extracting params
232 232
      * @param string $key
233
-     * @param mixed|null $defaultValue
233
+     * @param string|boolean $defaultValue
234 234
      * @return mixed|null
235 235
      */
236 236
     public static function getParam($key, $defaultValue = null)
Please login to merge, or discard this patch.
src/base/types/helpers/ApiFormHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
     public static function checkApiActions($namespace, $domain, $api) {
18 18
         $actions = [];
19 19
         $reflector = new \ReflectionClass($namespace);
20
-        if(null !== $reflector) {
21
-            foreach($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) {
20
+        if (null !== $reflector) {
21
+            foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) {
22 22
                 $docComments = $apiAction->getDocComment();
23 23
                 $action = self::extractAction($docComments);
24
-                if(null !== $action) {
24
+                if (null !== $action) {
25 25
                     list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain);
26 26
                     list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route);
27 27
                     $formAction = new FormAction();
Please login to merge, or discard this patch.
src/base/types/Controller.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -1,14 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace PSFS\base\types;
3 3
 
4
-use PSFS\base\exception\RouterException;
5
-use PSFS\base\Request;
6
-use PSFS\base\Router;
7 4
 use PSFS\base\Singleton;
8 5
 use PSFS\base\types\helpers\GeneratorHelper;
9 6
 use PSFS\base\types\interfaces\ControllerInterface;
10 7
 use PSFS\base\types\traits\JsonTrait;
11
-use PSFS\base\types\traits\OutputTrait;
12 8
 use PSFS\base\types\traits\RouteTrait;
13 9
 
14 10
 /**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $vars['__menu__'] = $this->getMenu();
42 42
         $domain = (null === $domain) ? $this->getDomain() : $domain;
43
-        return $this->tpl->render($domain . $template, $vars, $cookies);
43
+        return $this->tpl->render($domain.$template, $vars, $cookies);
44 44
     }
45 45
 
46 46
     /**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $vars['__menu__'] = $this->getMenu();
73 73
         $domain = $domain ?: $this->getDomain();
74
-        return $this->tpl->dump($domain . $template, $vars);
74
+        return $this->tpl->dump($domain.$template, $vars);
75 75
     }
76 76
 
77 77
     /**
Please login to merge, or discard this patch.
src/functions.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,9 +31,10 @@
 block discarded – undo
31 31
     function getallheaders()
32 32
     {
33 33
         $headers = array();
34
-        foreach ($_SERVER as $h => $v)
35
-            if (preg_match('/HTTP_(.+)/', $h, $hp))
34
+        foreach ($_SERVER as $h => $v) {
35
+                    if (preg_match('/HTTP_(.+)/', $h, $hp))
36 36
                 $headers[$hp[1]] = $v;
37
+        }
37 38
         return $headers;
38 39
     }
39 40
 }
Please login to merge, or discard this patch.
src/base/types/traits/BoostrapTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
  */
8 8
 Trait BoostrapTrait {}
9 9
 
10
-require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php';
11 10
\ No newline at end of file
11
+require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'bootstrap.php';
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
src/base/types/traits/SystemTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                 $use /= 1024;
36 36
                 break;
37 37
             case "MBytes":
38
-                $use /= (1024 * 1024);
38
+                $use /= (1024*1024);
39 39
                 break;
40 40
             case "Bytes":
41 41
             default:
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         Logger::log('Added handlers for errors');
62 62
         //Warning & Notice handler
63
-        set_error_handler(function ($errno, $errstr, $errfile, $errline) {
63
+        set_error_handler(function($errno, $errstr, $errfile, $errline) {
64 64
             Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]);
65 65
             return true;
66 66
         }, E_ALL | E_STRICT);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         Logger::log('Initializing stats (mem + ts)');
75 75
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
76 76
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
77
-        } else {
77
+        }else {
78 78
             $this->ts = Request::getInstance()->getTs();
79 79
         }
80 80
         $this->mem = memory_get_usage();
Please login to merge, or discard this patch.