@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | GeneratorHelper::createDir(dirname($path)); |
57 | 57 | if (false === FileHelper::writeFile($path, $data)) { |
58 | - throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ') . $path); |
|
58 | + throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ').$path); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | Inspector::stats('[Cache] Gathering data from cache', Inspector::SCOPE_DEBUG); |
71 | 71 | $data = null; |
72 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
72 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
73 | 73 | if (file_exists($absolutePath)) { |
74 | 74 | $data = FileHelper::readFile($absolutePath); |
75 | 75 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
86 | 86 | { |
87 | 87 | Inspector::stats('[Cache] Checking expiration', Inspector::SCOPE_DEBUG); |
88 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
88 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
89 | 89 | $lasModificationDate = filemtime($absolutePath); |
90 | 90 | return ($lasModificationDate + $expires <= time()); |
91 | 91 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | Inspector::stats('[Cache] Store data in cache', Inspector::SCOPE_DEBUG); |
154 | 154 | $data = self::transformData($data, $transform); |
155 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
155 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
156 | 156 | $this->saveTextToFile($data, $absolutePath); |
157 | 157 | } |
158 | 158 | |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | public function readFromCache($path, $expires = 300, $function = null, $transform = Cache::TEXT) |
169 | 169 | { |
170 | 170 | $data = null; |
171 | - Inspector::stats('[Cache] Reading data from cache: ' . json_encode(['path' => $path]), Inspector::SCOPE_DEBUG); |
|
172 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
171 | + Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]), Inspector::SCOPE_DEBUG); |
|
172 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
173 | 173 | if (is_callable($function) && $this->hasExpiredCache($path, $expires)) { |
174 | 174 | $data = $function(); |
175 | 175 | $this->storeData($path, $data, $transform, false, $expires); |
176 | - } else { |
|
176 | + }else { |
|
177 | 177 | $data = $this->getDataFromFile($path, $transform); |
178 | 178 | } |
179 | 179 | } |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | $query[Api::HEADER_API_LANG] = Request::header(Api::HEADER_API_LANG, 'es'); |
220 | 220 | $filename = FileHelper::generateHashFilename($action['http'], $action['slug'], $query); |
221 | 221 | $hashPath = FileHelper::generateCachePath($action, $query); |
222 | - Inspector::stats('[Cache] Cache file calculated: ' . json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG); |
|
222 | + Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG); |
|
223 | 223 | Logger::log('Cache file calculated', LOG_DEBUG, ['file' => $filename, 'hash' => $hashPath]); |
224 | 224 | } |
225 | 225 | return [$hashPath, $filename]; |
226 | 226 | } |
227 | 227 | |
228 | 228 | public function flushCache() { |
229 | - if(Config::getParam('cache.data.enable', false)) { |
|
229 | + if (Config::getParam('cache.data.enable', false)) { |
|
230 | 230 | Inspector::stats('[Cache] Flushing cache', Inspector::SCOPE_DEBUG); |
231 | 231 | $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR); |
232 | - if(is_array($action)) { |
|
233 | - $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
234 | - if(!file_exists($hashPath)) { |
|
235 | - $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath; |
|
232 | + if (is_array($action)) { |
|
233 | + $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
234 | + if (!file_exists($hashPath)) { |
|
235 | + $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath; |
|
236 | 236 | } |
237 | 237 | FileHelper::deleteDir($hashPath); |
238 | 238 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function init() |
87 | 87 | { |
88 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) { |
|
88 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) { |
|
89 | 89 | $this->loadConfigData(); |
90 | 90 | } |
91 | 91 | return $this; |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | $finalData = array_filter($finalData, function($key, $value) { |
202 | 202 | return in_array($key, self::$required, true) || !empty($value); |
203 | 203 | }, ARRAY_FILTER_USE_BOTH); |
204 | - $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
204 | + $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
205 | 205 | self::getInstance()->loadConfigData(); |
206 | 206 | $saved = true; |
207 | - } catch (ConfigException $e) { |
|
207 | + }catch (ConfigException $e) { |
|
208 | 208 | Logger::log($e->getMessage(), LOG_ERR); |
209 | 209 | } |
210 | 210 | return $saved; |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function loadConfigData() |
238 | 238 | { |
239 | - $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: []; |
|
239 | + $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: []; |
|
240 | 240 | $this->debug = array_key_exists('debug', $this->config) ? (bool)$this->config['debug'] : FALSE; |
241 | - if(array_key_exists('cache.var', $this->config)) { |
|
241 | + if (array_key_exists('cache.var', $this->config)) { |
|
242 | 242 | Security::getInstance()->setSessionKey('config.cache.var', $this->config['cache.var']); |
243 | 243 | } |
244 | 244 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public static function getParam($key, $defaultValue = null, $module = null) |
262 | 262 | { |
263 | - if(null !== $module) { |
|
264 | - return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue)); |
|
263 | + if (null !== $module) { |
|
264 | + return self::getParam(strtolower($module).'.'.$key, self::getParam($key, $defaultValue)); |
|
265 | 265 | } |
266 | 266 | $param = self::getInstance()->get($key); |
267 | 267 | return (null !== $param) ? $param : $defaultValue; |
@@ -11,7 +11,7 @@ |
||
11 | 11 | const TYPE_HTTP = 2; |
12 | 12 | |
13 | 13 | public static function parseRawData($type, $params) { |
14 | - switch($type) { |
|
14 | + switch ($type) { |
|
15 | 15 | default: |
16 | 16 | case self::TYPE_HTTP: |
17 | 17 | $parsedParams = http_build_query($params); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | { |
88 | 88 | $headers = []; |
89 | 89 | foreach ($this->getHeaders() as $key => $value) { |
90 | - $headers[] = $key . ': ' . $value; |
|
90 | + $headers[] = $key.': '.$value; |
|
91 | 91 | } |
92 | 92 | $headers[self::PSFS_TRACK_HEADER] = Logger::getUid(); |
93 | 93 | if (count($headers)) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | case Request::VERB_GET: |
118 | 118 | if (!empty($this->params)) { |
119 | 119 | $sep = false === strpos($this->getUrl(), '?') ? '?' : ''; |
120 | - $this->setUrl($this->getUrl() . $sep . http_build_query($this->getParams()), false); |
|
120 | + $this->setUrl($this->getUrl().$sep.http_build_query($this->getParams()), false); |
|
121 | 121 | } |
122 | 122 | break; |
123 | 123 | case Request::VERB_POST: |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | if ($this->isDebug() && is_resource($verbose)) { |
150 | 150 | $this->dumpVerboseLogs($verbose); |
151 | 151 | } |
152 | - Logger::log($this->getUrl() . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
152 | + Logger::log($this->getUrl().' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
153 | 153 | $this->info = array_merge($this->info, curl_getinfo($this->con)); |
154 | 154 | } |
155 | 155 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return ParameterTrait |
50 | 50 | */ |
51 | 51 | public function dropParam($key) { |
52 | - if(array_key_exists($key, $this->params)) { |
|
52 | + if (array_key_exists($key, $this->params)) { |
|
53 | 53 | unset($this->params[$key]); |
54 | 54 | } |
55 | 55 | return $this; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return mixed|null |
61 | 61 | */ |
62 | 62 | public function getParam($key) { |
63 | - if(array_key_exists($key, $this->params)) { |
|
63 | + if (array_key_exists($key, $this->params)) { |
|
64 | 64 | return $this->params[$key]; |
65 | 65 | } |
66 | 66 | return null; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return OptionTrait |
49 | 49 | */ |
50 | 50 | public function dropOption($key) { |
51 | - if(array_key_exists($key, $this->options)) { |
|
51 | + if (array_key_exists($key, $this->options)) { |
|
52 | 52 | unset($this->options[$key]); |
53 | 53 | } |
54 | 54 | return $this; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return mixed|null |
60 | 60 | */ |
61 | 61 | public function getOption($key) { |
62 | - if(array_key_exists($key, $this->options)) { |
|
62 | + if (array_key_exists($key, $this->options)) { |
|
63 | 63 | return $this->options[$key]; |
64 | 64 | } |
65 | 65 | return null; |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | protected $isMultipart = false; |
73 | 73 | |
74 | 74 | protected function closeConnection() { |
75 | - if(null !== $this->con) { |
|
76 | - if(is_resource($this->con)) { |
|
75 | + if (null !== $this->con) { |
|
76 | + if (is_resource($this->con)) { |
|
77 | 77 | curl_close($this->con); |
78 | - } else { |
|
78 | + }else { |
|
79 | 79 | $this->setCon(null); |
80 | 80 | } |
81 | 81 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->params = []; |
92 | 92 | $this->headers = []; |
93 | 93 | $this->debug = 'debug' === strtolower(Config::getParam('log.level', 'notice')); |
94 | - Logger::log('Context service for ' . static::class . ' cleared!'); |
|
94 | + Logger::log('Context service for '.static::class.' cleared!'); |
|
95 | 95 | $this->closeConnection(); |
96 | 96 | } |
97 | 97 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | $this->clearContext(); |
101 | 101 | $con = curl_init($this->url); |
102 | - if(is_resource($con)) { |
|
102 | + if (is_resource($con)) { |
|
103 | 103 | $this->setCon($con); |
104 | 104 | } |
105 | 105 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function setUrl($url, $cleanContext = true) |
120 | 120 | { |
121 | 121 | $this->url = $url; |
122 | - if($cleanContext) { |
|
122 | + if ($cleanContext) { |
|
123 | 123 | $this->initialize(); |
124 | 124 | } |
125 | 125 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function setIsJson($isJson = true) { |
186 | 186 | $this->isJson = $isJson; |
187 | - if($isJson) { |
|
187 | + if ($isJson) { |
|
188 | 188 | $this->setIsMultipart(false); |
189 | 189 | } |
190 | 190 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setIsMultipart($isMultipart = true) { |
203 | 203 | $this->isMultipart = $isMultipart; |
204 | - if($isMultipart) { |
|
204 | + if ($isMultipart) { |
|
205 | 205 | $this->setIsJson(false); |
206 | 206 | } |
207 | 207 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace PSFS\base\types\traits; |
3 | 3 | |
4 | -if(!defined('PSFS_BOOSTRAP_TRAT_LOADED')) { |
|
4 | +if (!defined('PSFS_BOOSTRAP_TRAT_LOADED')) { |
|
5 | 5 | /** |
6 | 6 | * Class BoostrapTrait |
7 | 7 | * @package PSFS\base\types |
@@ -10,5 +10,5 @@ discard block |
||
10 | 10 | { |
11 | 11 | } |
12 | 12 | define('PSFS_BOOSTRAP_TRAT_LOADED', true); |
13 | - require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php'; |
|
13 | + require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'bootstrap.php'; |
|
14 | 14 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | if (preg_match('/^asc$/i', $direction)) { |
64 | 64 | return self::ASC; |
65 | - } else { |
|
65 | + }else { |
|
66 | 66 | return self::DESC; |
67 | 67 | } |
68 | 68 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function fromArray(array $object = []) |
83 | 83 | { |
84 | - foreach($object as $field => $order) { |
|
84 | + foreach ($object as $field => $order) { |
|
85 | 85 | $this->addOrder($field, $order); |
86 | 86 | } |
87 | 87 | } |