@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * Add request param |
118 | 118 | * |
119 | - * @param $key |
|
119 | + * @param integer $key |
|
120 | 120 | * @param null $value |
121 | 121 | * |
122 | 122 | * @return \PSFS\base\Service |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | - * @param $header |
|
157 | - * @param null $content |
|
156 | + * @param string $header |
|
157 | + * @param string $content |
|
158 | 158 | * |
159 | 159 | * @return $this |
160 | 160 | */ |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | protected $isJson = true; |
60 | 60 | |
61 | 61 | private function closeConnection() { |
62 | - if(null !== $this->con) { |
|
62 | + if (null !== $this->con) { |
|
63 | 63 | curl_close($this->con); |
64 | 64 | } |
65 | 65 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $this->url = NULL; |
240 | 240 | $this->params = array(); |
241 | 241 | $this->headers = array(); |
242 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
242 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
243 | 243 | $this->closeConnection(); |
244 | 244 | } |
245 | 245 | |
@@ -282,17 +282,17 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | protected function applyOptions() { |
285 | - if(count($this->options)) { |
|
285 | + if (count($this->options)) { |
|
286 | 286 | curl_setopt_array($this->con, $this->options); |
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | 290 | protected function applyHeaders() { |
291 | 291 | $headers = []; |
292 | - foreach($this->headers as $key => $value) { |
|
293 | - $headers[] = $key . ': ' . $value; |
|
292 | + foreach ($this->headers as $key => $value) { |
|
293 | + $headers[] = $key.': '.$value; |
|
294 | 294 | } |
295 | - if(count($headers)) { |
|
295 | + if (count($headers)) { |
|
296 | 296 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
297 | 297 | } |
298 | 298 | } |
@@ -303,16 +303,16 @@ discard block |
||
303 | 303 | case 'GET': |
304 | 304 | default: |
305 | 305 | $this->addOption(CURLOPT_CUSTOMREQUEST, "GET"); |
306 | - if(!empty($this->params)) { |
|
306 | + if (!empty($this->params)) { |
|
307 | 307 | $sep = !preg_match('/\?/', $this->getUrl()) ? '?' : ''; |
308 | - $this->url = $this->url . $sep . http_build_query($this->params); |
|
308 | + $this->url = $this->url.$sep.http_build_query($this->params); |
|
309 | 309 | } |
310 | 310 | break; |
311 | 311 | case 'POST': |
312 | 312 | $this->addOption(CURLOPT_CUSTOMREQUEST, "POST"); |
313 | - if($this->getIsJson()) { |
|
313 | + if ($this->getIsJson()) { |
|
314 | 314 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
315 | - } else { |
|
315 | + }else { |
|
316 | 316 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
317 | 317 | } |
318 | 318 | break; |
@@ -322,17 +322,17 @@ discard block |
||
322 | 322 | case 'PUT': |
323 | 323 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PUT"); |
324 | 324 | |
325 | - if($this->getIsJson()) { |
|
325 | + if ($this->getIsJson()) { |
|
326 | 326 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
327 | - } else { |
|
327 | + }else { |
|
328 | 328 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
329 | 329 | } |
330 | 330 | break; |
331 | 331 | case 'PATCH': |
332 | 332 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
333 | - if($this->getIsJson()) { |
|
333 | + if ($this->getIsJson()) { |
|
334 | 334 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
335 | - } else { |
|
335 | + }else { |
|
336 | 336 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
337 | 337 | } |
338 | 338 | break; |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | $this->setDefaults(); |
350 | 350 | $this->applyOptions(); |
351 | 351 | $this->applyHeaders(); |
352 | - if('debug' === Config::getParam('log.level')) { |
|
352 | + if ('debug' === Config::getParam('log.level')) { |
|
353 | 353 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
354 | 354 | $verbose = fopen('php://temp', 'w+'); |
355 | 355 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
356 | 356 | } |
357 | 357 | $result = curl_exec($this->con); |
358 | 358 | $this->result = $this->isJson ? json_decode($result, true) : $result; |
359 | - if('debug' === Config::getParam('log.level')) { |
|
359 | + if ('debug' === Config::getParam('log.level')) { |
|
360 | 360 | rewind($verbose); |
361 | 361 | $verboseLog = stream_get_contents($verbose); |
362 | 362 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | 'url' => $this->getUrl(), |
366 | 366 | ]); |
367 | 367 | } |
368 | - Logger::log($this->url . ' response: ', LOG_DEBUG, $this->result); |
|
368 | + Logger::log($this->url.' response: ', LOG_DEBUG, $this->result); |
|
369 | 369 | $this->info = curl_getinfo($this->con); |
370 | 370 | } |
371 | 371 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | if (!Config::getInstance()->checkTryToSaveConfig() |
30 | 30 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted')) |
31 | 31 | ) { |
32 | - if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) { |
|
32 | + if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) { |
|
33 | 33 | throw new AdminCredentialsException(); |
34 | 34 | } |
35 | 35 | if (!Security::getInstance()->checkAdmin()) { |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | $token = ''; |
50 | 50 | $ct = strlen($ts); |
51 | 51 | for ($i = 0; $i < $ct; $i++) { |
52 | - $token = substr($hash, $i, 1) . |
|
53 | - substr($ts, $i, 1) . |
|
52 | + $token = substr($hash, $i, 1). |
|
53 | + substr($ts, $i, 1). |
|
54 | 54 | $token; |
55 | 55 | } |
56 | 56 | return $token; |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | $charsLength = strlen(self::RAND_SEP) - 1; |
69 | 69 | $tsLength = strlen($ts); |
70 | 70 | $i = 0; |
71 | - $ct = ceil($hashRest / 4); |
|
72 | - $part = substr($hash, $tsLength + $ct * $i, $ct); |
|
73 | - while(false !== $part) { |
|
74 | - $mixedToken .= $part . |
|
75 | - substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) . |
|
71 | + $ct = ceil($hashRest/4); |
|
72 | + $part = substr($hash, $tsLength + $ct*$i, $ct); |
|
73 | + while (false !== $part) { |
|
74 | + $mixedToken .= $part. |
|
75 | + substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1). |
|
76 | 76 | substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1); |
77 | - $part = substr($hash, $tsLength + $ct * $i, $ct); |
|
77 | + $part = substr($hash, $tsLength + $ct*$i, $ct); |
|
78 | 78 | $i++; |
79 | 79 | } |
80 | - return $mixedToken . $token; |
|
80 | + return $mixedToken.$token; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private static function getTs($isOdd = null) { |
88 | 88 | $ts = time(); |
89 | - $tsIsOdd = (bool)((int)substr($ts, -1) % 2); |
|
90 | - if(false === $isOdd && !$tsIsOdd) { |
|
89 | + $tsIsOdd = (bool)((int)substr($ts, -1)%2); |
|
90 | + if (false === $isOdd && !$tsIsOdd) { |
|
91 | 91 | $ts--; |
92 | - } elseif(true === $isOdd && !$tsIsOdd) { |
|
92 | + } elseif (true === $isOdd && !$tsIsOdd) { |
|
93 | 93 | $ts--; |
94 | 94 | } |
95 | 95 | return $ts; |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | $partToken = ''; |
122 | 122 | $ts = ''; |
123 | 123 | $part = strrev($part); |
124 | - for($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
|
125 | - if($i % 2 == 0) { |
|
124 | + for ($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
|
125 | + if ($i%2 == 0) { |
|
126 | 126 | $ts .= substr($part, $i, 1); |
127 | - } else { |
|
127 | + }else { |
|
128 | 128 | $partToken .= substr($part, $i, 1); |
129 | 129 | } |
130 | 130 | } |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | private static function parseTokenParts(array $parts) { |
140 | 140 | $token = ''; |
141 | 141 | list($partToken, $ts) = self::extractTs(array_pop($parts)); |
142 | - if($ts > 0) { |
|
143 | - foreach($parts as $part) { |
|
142 | + if ($ts > 0) { |
|
143 | + foreach ($parts as $part) { |
|
144 | 144 | $token .= $part; |
145 | 145 | } |
146 | - $token = $partToken . $token; |
|
146 | + $token = $partToken.$token; |
|
147 | 147 | } |
148 | 148 | return [$token, $ts]; |
149 | 149 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @return array |
172 | 172 | */ |
173 | 173 | private static function extractTokenParts($token) { |
174 | - for($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) { |
|
175 | - $token = str_replace(substr(self::RAND_SEP,$i,1), "|", $token); |
|
174 | + for ($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) { |
|
175 | + $token = str_replace(substr(self::RAND_SEP, $i, 1), "|", $token); |
|
176 | 176 | } |
177 | 177 | return array_unique(explode('||', $token)); |
178 | 178 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $routes = []; |
33 | 33 | foreach ($systemRoutes as $route => $params) { |
34 | - if(isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
34 | + if (isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
35 | 35 | $module = strtoupper($params['module']); |
36 | 36 | $mode = $params["visible"] ? 'visible' : 'hidden'; |
37 | 37 | $routes[$module][$mode][] = [ |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | ]; |
42 | 42 | } |
43 | 43 | } |
44 | - foreach($routes as $module => &$route) { |
|
45 | - if(array_key_exists('visible', $route)) { |
|
44 | + foreach ($routes as $module => &$route) { |
|
45 | + if (array_key_exists('visible', $route)) { |
|
46 | 46 | uasort($route["visible"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
47 | 47 | } |
48 | - if(array_key_exists('hidden', $route)) { |
|
48 | + if (array_key_exists('hidden', $route)) { |
|
49 | 49 | uasort($route["hidden"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
50 | 50 | } |
51 | 51 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $objects = scandir($dir); |
20 | 20 | foreach ($objects as $object) { |
21 | 21 | if ($object != "." && $object != "..") { |
22 | - if (filetype($dir . "/" . $object) == "dir") { |
|
23 | - self::deleteDir($dir . "/" . $object); |
|
24 | - } else { |
|
25 | - unlink($dir . "/" . $object); |
|
22 | + if (filetype($dir."/".$object) == "dir") { |
|
23 | + self::deleteDir($dir."/".$object); |
|
24 | + }else { |
|
25 | + unlink($dir."/".$object); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | { |
39 | 39 | $rootDirs = array("css", "js", "media", "font"); |
40 | 40 | foreach ($rootDirs as $dir) { |
41 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
41 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
42 | 42 | try { |
43 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
44 | - } catch (\Exception $e) { |
|
43 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
44 | + }catch (\Exception $e) { |
|
45 | 45 | Logger::log($e->getMessage()); |
46 | 46 | } |
47 | 47 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | { |
58 | 58 | try { |
59 | 59 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
60 | - throw new \Exception(_('Can\'t create directory ') . $dir); |
|
60 | + throw new \Exception(_('Can\'t create directory ').$dir); |
|
61 | 61 | } |
62 | - } catch (\Exception $e) { |
|
62 | + }catch (\Exception $e) { |
|
63 | 63 | Logger::log($e->getMessage(), LOG_WARNING); |
64 | 64 | if (!file_exists(dirname($dir))) { |
65 | - throw new GeneratorException($e->getMessage() . $dir); |
|
65 | + throw new GeneratorException($e->getMessage().$dir); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function getTemplatePath() |
75 | 75 | { |
76 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
76 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
77 | 77 | return realpath($path); |
78 | 78 | } |
79 | 79 | |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | * @throws GeneratorException |
92 | 92 | */ |
93 | 93 | public static function checkCustomNamespaceApi($namespace) { |
94 | - if(!empty($namespace)) { |
|
95 | - if(class_exists($namespace)) { |
|
94 | + if (!empty($namespace)) { |
|
95 | + if (class_exists($namespace)) { |
|
96 | 96 | $reflector = new \ReflectionClass($namespace); |
97 | - if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
97 | + if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
98 | 98 | throw new GeneratorException(_('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501); |
99 | - } elseif(!$reflector->isAbstract()) { |
|
99 | + } elseif (!$reflector->isAbstract()) { |
|
100 | 100 | throw new GeneratorException(_('La clase definida debe ser abstracta'), 501); |
101 | 101 | } |
102 | - } else { |
|
102 | + }else { |
|
103 | 103 | throw new GeneratorException(_('La clase definida para extender la API no existe'), 501); |
104 | 104 | } |
105 | 105 | } |
@@ -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 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | GeneratorHelper::createDir(dirname($path)); |
52 | 52 | if (false === FileHelper::writeFile($path, $data)) { |
53 | - throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path); |
|
53 | + throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]); |
67 | 67 | $data = null; |
68 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
68 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
69 | 69 | if (file_exists($absolutePath)) { |
70 | 70 | $data = FileHelper::readFile($absolutePath); |
71 | 71 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
83 | 83 | { |
84 | 84 | Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]); |
85 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
85 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
86 | 86 | $lasModificationDate = filemtime($absolutePath); |
87 | 87 | return ($lasModificationDate + $expires <= time()); |
88 | 88 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]); |
153 | 153 | $data = Cache::transformData($data, $transform); |
154 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
154 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
155 | 155 | $this->saveTextToFile($data, $absolutePath); |
156 | 156 | } |
157 | 157 | |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | { |
168 | 168 | $data = null; |
169 | 169 | Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]); |
170 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
170 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
171 | 171 | if (is_callable($function) && $this->hasExpiredCache($path, $expires)) { |
172 | 172 | $data = call_user_func($function); |
173 | 173 | $this->storeData($path, $data, $transform, false, $expires); |
174 | - } else { |
|
174 | + }else { |
|
175 | 175 | $data = $this->getDataFromFile($path, $transform); |
176 | 176 | } |
177 | 177 | } |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | * Flush cache when save a registry |
229 | 229 | */ |
230 | 230 | public function flushCache() { |
231 | - if(Config::getParam('cache.data.enable', false)) { |
|
231 | + if (Config::getParam('cache.data.enable', false)) { |
|
232 | 232 | Logger::log('Flushing cache', LOG_DEBUG); |
233 | 233 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
234 | - $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
235 | - if(!file_exists($hashPath)) { |
|
236 | - $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath; |
|
234 | + $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
235 | + if (!file_exists($hashPath)) { |
|
236 | + $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath; |
|
237 | 237 | } |
238 | 238 | FileHelper::deleteDir($hashPath); |
239 | 239 | } |
@@ -121,9 +121,11 @@ |
||
121 | 121 | $cacheService->storeData($cacheFilename, $properties, $cache); |
122 | 122 | } |
123 | 123 | /** @var \ReflectionProperty $property */ |
124 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
124 | + if (!empty($properties) && is_array($properties)) { |
|
125 | + foreach ($properties as $property => $class) { |
|
125 | 126 | $this->load($property, true, $class); |
126 | 127 | } |
128 | + } |
|
127 | 129 | $this->setLoaded(); |
128 | 130 | } else { |
129 | 131 | Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct() |
17 | 17 | { |
18 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
18 | + Logger::log(get_class($this).' constructor invoked'); |
|
19 | 19 | $this->init(); |
20 | 20 | } |
21 | 21 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $calledClass = get_called_class(); |
69 | 69 | try { |
70 | 70 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
71 | - $setter = "set" . ucfirst($variable); |
|
71 | + $setter = "set".ucfirst($variable); |
|
72 | 72 | if (method_exists($calledClass, $setter)) { |
73 | 73 | $this->$setter($instance); |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | $this->$variable = $instance; |
76 | 76 | } |
77 | - } catch (\Exception $e) { |
|
78 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
77 | + }catch (\Exception $e) { |
|
78 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
79 | 79 | throw $e; |
80 | 80 | } |
81 | 81 | return $this; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | if (!$this->isLoaded()) { |
90 | 90 | $filename = sha1(get_class($this)); |
91 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json"; |
|
91 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json"; |
|
92 | 92 | /** @var \PSFS\base\Cache $cacheService */ |
93 | 93 | $cacheService = Cache::getInstance(); |
94 | 94 | /** @var \PSFS\base\config\Config $configService */ |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | $this->load($property, true, $class); |
105 | 105 | } |
106 | 106 | $this->setLoaded(); |
107 | - } else { |
|
108 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
107 | + }else { |
|
108 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -17,11 +17,11 @@ |
||
17 | 17 | public static function checkApiActions($namespace, $domain, $api) { |
18 | 18 | $actions = []; |
19 | 19 | $reflector = new \ReflectionClass($namespace); |
20 | - if(null !== $reflector) { |
|
21 | - foreach($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
20 | + if (null !== $reflector) { |
|
21 | + foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
22 | 22 | $docComments = $apiAction->getDocComment(); |
23 | 23 | $action = self::extractAction($docComments); |
24 | - if(null !== $action) { |
|
24 | + if (null !== $action) { |
|
25 | 25 | list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain); |
26 | 26 | list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route); |
27 | 27 | $formAction = new FormAction(); |
@@ -31,9 +31,10 @@ |
||
31 | 31 | function getallheaders() |
32 | 32 | { |
33 | 33 | $headers = array(); |
34 | - foreach ($_SERVER as $h => $v) |
|
35 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
34 | + foreach ($_SERVER as $h => $v) { |
|
35 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
36 | 36 | $headers[$hp[1]] = $v; |
37 | + } |
|
37 | 38 | return $headers; |
38 | 39 | } |
39 | 40 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | /* @var $file SplFileInfo */ |
47 | 47 | foreach ($finder as $file) { |
48 | 48 | $path = $file->getRealPath(); |
49 | - if(!in_array($path, $loaded_files)) { |
|
49 | + if (!in_array($path, $loaded_files)) { |
|
50 | 50 | $loaded_files[] = $path; |
51 | 51 | require_once($path); |
52 | 52 | } |
@@ -7,4 +7,4 @@ |
||
7 | 7 | */ |
8 | 8 | Trait BoostrapTrait {} |
9 | 9 | |
10 | -require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php'; |
|
11 | 10 | \ No newline at end of file |
11 | +require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'bootstrap.php'; |
|
12 | 12 | \ No newline at end of file |