Test Failed
Push — master ( 5f9190...472f53 )
by Fran
02:50
created
src/controller/UserController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                 Logger::log('Configuration saved successful');
63 63
                 Security::getInstance()->setFlash("callback_message", t("Usuario agregado correctamente"));
64 64
                 Security::getInstance()->setFlash("callback_route", Router::getInstance()->getRoute("admin", true));
65
-            } else {
65
+            }else {
66 66
                 throw new ConfigException(t('Error al guardar los administradores, prueba a cambiar los permisos'));
67 67
             }
68 68
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         if ($this->isAdmin()) {
100 100
             return $this->redirect('admin');
101
-        } else {
101
+        }else {
102 102
             return Admin::staticAdminLogon($route);
103 103
         }
104 104
     }
Please login to merge, or discard this patch.
src/controller/base/Admin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@
 block discarded – undo
35 35
      */
36 36
     public static function staticAdminLogon($route = null)
37 37
     {
38
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
38
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
39 39
             return AdminServices::getInstance()->setAdminHeaders();
40
-        } else {
40
+        }else {
41 41
             return UserController::showAdminManager();
42 42
         }
43 43
     }
Please login to merge, or discard this patch.
src/base/types/traits/BoostrapTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +50 added lines, -50 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::getParam('debug', true)) {
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
         $notFoundRoute = Config::getParam('route.404');
120
-        if(null !== $notFoundRoute) {
120
+        if (null !== $notFoundRoute) {
121 121
             Request::getInstance()->redirect($this->getRoute($notFoundRoute, true));
122
-        } else {
122
+        }else {
123 123
             return $template->render('error.html.twig', array(
124 124
                 'exception' => $exception,
125 125
                 'trace' => $exception->getTraceAsString(),
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
         try {
171 171
             //Search action and execute
172 172
             return $this->searchAction($route);
173
-        } catch (AccessDeniedException $e) {
174
-            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
173
+        }catch (AccessDeniedException $e) {
174
+            Logger::log(t('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
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     protected function searchAction($route)
195 195
     {
196
-        Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG);
196
+        Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG);
197 197
         //Revisamos si tenemos la ruta registrada
198 198
         $parts = parse_url($route);
199 199
         $path = array_key_exists('path', $parts) ? $parts['path'] : $route;
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
                 /** @var $class \PSFS\base\types\Controller */
209 209
                 $class = RouterHelper::getClassToCall($action);
210 210
                 try {
211
-                    if($this->checkRequirements($action, $get)) {
211
+                    if ($this->checkRequirements($action, $get)) {
212 212
                         return $this->executeCachedRoute($route, $action, $class, $get);
213
-                    } else {
213
+                    }else {
214 214
                         throw new RouterException(t('La ruta no es válida'), 400);
215 215
                     }
216
-                } catch (\Exception $e) {
216
+                }catch (\Exception $e) {
217 217
                     Logger::log($e->getMessage(), LOG_ERR);
218 218
                     throw $e;
219 219
                 }
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
      */
230 230
     private function checkRequirements(array $action, $params = []) {
231 231
         Inspector::stats('[Router] Checking request requirements', Inspector::SCOPE_DEBUG);
232
-        if(!empty($params) && !empty($action['requirements'])) {
232
+        if (!empty($params) && !empty($action['requirements'])) {
233 233
             $checked = 0;
234
-            foreach(array_keys($params) as $key) {
235
-                if(in_array($key, $action['requirements'], true)) {
234
+            foreach (array_keys($params) as $key) {
235
+                if (in_array($key, $action['requirements'], true)) {
236 236
                     $checked++;
237 237
                 }
238 238
             }
239 239
             $valid = count($action['requirements']) === $checked;
240
-        } else {
240
+        }else {
241 241
             $valid = true;
242 242
         }
243 243
         return $valid;
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
         $this->checkExternalModules();
288 288
         if (file_exists($modulesPath)) {
289 289
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
290
-            if($modules->hasResults()) {
290
+            if ($modules->hasResults()) {
291 291
                 foreach ($modules->getIterator() as $modulePath) {
292 292
                     $module = $modulePath->getBasename();
293
-                    $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
293
+                    $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
294 294
                 }
295 295
             }
296 296
         }
297
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE);
297
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE);
298 298
     }
299 299
 
300 300
     /**
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             $home_params = NULL;
311 311
             foreach ($this->routing as $pattern => $params) {
312 312
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
313
-                if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) {
313
+                if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) {
314 314
                     $home_params = $params;
315 315
                 }
316 316
                 unset($method);
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
     private function inspectDir($origen, $namespace = 'PSFS', $routing = [])
333 333
     {
334 334
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth('< 3')->name('*.php');
335
-        if($files->hasResults()) {
335
+        if ($files->hasResults()) {
336 336
             foreach ($files->getIterator() as $file) {
337
-                if($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) {
338
-                    $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
339
-                } else {
337
+                if ($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) {
338
+                    $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
339
+                }else {
340 340
                     $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname()));
341 341
                 }
342
-                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
342
+                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
343 343
             }
344 344
         }
345 345
         $this->finder = new Finder();
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     private function addRouting($namespace, &$routing, $module = 'PSFS')
369 369
     {
370 370
         if (self::exists($namespace)) {
371
-            if(I18nHelper::checkI18Class($namespace)) {
371
+            if (I18nHelper::checkI18Class($namespace)) {
372 372
                 return $routing;
373 373
             }
374 374
             $reflection = new \ReflectionClass($namespace);
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
             if (!$this->domains) {
411 411
                 $this->domains = [];
412 412
             }
413
-            $domain = '@' . $class->getConstant('DOMAIN') . '/';
413
+            $domain = '@'.$class->getConstant('DOMAIN').'/';
414 414
             if (!array_key_exists($domain, $this->domains)) {
415 415
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
416 416
             }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
      */
427 427
     public function simpatize()
428 428
     {
429
-        $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php';
430
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
429
+        $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php';
430
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
431 431
         $this->generateSlugs($absoluteTranslationFileName);
432 432
         GeneratorHelper::createDir(CONFIG_DIR);
433
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
433
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
434 434
 
435 435
         return $this;
436 436
     }
@@ -446,18 +446,18 @@  discard block
 block discarded – undo
446 446
     public function getRoute($slug = '', $absolute = FALSE, array $params = [])
447 447
     {
448 448
         if ('' === $slug) {
449
-            return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/';
449
+            return $absolute ? Request::getInstance()->getRootUrl().'/' : '/';
450 450
         }
451 451
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
452 452
             throw new RouterException(t('No existe la ruta especificada'));
453 453
         }
454
-        $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
454
+        $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
455 455
         if (!empty($params)) {
456 456
             foreach ($params as $key => $value) {
457
-                $url = str_replace('{' . $key . '}', $value, $url);
457
+                $url = str_replace('{'.$key.'}', $value, $url);
458 458
             }
459 459
         } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
460
-            $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
460
+            $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
461 461
         }
462 462
 
463 463
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
      * @param string $method
477 477
      */
478 478
     private function checkPreActions($class, $method) {
479
-        $preAction = 'pre' . ucfirst($method);
480
-        if(method_exists($class, $preAction)) {
479
+        $preAction = 'pre'.ucfirst($method);
480
+        if (method_exists($class, $preAction)) {
481 481
             Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG);
482 482
             try {
483
-                if(false === call_user_func_array([$class, $preAction])) {
483
+                if (false === call_user_func_array([$class, $preAction])) {
484 484
                     Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]);
485 485
                     error_clear_last();
486 486
                 }
487
-            } catch (\Exception $e) {
487
+            }catch (\Exception $e) {
488 488
                 Logger::log($e->getMessage(), LOG_ERR, [$class, $method]);
489 489
             }
490 490
         }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
      */
502 502
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
503 503
     {
504
-        Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG);
504
+        Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG);
505 505
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
506 506
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
507 507
         $cache = Cache::needCache();
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
         $return = null;
510 510
         if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) {
511 511
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
512
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache);
512
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache);
513 513
             if (NULL !== $cachedData) {
514
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON);
514
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON);
515 515
                 Template::getInstance()->renderCache($cachedData, $headers);
516 516
                 $execute = FALSE;
517 517
             }
518 518
         }
519 519
         if ($execute) {
520
-            Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG);
520
+            Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG);
521 521
             $this->checkPreActions($class, $action['method']);
522 522
             $return = call_user_func_array([$class, $action['method']], $params);
523 523
             if (false === $return) {
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath)
557 557
     {
558 558
         $extModule = $modulePath->getBasename();
559
-        $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
560
-        if(file_exists($moduleAutoloader)) {
559
+        $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
560
+        if (file_exists($moduleAutoloader)) {
561 561
             include_once $moduleAutoloader;
562 562
             if ($hydrateRoute) {
563
-                $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
563
+                $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
564 564
             }
565 565
         }
566 566
     }
@@ -574,16 +574,16 @@  discard block
 block discarded – undo
574 574
     {
575 575
         try {
576 576
             $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
577
-            $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
578
-            if(file_exists($externalModulePath)) {
577
+            $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
578
+            if (file_exists($externalModulePath)) {
579 579
                 $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
580
-                if($externalModule->hasResults()) {
580
+                if ($externalModule->hasResults()) {
581 581
                     foreach ($externalModule->getIterator() as $modulePath) {
582 582
                         $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath);
583 583
                     }
584 584
                 }
585 585
             }
586
-        } catch (\Exception $e) {
586
+        }catch (\Exception $e) {
587 587
             Logger::log($e->getMessage(), LOG_WARNING);
588 588
             $module = null;
589 589
         }
Please login to merge, or discard this patch.
src/base/dto/Order.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.