@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | private function saveTextToFile($data, $path, $absolute = false) |
| 31 | 31 | { |
| 32 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 32 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 33 | 33 | $filename = basename($absolutePath); |
| 34 | 34 | Config::createDir(str_replace($filename, "", $absolutePath)); |
| 35 | 35 | if (false === file_put_contents($absolutePath, $data)) { |
| 36 | - throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $absolutePath); |
|
| 36 | + throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$absolutePath); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false) |
| 48 | 48 | { |
| 49 | 49 | $data = null; |
| 50 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 50 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 51 | 51 | if (file_exists($absolutePath)) { |
| 52 | 52 | $data = file_get_contents($absolutePath); |
| 53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
| 65 | 65 | { |
| 66 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 66 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 67 | 67 | $lasModificationDate = filemtime($absolutePath); |
| 68 | 68 | return ($lasModificationDate + $expires <= time()); |
| 69 | 69 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | break; |
| 87 | 87 | case Cache::GZIP: |
| 88 | 88 | // TODO implementar |
| 89 | - if(function_exists('gzuncompress')) { |
|
| 89 | + if (function_exists('gzuncompress')) { |
|
| 90 | 90 | $data = gzuncompress($data); |
| 91 | 91 | } |
| 92 | 92 | break; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $data = Cache::transformData($data, Cache::GZIP); |
| 112 | 112 | break; |
| 113 | 113 | case Cache::GZIP: |
| 114 | - if(function_exists('gzcompress')) { |
|
| 114 | + if (function_exists('gzcompress')) { |
|
| 115 | 115 | $data = gzcompress($data); |
| 116 | 116 | } |
| 117 | 117 | break; |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT) |
| 144 | 144 | { |
| 145 | 145 | $data = null; |
| 146 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
| 146 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
| 147 | 147 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
| 148 | 148 | $data = call_user_func($function); |
| 149 | 149 | $this->storeData($path, $data, $transform); |
| 150 | - } else { |
|
| 150 | + }else { |
|
| 151 | 151 | $data = $this->getDataFromFile($path, $transform); |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $hash = ""; |
| 178 | 178 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
| 179 | 179 | if (null !== $action && $action["cache"] > 0) { |
| 180 | - $hash = $action["http"] . " " . $action["slug"]; |
|
| 180 | + $hash = $action["http"]." ".$action["slug"]; |
|
| 181 | 181 | } |
| 182 | 182 | return sha1($hash); |
| 183 | 183 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * Método que guarda en fichero los datos pasados |
| 124 | - * @param $path |
|
| 124 | + * @param string $path |
|
| 125 | 125 | * @param $data |
| 126 | 126 | * @param int $transform |
| 127 | 127 | * @param boolean $absolutePath |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Método estático que revisa si se necesita cachear la respuesta de un servicio o no |
| 159 | - * @return integer|boolean |
|
| 159 | + * @return integer |
|
| 160 | 160 | */ |
| 161 | 161 | public static function needCache() |
| 162 | 162 | { |