1 | <?php |
||
14 | class Cache |
||
15 | { |
||
16 | |||
17 | const JSON = 1; |
||
18 | const TEXT = 2; |
||
19 | const GZIP = 3; |
||
20 | const JSONGZ = 4; |
||
21 | |||
22 | use SingletonTrait; |
||
23 | |||
24 | /** |
||
25 | * Método que guarda un text en un fichero |
||
26 | * @param string $data |
||
27 | * @param string $path |
||
28 | * @param boolean $absolute |
||
29 | * @throws ConfigException |
||
30 | 6 | */ |
|
31 | private function saveTextToFile($data, $path, $absolute = false) |
||
41 | |||
42 | /** |
||
43 | * Método que extrae el texto de un fichero |
||
44 | * @param string $path |
||
45 | * @param int $transform |
||
46 | * @param boolean $absolute |
||
47 | * @return mixed |
||
|
|||
48 | 6 | */ |
|
49 | public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false) |
||
58 | |||
59 | /** |
||
60 | * Método que verifica si un fichero tiene la cache expirada |
||
61 | * @param string $path |
||
62 | * @param int $expires |
||
63 | * @param boolean $absolute |
||
64 | * @return bool |
||
65 | 1 | */ |
|
66 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
||
72 | |||
73 | /** |
||
74 | * Método que transforma los datos de salida |
||
75 | * @param string $data |
||
76 | * @param int $transform |
||
77 | * @return array|string|null |
||
78 | 6 | */ |
|
79 | public static function extractDataWithFormat($data, $transform = Cache::TEXT) |
||
98 | |||
99 | /** |
||
100 | * Método que transforma los datos de entrada del fichero |
||
101 | * @param string $data |
||
102 | * @param int $transform |
||
103 | * @return string |
||
104 | 6 | */ |
|
105 | public static function transformData($data, $transform = Cache::TEXT) |
||
123 | |||
124 | /** |
||
125 | * Método que guarda en fichero los datos pasados |
||
126 | * @param $path |
||
127 | * @param $data |
||
128 | * @param int $transform |
||
129 | * @param boolean $absolutePath |
||
130 | 6 | */ |
|
131 | public function storeData($path, $data, $transform = Cache::TEXT, $absolutePath = false) |
||
136 | |||
137 | /** |
||
138 | * Método que verifica si tiene que leer o no un fichero de cache |
||
139 | * @param string $path |
||
140 | * @param int $expires |
||
141 | * @param callable $function |
||
142 | * @param int $transform |
||
143 | * @return mixed |
||
144 | 1 | */ |
|
145 | public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT) |
||
158 | |||
159 | /** |
||
160 | * @return bool |
||
161 | */ |
||
162 | 1 | private function checkAdminSite() { |
|
171 | |||
172 | /** |
||
173 | * Método estático que revisa si se necesita cachear la respuesta de un servicio o no |
||
174 | * @return integer|boolean |
||
175 | */ |
||
176 | 1 | public static function needCache() |
|
187 | |||
188 | /** |
||
189 | * Método que construye un hash para almacenar la cache |
||
190 | * @return string |
||
191 | */ |
||
192 | public function getRequestCacheHash() |
||
201 | } |
||
202 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.