Passed
Push — master ( bae6c3...e6b3d1 )
by Fran
04:09
created
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   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     use SingletonTrait;
28 28
 
29 29
     public function init() {
30
-        if(Cache::canUseMemcache()) {
30
+        if (Cache::canUseMemcache()) {
31 31
             $this->memcache = new \Memcached();
32 32
             $this->memcache->connect(Config::getParam('memcache.host', '127.0.0.1'), Config::getParam('memcache.port', 11211));
33 33
         }
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
67 67
     {
68 68
         $data = null;
69
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
70
-        if(Cache::MEMCACHE && Cache::canUseMemcache()) {
69
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
70
+        if (Cache::MEMCACHE && Cache::canUseMemcache()) {
71 71
             $data = $this->memcache->get(sha1($absolutePath));
72 72
         } elseif (file_exists($absolutePath)) {
73 73
             $data = file_get_contents($absolutePath);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
86 86
     {
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
     }
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
     public function storeData($path, $data, $transform = Cache::TEXT, $absolute = false, $expires = 600)
156 156
     {
157 157
         $data = Cache::transformData($data, $transform);
158
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
159
-        if(Cache::MEMCACHE == $transform) {
158
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
159
+        if (Cache::MEMCACHE == $transform) {
160 160
             $this->memcache->set(sha1($absolutePath), $data, $expires);
161
-        } else {
161
+        }else {
162 162
             $this->saveTextToFile($data, $absolutePath);
163 163
         }
164 164
     }
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
175 175
     {
176 176
         $data = null;
177
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
177
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
178 178
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
179 179
                 $data = call_user_func($function);
180 180
                 $this->storeData($path, $data, $transform, false, $expires);
181
-            } else {
181
+            }else {
182 182
                 $data = $this->getDataFromFile($path, $transform);
183 183
             }
184 184
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
         $hash = "";
225 225
         $action = Security::getInstance()->getSessionKey("__CACHE__");
226 226
         if (null !== $action && $action["cache"] > 0) {
227
-            $hash = $action["http"] . " " . $action["slug"];
227
+            $hash = $action["http"]." ".$action["slug"];
228 228
         }
229 229
         return sha1($hash);
230 230
     }
Please login to merge, or discard this patch.
src/base/config/Config.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 namespace PSFS\base\config;
4 4
 
5 5
 
6
-use PSFS\base\Cache;
7 6
 use PSFS\base\exception\ConfigException;
8 7
 use PSFS\base\Logger;
9 8
 use PSFS\base\Request;
Please login to merge, or discard this patch.
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
             }, 1);
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.
src/Dispatcher.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
                 if (!$this->parser->isFile()) {
79 79
                     return $this->router->execute($this->actualUri);
80 80
                 }
81
-            } else {
81
+            }else {
82 82
                 return ConfigController::getInstance()->config();
83 83
             }
84
-        } catch (AdminCredentialsException $a) {
84
+        }catch (AdminCredentialsException $a) {
85 85
             return UserController::showAdminManager();
86
-        } catch (SecurityException $s) {
86
+        }catch (SecurityException $s) {
87 87
             return $this->security->notAuthorized($this->actualUri);
88
-        } catch (RouterException $r) {
88
+        }catch (RouterException $r) {
89 89
             return $this->router->httpNotFound($r);
90
-        } catch (\Exception $e) {
90
+        }catch (\Exception $e) {
91 91
             return $this->dumpException($e);
92 92
         }
93 93
     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                 $use /= 1024;
130 130
                 break;
131 131
             case "MBytes":
132
-                $use /= (1024 * 1024);
132
+                $use /= (1024*1024);
133 133
                 break;
134 134
             case "Bytes":
135 135
             default:
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     {
155 155
         Logger::log('Added handlers for errors');
156 156
         //Warning & Notice handler
157
-        set_error_handler(function ($errno, $errstr, $errfile, $errline) {
157
+        set_error_handler(function($errno, $errstr, $errfile, $errline) {
158 158
             Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]);
159 159
             return true;
160 160
         }, E_ALL | E_STRICT);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         Logger::log('Initializing stats (mem + ts)');
169 169
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
170 170
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
171
-        } else {
171
+        }else {
172 172
             $this->ts = $this->parser->getTs();
173 173
         }
174 174
         $this->mem = memory_get_usage();
Please login to merge, or discard this patch.
src/base/types/helpers/I18nHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $translations = array();
25 25
         if (file_exists($absoluteTranslationFileName)) {
26 26
             @include($absoluteTranslationFileName);
27
-        } else {
27
+        }else {
28 28
             Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
29 29
         }
30 30
 
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public static function setLocale() {
38 38
         $locale = Config::getParam("default_language", 'es_ES');
39
-        Logger::log('Set locale to project [' . $locale . ']');
39
+        Logger::log('Set locale to project ['.$locale.']');
40 40
         // Load translations
41
-        putenv("LC_ALL=" . $locale);
41
+        putenv("LC_ALL=".$locale);
42 42
         setlocale(LC_ALL, $locale);
43 43
         // Load the locale path
44
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
45
-        Logger::log('Set locale dir ' . $locale_path);
44
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
45
+        Logger::log('Set locale dir '.$locale_path);
46 46
         GeneratorHelper::createDir($locale_path);
47 47
         bindtextdomain('translations', $locale_path);
48 48
         textdomain('translations');
Please login to merge, or discard this patch.