Passed
Push — master ( 303f89...eaed60 )
by Fran
12:51 queued 11s
created
src/base/Cache.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@
 block discarded – undo
188 188
     }
189 189
 
190 190
     /**
191
-     * @return integer|boolean
191
+     * @return integer
192 192
      */
193 193
     public static function needCache()
194 194
     {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         GeneratorHelper::createDir(dirname($path));
56 56
         if (false === FileHelper::writeFile($path, $data)) {
57
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
57
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
58 58
         }
59 59
     }
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]);
70 70
         $data = null;
71
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
71
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
72 72
         if (file_exists($absolutePath)) {
73 73
             $data = FileHelper::readFile($absolutePath);
74 74
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
85 85
     {
86 86
         Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]);
87
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
87
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
88 88
         $lasModificationDate = filemtime($absolutePath);
89 89
         return ($lasModificationDate + $expires <= time());
90 90
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]);
153 153
         $data = self::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
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $data = null;
170 170
         Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]);
171
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
172 172
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
173 173
                 $data = $function();
174 174
                 $this->storeData($path, $data, $transform, false, $expires);
175
-            } else {
175
+            }else {
176 176
                 $data = $this->getDataFromFile($path, $transform);
177 177
             }
178 178
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     public function flushCache() {
227
-        if(Config::getParam('cache.data.enable', false)) {
227
+        if (Config::getParam('cache.data.enable', false)) {
228 228
             Logger::log('Flushing cache', LOG_DEBUG);
229 229
             $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR);
230
-            if(is_array($action)) {
231
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
232
-                if(!file_exists($hashPath)) {
233
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
230
+            if (is_array($action)) {
231
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
232
+                if (!file_exists($hashPath)) {
233
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
234 234
                 }
235 235
                 FileHelper::deleteDir($hashPath);
236 236
             }
Please login to merge, or discard this patch.
src/base/Logger.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      * @param string $msg
86 86
      * @param array $context
87 87
      *
88
-     * @return bool
88
+     * @return boolean|null
89 89
      */
90 90
     public function debugLog($msg = '', array $context = [])
91 91
     {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     }
94 94
 
95 95
     /**
96
-     * @param $msg
96
+     * @param string $msg
97 97
      * @param array $context
98 98
      *
99 99
      * @return bool
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
     /**
107
-     * @param $msg
107
+     * @param string $msg
108 108
      * @param array $context
109 109
      * @return bool
110 110
      */
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 
17 17
 if (!defined('LOG_DIR')) {
18
-    GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
19
-    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
18
+    GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs');
19
+    define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
20 20
 }
21 21
 
22 22
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $config = Config::getInstance();
51 51
         $args = func_get_args();
52 52
         list($logger, $debug, $path) = $this->setup($config, $args);
53
-        $this->stream = fopen($path . DIRECTORY_SEPARATOR . date('Ymd') . '.log', 'a+');
53
+        $this->stream = fopen($path.DIRECTORY_SEPARATOR.date('Ymd').'.log', 'a+');
54 54
         $this->addPushLogger($logger, $debug, $config);
55 55
         $this->log_level = Config::getParam('log.level', 'info');
56 56
     }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     private function createLoggerPath(Config $config)
192 192
     {
193 193
         $logger = $this->setLoggerName($config);
194
-        $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m');
194
+        $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m');
195 195
         GeneratorHelper::createDir($path);
196 196
 
197 197
         return $path;
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public static function log($msg, $type = LOG_DEBUG, array $context = null)
206 206
     {
207
-        if(null === $context) {
207
+        if (null === $context) {
208 208
             $context = [];
209 209
         }
210
-        if(Config::getParam('profiling.enable')) {
210
+        if (Config::getParam('profiling.enable')) {
211 211
             Inspector::stats($msg);
212 212
         }
213 213
         switch ($type) {
Please login to merge, or discard this patch.
src/base/Router.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     }
180 180
 
181 181
     /**
182
-     * @param $route
182
+     * @param string|null $route
183 183
      * @throws AccessDeniedException
184 184
      * @throws AdminCredentialsException
185 185
      * @throws RouterException
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     /**
536 536
      * @param bool $hydrateRoute
537 537
      * @param $modulePath
538
-     * @param $externalModulePath
538
+     * @param string $externalModulePath
539 539
      */
540 540
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath)
541 541
     {
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     }
551 551
 
552 552
     /**
553
-     * @param $hydrateRoute
553
+     * @param boolean $hydrateRoute
554 554
      * @param $module
555 555
      * @return mixed
556 556
      */
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function init()
77 77
     {
78
-        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE);
78
+        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE);
79 79
         if (empty($this->routing) || Config::getInstance()->getDebugMode()) {
80 80
             $this->debugLoad();
81
-        } else {
82
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE);
81
+        }else {
82
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE);
83 83
         }
84 84
         $this->checkExternalModules(false);
85 85
         $this->setLoaded();
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
         }
118 118
 
119 119
         $not_found_route = Config::getParam('route.404');
120
-        if(null !== $not_found_route) {
120
+        if (null !== $not_found_route) {
121 121
             Request::getInstance()->redirect($this->getRoute($not_found_route, true));
122
-        } else {
122
+        }else {
123 123
             return $template->render('error.html.twig', array(
124 124
                 'exception' => $e,
125 125
                 'trace' => $e->getTraceAsString(),
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
         try {
171 171
             //Search action and execute
172 172
             $this->searchAction($route);
173
-        } catch (AccessDeniedException $e) {
174
-            Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
173
+        }catch (AccessDeniedException $e) {
174
+            Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']);
175 175
             return Admin::staticAdminLogon($route);
176
-        } catch (RouterException $r) {
176
+        }catch (RouterException $r) {
177 177
             Logger::log($r->getMessage(), LOG_WARNING);
178
-        } catch (\Exception $e) {
178
+        }catch (\Exception $e) {
179 179
             Logger::log($e->getMessage(), LOG_ERR);
180 180
             throw $e;
181 181
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function searchAction($route)
194 194
     {
195
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
195
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
196 196
         //Revisamos si tenemos la ruta registrada
197 197
         $parts = parse_url($route);
198 198
         $path = array_key_exists('path', $parts) ? $parts['path'] : $route;
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
                 /** @var $class \PSFS\base\types\Controller */
208 208
                 $class = RouterHelper::getClassToCall($action);
209 209
                 try {
210
-                    if($this->checkRequirements($action, $get)) {
210
+                    if ($this->checkRequirements($action, $get)) {
211 211
                         $this->executeCachedRoute($route, $action, $class, $get);
212
-                    } else {
212
+                    }else {
213 213
                         throw new RouterException(_('La ruta no es válida'), 400);
214 214
                     }
215
-                } catch (\Exception $e) {
215
+                }catch (\Exception $e) {
216 216
                     Logger::log($e->getMessage(), LOG_ERR);
217 217
                     throw $e;
218 218
                 }
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
      * @return bool
228 228
      */
229 229
     private function checkRequirements(array $action, $params = []) {
230
-        if(!empty($params) && !empty($action['requirements'])) {
230
+        if (!empty($params) && !empty($action['requirements'])) {
231 231
             $checked = 0;
232
-            foreach(array_keys($params) as $key) {
233
-                if(in_array($key, $action['requirements'], true)) {
232
+            foreach (array_keys($params) as $key) {
233
+                if (in_array($key, $action['requirements'], true)) {
234 234
                     $checked++;
235 235
                 }
236 236
             }
237 237
             $valid = count($action['requirements']) === $checked;
238
-        } else {
238
+        }else {
239 239
             $valid = true;
240 240
         }
241 241
         return $valid;
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $this->checkExternalModules();
286 286
         if (file_exists($modulesPath)) {
287 287
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
288
-            if($modules->hasResults()) {
288
+            if ($modules->hasResults()) {
289 289
                 foreach ($modules->getIterator() as $modulePath) {
290 290
                     $module = $modulePath->getBasename();
291
-                    $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
291
+                    $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
292 292
                 }
293 293
             }
294 294
         }
295
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE);
295
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE);
296 296
     }
297 297
 
298 298
     /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             $home_params = NULL;
309 309
             foreach ($this->routing as $pattern => $params) {
310 310
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
311
-                if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) {
311
+                if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) {
312 312
                     $home_params = $params;
313 313
                 }
314 314
             }
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
     private function inspectDir($origen, $namespace = 'PSFS', $routing = [])
330 330
     {
331 331
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php');
332
-        if($files->hasResults()) {
332
+        if ($files->hasResults()) {
333 333
             foreach ($files->getIterator() as $file) {
334
-                if(method_exists($file, 'getRelativePathname') && $namespace !== 'PSFS') {
335
-                    $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
336
-                } else {
334
+                if (method_exists($file, 'getRelativePathname') && $namespace !== 'PSFS') {
335
+                    $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
336
+                }else {
337 337
                     $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname()));
338 338
                 }
339
-                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
339
+                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
340 340
             }
341 341
         }
342 342
         $this->finder = new Finder();
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     private function addRouting($namespace, &$routing, $module = 'PSFS')
366 366
     {
367 367
         if (self::exists($namespace)) {
368
-            if(I18nHelper::checkI18Class($namespace)) {
368
+            if (I18nHelper::checkI18Class($namespace)) {
369 369
                 return $routing;
370 370
             }
371 371
             $reflection = new \ReflectionClass($namespace);
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
             if (!$this->domains) {
408 408
                 $this->domains = [];
409 409
             }
410
-            $domain = '@' . $class->getConstant('DOMAIN') . '/';
410
+            $domain = '@'.$class->getConstant('DOMAIN').'/';
411 411
             if (!array_key_exists($domain, $this->domains)) {
412 412
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
413 413
             }
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
      */
424 424
     public function simpatize()
425 425
     {
426
-        $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php';
427
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
426
+        $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php';
427
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
428 428
         $this->generateSlugs($absoluteTranslationFileName);
429 429
         GeneratorHelper::createDir(CONFIG_DIR);
430
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
430
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
431 431
 
432 432
         return $this;
433 433
     }
@@ -443,18 +443,18 @@  discard block
 block discarded – undo
443 443
     public function getRoute($slug = '', $absolute = FALSE, array $params = [])
444 444
     {
445 445
         if ('' === $slug) {
446
-            return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/';
446
+            return $absolute ? Request::getInstance()->getRootUrl().'/' : '/';
447 447
         }
448 448
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
449 449
             throw new RouterException(_('No existe la ruta especificada'));
450 450
         }
451
-        $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
451
+        $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
452 452
         if (!empty($params)) {
453 453
             foreach ($params as $key => $value) {
454
-                $url = str_replace('{' . $key . '}', $value, $url);
454
+                $url = str_replace('{'.$key.'}', $value, $url);
455 455
             }
456 456
         } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
457
-            $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
457
+            $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
458 458
         }
459 459
 
460 460
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -496,17 +496,17 @@  discard block
 block discarded – undo
496 496
      */
497 497
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
498 498
     {
499
-        Logger::log('Executing route ' . $route, LOG_INFO);
499
+        Logger::log('Executing route '.$route, LOG_INFO);
500 500
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
501 501
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
502 502
         $cache = Cache::needCache();
503 503
         $execute = TRUE;
504 504
         if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) {
505 505
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
506
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName,
506
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName,
507 507
                 $cache);
508 508
             if (NULL !== $cachedData) {
509
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers',
509
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers',
510 510
                     $cache, null, Cache::JSON);
511 511
                 Template::getInstance()->renderCache($cachedData, $headers);
512 512
                 $execute = FALSE;
@@ -549,11 +549,11 @@  discard block
 block discarded – undo
549 549
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath)
550 550
     {
551 551
         $extModule = $modulePath->getBasename();
552
-        $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
553
-        if(file_exists($moduleAutoloader)) {
552
+        $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
553
+        if (file_exists($moduleAutoloader)) {
554 554
             include_once $moduleAutoloader;
555 555
             if ($hydrateRoute) {
556
-                $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
556
+                $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
557 557
             }
558 558
         }
559 559
     }
@@ -567,14 +567,14 @@  discard block
 block discarded – undo
567 567
     {
568 568
         try {
569 569
             $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
570
-            $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
570
+            $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
571 571
             $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
572
-            if($externalModule->hasResults()) {
572
+            if ($externalModule->hasResults()) {
573 573
                 foreach ($externalModule->getIterator() as $modulePath) {
574 574
                     $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath);
575 575
                 }
576 576
             }
577
-        } catch (\Exception $e) {
577
+        }catch (\Exception $e) {
578 578
             Logger::log($e->getMessage(), LOG_WARNING);
579 579
             $module = null;
580 580
         }
Please login to merge, or discard this patch.
src/base/types/helpers/FileHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function readFile($path) {
25 25
         $data = false;
26
-        if(file_exists($path)) {
26
+        if (file_exists($path)) {
27 27
             $data = @file_get_contents($path);
28 28
         }
29 29
         return $data;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @return string
37 37
      */
38 38
     public static function generateHashFilename($verb, $slug, array $query = []) {
39
-        return sha1(strtolower($verb) . ' ' . $slug . ' ' . strtolower(http_build_query($query)));
39
+        return sha1(strtolower($verb).' '.$slug.' '.strtolower(http_build_query($query)));
40 40
     }
41 41
 
42 42
     /**
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
     public static function generateCachePath(array $action, array $query = []) {
48 48
         $class = GeneratorHelper::extractClassFromNamespace($action['class']);
49 49
         $filename = self::generateHashFilename($action['http'], $action['slug'], $query);
50
-        $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2);
51
-        return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR;
50
+        $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2);
51
+        return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR;
52 52
     }
53 53
 
54 54
     /**
Please login to merge, or discard this patch.
src/base/Singleton.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function __construct()
24 24
     {
25
-        Logger::log(get_class($this) . ' constructor invoked');
25
+        Logger::log(get_class($this).' constructor invoked');
26 26
         $this->init();
27 27
     }
28 28
 
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
         $calledClass = static::class;
81 81
         try {
82 82
             $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass);
83
-            $setter = 'set' . ucfirst($variable);
83
+            $setter = 'set'.ucfirst($variable);
84 84
             if (method_exists($calledClass, $setter)) {
85 85
                 $this->$setter($instance);
86
-            } else {
86
+            }else {
87 87
                 $this->$variable = $instance;
88 88
             }
89
-        } catch (\Exception $e) {
90
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR);
89
+        }catch (\Exception $e) {
90
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
91 91
             throw $e;
92 92
         }
93 93
         return $this;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         if (!$this->isLoaded()) {
104 104
             $filename = sha1(get_class($this));
105
-            $cacheFilename = 'reflections' . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json";
105
+            $cacheFilename = 'reflections'.DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json";
106 106
             /** @var \PSFS\base\Cache $cacheService */
107 107
             $cacheService = Cache::getInstance();
108 108
             /** @var \PSFS\base\config\Config $configService */
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
                 }
121 121
             }
122 122
             $this->setLoaded();
123
-        } else {
124
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
123
+        }else {
124
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
125 125
         }
126 126
     }
127 127
 }
Please login to merge, or discard this patch.
src/base/Security.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             session_start();
74 74
         }
75 75
         // Fix for phpunits
76
-        if(!isset($_SESSION)) {
76
+        if (!isset($_SESSION)) {
77 77
             $_SESSION = [];
78 78
         }
79 79
     }
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
     public static function save($user)
128 128
     {
129 129
         $saved = true;
130
-        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
131
-        $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
130
+        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
131
+        $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
132 132
         $admins[$user['username']]['profile'] = $user['profile'];
133 133
 
134
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
134
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
135 135
         return $saved;
136 136
     }
137 137
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function getAdmins()
176 176
     {
177
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
177
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
178 178
     }
179 179
 
180 180
     /**
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 if (!empty($user) && !empty($admins[$user])) {
201 201
                     $auth = $admins[$user]['hash'];
202
-                    $this->authorized = ($auth === sha1($user . $pass));
202
+                    $this->authorized = ($auth === sha1($user.$pass));
203 203
                     if ($this->authorized) {
204
-                        $this->updateAdmin($user , $admins[$user]['profile']);
204
+                        $this->updateAdmin($user, $admins[$user]['profile']);
205 205
                         ResponseHelper::setCookieHeaders([
206 206
                             [
207 207
                                 'name' => $this->getHash(),
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                         ]);
213 213
                         $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}"));
214 214
                     }
215
-                } else {
215
+                }else {
216 216
                     $this->admin = null;
217 217
                     $this->setSessionKey(self::ADMIN_ID_TOKEN, null);
218 218
                 }
Please login to merge, or discard this patch.
src/base/types/helpers/ApiFormHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
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();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $action = null;
46 46
         if (false !== preg_match('/@action\s+([^\s]+)/', $doc, $matches)) {
47
-            if(count($matches) > 1) {
47
+            if (count($matches) > 1) {
48 48
                 list(, $action) = $matches;
49 49
             }
50 50
         }
Please login to merge, or discard this patch.
src/base/types/traits/Api/MutationTrait.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -65,21 +65,21 @@  discard block
 block discarded – undo
65 65
         if (count($pks) == 1) {
66 66
             $pks = array_keys($pks);
67 67
             return [
68
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
68
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
69 69
             ];
70 70
         } elseif (count($pks) > 1) {
71 71
             $apiPks = [];
72 72
             $principal = '';
73 73
             $sep = 'CONCAT(';
74 74
             foreach ($pks as $pk) {
75
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
76
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
77
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
75
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
76
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
77
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
78 78
             }
79 79
             $principal .= ')';
80 80
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
81 81
             return $apiPks;
82
-        } else {
82
+        }else {
83 83
             throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta'));
84 84
         }
85 85
     }
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
         $pks = '';
103 103
         $sep = '';
104 104
         foreach ($tableMap->getPrimaryKeys() as $pk) {
105
-            $pks .= $sep . $pk->getFullyQualifiedName();
105
+            $pks .= $sep.$pk->getFullyQualifiedName();
106 106
             $sep = ', "|", ';
107 107
         }
108
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
108
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
109 109
     }
110 110
 
111 111
     /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             }
128 128
             if (null !== $column) {
129 129
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
130
-            } else {
130
+            }else {
131 131
                 $this->addClassListName($tableMap);
132 132
             }
133 133
         }
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
             $this->addPkToList();
147 147
         }
148 148
         if (!empty($this->extraColumns)) {
149
-            if(Config::getParam('api.extrafields.compat', true)) {
149
+            if (Config::getParam('api.extrafields.compat', true)) {
150 150
                 $fields = array_values($this->extraColumns);
151
-            } else {
151
+            }else {
152 152
                 $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD);
153 153
                 $fields = explode(',', $returnFields ?: '');
154 154
                 $fields[] = self::API_MODEL_KEY_FIELD;
155 155
             }
156 156
             foreach ($this->extraColumns as $expression => $columnName) {
157
-                if(empty($fields) || in_array($columnName, $fields)) {
157
+                if (empty($fields) || in_array($columnName, $fields)) {
158 158
                     $query->withColumn($expression, $columnName);
159 159
                 }
160 160
             }
@@ -186,17 +186,17 @@  discard block
 block discarded – undo
186 186
     {
187 187
         $this->extractApiLang();
188 188
         $model = $this->getModelNamespace();
189
-        $modelI18n = $model . 'I18n';
189
+        $modelI18n = $model.'I18n';
190 190
         if (method_exists($query, 'useI18nQuery')) {
191 191
             $query->useI18nQuery($this->lang);
192
-            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap';
192
+            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap';
193 193
             /** @var TableMap $modelI18nTableMap */
194 194
             $modelI18nTableMap = $modelI18nTableMapClass::getTableMap();
195
-            foreach($modelI18nTableMap->getColumns() as $columnMap) {
196
-                if(!$columnMap->isPrimaryKey()) {
197
-                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName(), $columnMap->getPhpName());
198
-                } elseif(!$columnMap->isForeignKey()) {
199
-                    $query->withColumn('IFNULL(' . $modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName() . ', "'.$this->lang.'")', $columnMap->getPhpName());
195
+            foreach ($modelI18nTableMap->getColumns() as $columnMap) {
196
+                if (!$columnMap->isPrimaryKey()) {
197
+                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName(), $columnMap->getPhpName());
198
+                } elseif (!$columnMap->isForeignKey()) {
199
+                    $query->withColumn('IFNULL('.$modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName().', "'.$this->lang.'")', $columnMap->getPhpName());
200 200
                 }
201 201
             }
202 202
         }
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
         $model->fromArray($data);
211 211
         $tableMap = $this->getTableMap();
212 212
         try {
213
-            if($tableMap->hasRelation($tableMap->getPhpName() . 'I18n'))
213
+            if ($tableMap->hasRelation($tableMap->getPhpName().'I18n'))
214 214
             {
215
-                $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
215
+                $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
216 216
                 $i18NTableMap = $relateI18n->getLocalTable();
217
-                foreach($i18NTableMap->getColumns() as $columnMap) {
218
-                    $method = 'set' . $columnMap->getPhpName();
219
-                    if(!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
217
+                foreach ($i18NTableMap->getColumns() as $columnMap) {
218
+                    $method = 'set'.$columnMap->getPhpName();
219
+                    if (!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
220 220
                         &&array_key_exists($columnMap->getPhpName(), $data)
221 221
                         && method_exists($model, $method)) {
222 222
                         $model->$method($data[$columnMap->getPhpName()]);
223 223
                     }
224 224
                 }
225 225
             }
226
-        } catch(\Exception $e) {
226
+        }catch (\Exception $e) {
227 227
             Logger::log($e->getMessage(), LOG_WARNING);
228 228
         }
229 229
     }
Please login to merge, or discard this patch.
src/base/types/helpers/I18nHelper.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
     /**
21 21
      * @param string $default
22
-     * @return array|mixed|string
22
+     * @return string
23 23
      */
24 24
     public static function extractLocale($default = null)
25 25
     {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $locale = Request::header('X-API-LANG');
29 29
         if (empty($locale)) {
30 30
             $locale = Security::getInstance()->getSessionKey(self::PSFS_SESSION_LANGUAGE_KEY);
31
-            if(empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
31
+            if (empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
32 32
                 $BrowserLocales = explode(",", str_replace("-", "_", $_SERVER["HTTP_ACCEPT_LANGUAGE"])); // brosers use en-US, Linux uses en_US
33 33
                 for ($i = 0; $i < count($BrowserLocales); $i++) {
34 34
                     list($BrowserLocales[$i]) = explode(";", $BrowserLocales[$i]); //trick for "en;q=0.8"
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
         if (false !== strpos($locale, '_')) {
41 41
             $locale = explode('_', $locale);
42 42
             if ($locale[0] == 'en') {
43
-                $locale = $locale[0] . '_GB';
44
-            } else {
45
-                $locale = $locale[0] . '_' . strtoupper($locale[1]);
43
+                $locale = $locale[0].'_GB';
44
+            }else {
45
+                $locale = $locale[0].'_'.strtoupper($locale[1]);
46 46
             }
47
-        } else {
47
+        }else {
48 48
             if (strtolower($locale) === 'en') {
49 49
                 $locale = 'en_GB';
50
-            } else {
51
-                $locale = $locale . '_' . strtoupper($locale);
50
+            }else {
51
+                $locale = $locale.'_'.strtoupper($locale);
52 52
             }
53 53
         }
54 54
         if (!in_array($locale, self::$langs)) {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $translations = array();
70 70
         if (file_exists($absoluteTranslationFileName)) {
71 71
             @include($absoluteTranslationFileName);
72
-        } else {
72
+        }else {
73 73
             Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
74 74
         }
75 75
 
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
     public static function setLocale()
83 83
     {
84 84
         $locale = self::extractLocale('es_ES');
85
-        Logger::log('Set locale to project [' . $locale . ']');
85
+        Logger::log('Set locale to project ['.$locale.']');
86 86
         // Load translations
87
-        putenv("LC_ALL=" . $locale);
87
+        putenv("LC_ALL=".$locale);
88 88
         setlocale(LC_ALL, $locale);
89 89
         // Load the locale path
90
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
91
-        Logger::log('Set locale dir ' . $locale_path);
90
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
91
+        Logger::log('Set locale dir '.$locale_path);
92 92
         GeneratorHelper::createDir($locale_path);
93 93
         bindtextdomain('translations', $locale_path);
94 94
         textdomain('translations');
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function checkI18Class($namespace) {
125 125
         $isI18n = false;
126
-        if(preg_match('/I18n$/i', $namespace)) {
126
+        if (preg_match('/I18n$/i', $namespace)) {
127 127
             $parentClass = preg_replace('/I18n$/i', '', $namespace);
128
-            if(Router::exists($parentClass)) {
128
+            if (Router::exists($parentClass)) {
129 129
                 $isI18n = true;
130 130
             }
131 131
         }
Please login to merge, or discard this patch.