Passed
Push — master ( 416db0...5c3ce7 )
by Fran
03:08
created
src/base/types/helpers/AdminHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $routes = [];
33 33
         foreach ($systemRoutes as $route => $params) {
34
-            if(isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) {
34
+            if (isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) {
35 35
                 $module = strtoupper($params['module']);
36 36
                 $mode = $params["visible"] ? 'visible' : 'hidden';
37 37
                 $routes[$module][$mode][] = [
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
                 ];
42 42
             }
43 43
         }
44
-        foreach($routes as $module => &$route) {
45
-            if(array_key_exists('visible', $route)) {
44
+        foreach ($routes as $module => &$route) {
45
+            if (array_key_exists('visible', $route)) {
46 46
                 uasort($route["visible"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel');
47 47
             }
48
-            if(array_key_exists('hidden', $route)) {
48
+            if (array_key_exists('hidden', $route)) {
49 49
                 uasort($route["hidden"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel');
50 50
             }
51 51
         }
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   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         GeneratorHelper::createDir(dirname($path));
52 52
         if (false === FileHelper::writeFile($path, $data)) {
53
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
53
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
54 54
         }
55 55
     }
56 56
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]);
67 67
         $data = null;
68
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
68
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
69 69
         if (file_exists($absolutePath)) {
70 70
             $data = FileHelper::readFile($absolutePath);
71 71
         }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
83 83
     {
84 84
         Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]);
85
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
85
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
86 86
         $lasModificationDate = filemtime($absolutePath);
87 87
         return ($lasModificationDate + $expires <= time());
88 88
     }
@@ -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 = Cache::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
 
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $data = null;
169 169
         Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]);
170
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
170
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
171 171
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
172 172
                 $data = call_user_func($function);
173 173
                 $this->storeData($path, $data, $transform, false, $expires);
174
-            } else {
174
+            }else {
175 175
                 $data = $this->getDataFromFile($path, $transform);
176 176
             }
177 177
         }
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
      * Flush cache when save a registry
229 229
      */
230 230
     public function flushCache() {
231
-        if(Config::getParam('cache.data.enable', false)) {
231
+        if (Config::getParam('cache.data.enable', false)) {
232 232
             Logger::log('Flushing cache', LOG_DEBUG);
233 233
             $action = Security::getInstance()->getSessionKey("__CACHE__");
234
-            if(is_array($action)) {
235
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
236
-                if(!file_exists($hashPath)) {
237
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
234
+            if (is_array($action)) {
235
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
236
+                if (!file_exists($hashPath)) {
237
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
238 238
                 }
239 239
                 FileHelper::deleteDir($hashPath);
240 240
             }
Please login to merge, or discard this patch.
src/base/Singleton.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,9 +121,11 @@
 block discarded – undo
121 121
                 $cacheService->storeData($cacheFilename, $properties, $cache);
122 122
             }
123 123
             /** @var \ReflectionProperty $property */
124
-            if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) {
124
+            if (!empty($properties) && is_array($properties)) {
125
+                foreach ($properties as $property => $class) {
125 126
                 $this->load($property, true, $class);
126 127
             }
128
+            }
127 129
             $this->setLoaded();
128 130
         } else {
129 131
             Logger::log(get_class($this) . ' already loaded', LOG_INFO);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function __construct()
17 17
     {
18
-        Logger::log(get_class($this) . ' constructor invoked');
18
+        Logger::log(get_class($this).' constructor invoked');
19 19
         $this->init();
20 20
     }
21 21
 
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
         $calledClass = get_called_class();
69 69
         try {
70 70
             $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass);
71
-            $setter = "set" . ucfirst($variable);
71
+            $setter = "set".ucfirst($variable);
72 72
             if (method_exists($calledClass, $setter)) {
73 73
                 $this->$setter($instance);
74
-            } else {
74
+            }else {
75 75
                 $this->$variable = $instance;
76 76
             }
77
-        } catch (\Exception $e) {
78
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR);
77
+        }catch (\Exception $e) {
78
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
79 79
             throw $e;
80 80
         }
81 81
         return $this;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     {
89 89
         if (!$this->isLoaded()) {
90 90
             $filename = sha1(get_class($this));
91
-            $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json";
91
+            $cacheFilename = "reflections".DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json";
92 92
             /** @var \PSFS\base\Cache $cacheService */
93 93
             $cacheService = Cache::getInstance();
94 94
             /** @var \PSFS\base\config\Config $configService */
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
                 $this->load($property, true, $class);
105 105
             }
106 106
             $this->setLoaded();
107
-        } else {
108
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
107
+        }else {
108
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
109 109
         }
110 110
     }
111 111
 }
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/functions.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
     /* @var $file SplFileInfo */
47 47
     foreach ($finder as $file) {
48 48
         $path = $file->getRealPath();
49
-        if(!in_array($path, $loaded_files)) {
49
+        if (!in_array($path, $loaded_files)) {
50 50
             $loaded_files[] = $path;
51 51
             require_once($path);
52 52
         }
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/SingletonTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
      */
35 35
     public static function dropInstance() {
36 36
         $class = get_called_class();
37
-        if(isset(self::$instance[$class])) {
37
+        if (isset(self::$instance[$class])) {
38 38
             self::$instance[$class] = null;
39 39
         }
40 40
     }
Please login to merge, or discard this patch.
src/base/types/traits/OutputTrait.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@
 block discarded – undo
202 202
 
203 203
     /**
204 204
      * Método que fuerza la descarga de un fichero
205
-     * @param $data
205
+     * @param string $data
206 206
      * @param string $content
207 207
      * @param string $filename
208 208
      * @return mixed
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                 $this->setStatusCode(Template::STATUS_OK);
121 121
                 break;
122 122
             default:
123
-                $this->setStatusCode('HTTP/1.0 ' . $status ?: 200);
123
+                $this->setStatusCode('HTTP/1.0 '.$status ?: 200);
124 124
                 break;
125 125
         }
126 126
         return $this;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         ResponseHelper::setStatusHeader($this->getStatusCode());
139 139
         ResponseHelper::setAuthHeaders($this->isPublicZone());
140 140
         ResponseHelper::setCookieHeaders($cookies);
141
-        header('Content-type: ' . $contentType);
141
+        header('Content-type: '.$contentType);
142 142
 
143 143
     }
144 144
 
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
         Logger::log('Start output response');
155 155
         ob_start();
156 156
         $this->setReponseHeaders($contentType, $cookies);
157
-        header('Content-length: ' . strlen($output));
158
-        header('CRC: ' . crc32($output));
157
+        header('Content-length: '.strlen($output));
158
+        header('CRC: '.crc32($output));
159 159
 
160 160
         $needCache = Cache::needCache();
161 161
         $cache = Cache::getInstance();
162 162
         list($path, $cacheDataName) = $cache->getRequestCacheHash();
163 163
         if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK && null !== $cacheDataName) {
164 164
             Logger::log('Saving output response into cache');
165
-            $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output);
166
-            $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON);
165
+            $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output);
166
+            $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON);
167 167
         } elseif (Request::getInstance()->getMethod() !== 'GET') {
168 168
             $cache->flushCache();
169 169
         }
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
         Logger::log('Close template render');
184 184
         $uri = Request::requestUri();
185 185
         Security::getInstance()->setSessionKey("lastRequest", array(
186
-            "url" => Request::getInstance()->getRootUrl() . $uri,
186
+            "url" => Request::getInstance()->getRootUrl().$uri,
187 187
             "ts" => microtime(true),
188 188
         ));
189 189
         Security::getInstance()->updateSession();
190
-        Logger::log('End request: ' . $uri, LOG_INFO);
190
+        Logger::log('End request: '.$uri, LOG_INFO);
191 191
         exit;
192 192
     }
193 193
 
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
         /////////////////////////////////////////////////////////////
226 226
         // Date in the past sets the value to already have been expired.
227 227
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
228
-        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
228
+        header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
229 229
         header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
230 230
         header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
231 231
         header("Pragma: no-cache");
232 232
         header("Expires: 0");
233 233
         header('Content-Transfer-Encoding: binary');
234
-        header("Content-type: " . $content);
235
-        header("Content-length: " . strlen($data));
236
-        header('Content-Disposition: attachment; filename="' . $filename . '"');
234
+        header("Content-type: ".$content);
235
+        header("Content-length: ".strlen($data));
236
+        header('Content-Disposition: attachment; filename="'.$filename.'"');
237 237
         header("Access-Control-Expose-Headers: Filename");
238
-        header("Filename: " . $filename);
238
+        header("Filename: ".$filename);
239 239
         echo $data;
240 240
         ob_flush();
241 241
         ob_end_clean();
Please login to merge, or discard this patch.