@@ -146,7 +146,7 @@ discard block |
||
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 |
||
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 | { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | GeneratorHelper::createDir(dirname($path)); |
46 | 46 | if (false === file_put_contents($path, $data)) { |
47 | - throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path); |
|
47 | + throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false) |
59 | 59 | { |
60 | 60 | $data = null; |
61 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
61 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
62 | 62 | if (file_exists($absolutePath)) { |
63 | 63 | $data = file_get_contents($absolutePath); |
64 | 64 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
76 | 76 | { |
77 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
77 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
78 | 78 | $lasModificationDate = filemtime($absolutePath); |
79 | 79 | return ($lasModificationDate + $expires <= time()); |
80 | 80 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | public function storeData($path, $data, $transform = Cache::TEXT, $absolute = false, $expires = 600) |
141 | 141 | { |
142 | 142 | $data = Cache::transformData($data, $transform); |
143 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
143 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
144 | 144 | $this->saveTextToFile($data, $absolutePath); |
145 | 145 | } |
146 | 146 | |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT) |
156 | 156 | { |
157 | 157 | $data = null; |
158 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
158 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
159 | 159 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
160 | 160 | $data = call_user_func($function); |
161 | 161 | $this->storeData($path, $data, $transform, false, $expires); |
162 | - } else { |
|
162 | + }else { |
|
163 | 163 | $data = $this->getDataFromFile($path, $transform); |
164 | 164 | } |
165 | 165 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $hash = ""; |
206 | 206 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
207 | 207 | if (null !== $action && $action["cache"] > 0) { |
208 | - $hash = $action["http"] . " " . $action["slug"]; |
|
208 | + $hash = $action["http"]." ".$action["slug"]; |
|
209 | 209 | } |
210 | 210 | return sha1($hash); |
211 | 211 | } |
@@ -3,7 +3,6 @@ |
||
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; |
@@ -74,7 +74,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -232,7 +232,7 @@ |
||
232 | 232 | /** |
233 | 233 | * Static wrapper for extracting params |
234 | 234 | * @param string $key |
235 | - * @param mixed|null $defaultValue |
|
235 | + * @param string|boolean $defaultValue |
|
236 | 236 | * @return mixed|null |
237 | 237 | */ |
238 | 238 | public static function getParam($key, $defaultValue = null) |
@@ -78,16 +78,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -24,7 +24,7 @@ discard block |
||
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 |
||
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'); |