Passed
Push — master ( efa76a...920abb )
by Fran
02:31
created
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);
196
+        Inspector::stats('[Router] Searching action to execute: '.$route);
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');
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(1)->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 ');
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);
504
+        Inspector::stats('[Router] Executing route '.$route);
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);
520
+            Inspector::stats('[Router] Start executing action '.$route);
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/Cache.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
69 69
     {
70 70
         Inspector::stats('[Cache] Gathering data from cache');
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
 block discarded – undo
85 85
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
86 86
     {
87 87
         Inspector::stats('[Cache] Checking expiration');
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
 block discarded – undo
152 152
     {
153 153
         Inspector::stats('[Cache] Store data in cache');
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
 block discarded – undo
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]));
172
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]));
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
 block discarded – undo
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]));
222
+            Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]));
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');
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
             }
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 = array())
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.
src/base/dto/Dto.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct($hydrate = true)
20 20
     {
21 21
         parent::__construct();
22
-        if($hydrate) {
22
+        if ($hydrate) {
23 23
             $this->fromArray(Request::getInstance()->getData());
24 24
         }
25 25
     }
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
                 /** @var \ReflectionProperty $property */
48 48
                 foreach ($properties as $property) {
49 49
                     $value = $property->getValue($this);
50
-                    if(is_object($value) && method_exists($value, 'toArray')) {
50
+                    if (is_object($value) && method_exists($value, 'toArray')) {
51 51
                         $dto[$property->getName()] = $value->toArray();
52
-                    } elseif(is_array($value)) {
53
-                        foreach($value as &$arrValue) {
54
-                            if($arrValue instanceof Dto) {
52
+                    } elseif (is_array($value)) {
53
+                        foreach ($value as &$arrValue) {
54
+                            if ($arrValue instanceof Dto) {
55 55
                                 $arrValue = $arrValue->toArray();
56 56
                             }
57 57
                         }
58 58
                         $dto[$property->getName()] = $value;
59
-                    } else {
59
+                    }else {
60 60
                         $dto[$property->getName()] = $property->getValue($this);
61 61
                     }
62 62
                 }
63 63
             }
64
-        } catch (\Exception $e) {
65
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
64
+        }catch (\Exception $e) {
65
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
66 66
         }
67 67
         return $dto;
68 68
     }
@@ -85,26 +85,26 @@  discard block
 block discarded – undo
85 85
     protected function parseDtoField(array $properties, $key, $value = null) {
86 86
         list($type, $isArray) = $this->extractTypes($properties, $key);
87 87
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
88
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
89
-            if(null !== $value && is_array($value)) {
90
-                if(!array_key_exists($type, $this->__cache)) {
88
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
89
+            if (null !== $value && is_array($value)) {
90
+                if (!array_key_exists($type, $this->__cache)) {
91 91
                     $this->__cache[$type] = new $type(false);
92 92
                 }
93
-                if($isArray) {
93
+                if ($isArray) {
94 94
                     $this->$key = [];
95
-                    foreach($value as $data) {
96
-                        if(null !== $data && is_array($data)) {
95
+                    foreach ($value as $data) {
96
+                        if (null !== $data && is_array($data)) {
97 97
                             $dto = clone $this->__cache[$type];
98 98
                             $dto->fromArray($data);
99 99
                             array_push($this->$key, $dto);
100 100
                         }
101 101
                     }
102
-                } else {
102
+                }else {
103 103
                     $this->$key = clone $this->__cache[$type];
104 104
                     $this->$key->fromArray($value);
105 105
                 }
106 106
             }
107
-        } else {
107
+        }else {
108 108
             $this->castValue($key, $value, $type);
109 109
         }
110 110
     }
Please login to merge, or discard this patch.
src/base/types/helpers/ServiceHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     }
16 16
 
17 17
     public static function parseRawData($type, $params) {
18
-        switch($type) {
18
+        switch ($type) {
19 19
             default:
20 20
             case self::TYPE_HTTP:
21 21
                 $parsedParams = http_build_query($params);
Please login to merge, or discard this patch.
src/base/extension/AssetsTokenParser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
         $tmp = [];
142 142
         if (null === $node) {
143 143
             $node = $value;
144
-        } else {
144
+        }else {
145 145
             $tmp = $this->getTmpAttribute($node);
146 146
         }
147 147
         if (null !== $node) {
Please login to merge, or discard this patch.
src/base/extension/CustomTranslateExtension.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
             $customKey = $customKey ?: Security::getInstance()->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY);
55 55
         }
56 56
         if (null !== $customKey) {
57
-            Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO);
58
-            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']);
59
-        } else {
60
-            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']);
57
+            Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO);
58
+            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']);
59
+        }else {
60
+            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']);
61 61
         }
62 62
         if (file_exists(self::$filename)) {
63
-            Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO);
63
+            Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO);
64 64
             self::$translations = json_decode(file_get_contents(self::$filename), true);
65 65
         } elseif (null !== $customKey) {
66 66
             self::checkLoad(null, $forceReload, true);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     public function getFilters()
82 82
     {
83 83
         return array(
84
-            new TwigFilter('trans', function ($message) {
84
+            new TwigFilter('trans', function($message) {
85 85
                 return self::_($message);
86 86
             }),
87 87
         );
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         self::checkLoad($customKey, $forceReload);
107 107
         if (array_key_exists($message, self::$translations)) {
108 108
             $translation = self::$translations[$message];
109
-        } else {
109
+        }else {
110 110
             $translation = gettext($message);
111 111
         }
112 112
         if (self::$generate) {
Please login to merge, or discard this patch.
src/base/Service.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     protected $isMultipart = false;
71 71
 
72 72
     private function closeConnection() {
73
-        if(null !== $this->con) {
73
+        if (null !== $this->con) {
74 74
             curl_close($this->con);
75 75
         }
76 76
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      */
234 234
     public function setIsJson($isJson = true) {
235 235
         $this->isJson = $isJson;
236
-        if($isJson) {
236
+        if ($isJson) {
237 237
             $this->setIsMultipart(false);
238 238
         }
239 239
     }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      */
251 251
     public function setIsMultipart($isMultipart = true) {
252 252
         $this->isMultipart = $isMultipart;
253
-        if($isMultipart) {
253
+        if ($isMultipart) {
254 254
             $this->setIsJson(false);
255 255
         }
256 256
     }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         $this->url = NULL;
271 271
         $this->params = array();
272 272
         $this->headers = array();
273
-        Logger::log('Context service for ' . static::class . ' cleared!');
273
+        Logger::log('Context service for '.static::class.' cleared!');
274 274
         $this->closeConnection();
275 275
     }
276 276
 
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
     }
314 314
 
315 315
     protected function applyOptions() {
316
-        if(count($this->options)) {
316
+        if (count($this->options)) {
317 317
             curl_setopt_array($this->con, $this->options);
318 318
         }
319 319
     }
320 320
 
321 321
     protected function applyHeaders() {
322 322
         $headers = [];
323
-        foreach($this->headers as $key => $value) {
324
-            $headers[] = $key . ': ' . $value;
323
+        foreach ($this->headers as $key => $value) {
324
+            $headers[] = $key.': '.$value;
325 325
         }
326 326
         $headers[self::PSFS_TRACK_HEADER] = Logger::getUid();
327
-        if(count($headers)) {
327
+        if (count($headers)) {
328 328
             curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers);
329 329
         }
330 330
     }
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
      * @return int
334 334
      */
335 335
     private function parseServiceType() {
336
-        if($this->getIsJson()) {
336
+        if ($this->getIsJson()) {
337 337
             return ServiceHelper::TYPE_JSON;
338 338
         }
339
-        if($this->getIsMultipart()) {
339
+        if ($this->getIsMultipart()) {
340 340
             return ServiceHelper::TYPE_MULTIPART;
341 341
         }
342 342
         return ServiceHelper::TYPE_HTTP;
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
             case Request::VERB_GET:
350 350
             default:
351 351
                 $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_GET);
352
-                if(!empty($this->params)) {
352
+                if (!empty($this->params)) {
353 353
                     $sep = false === strpos($this->getUrl(), '?') ? '?' : '';
354
-                    $this->url = $this->url . $sep . http_build_query($this->params);
354
+                    $this->url = $this->url.$sep.http_build_query($this->params);
355 355
                 }
356 356
                 break;
357 357
             case Request::VERB_POST:
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
         $this->applyOptions();
384 384
         $this->applyHeaders();
385 385
         $verbose = null;
386
-        if('debug' === Config::getParam('log.level')) {
386
+        if ('debug' === Config::getParam('log.level')) {
387 387
             curl_setopt($this->con, CURLOPT_VERBOSE, true);
388 388
             $verbose = fopen('php://temp', 'wb+');
389 389
             curl_setopt($this->con, CURLOPT_STDERR, $verbose);
390 390
         }
391 391
         $result = curl_exec($this->con);
392 392
         $this->setResult($this->isJson ? json_decode($result, true) : $result);
393
-        if('debug' === Config::getParam('log.level')) {
393
+        if ('debug' === Config::getParam('log.level')) {
394 394
             rewind($verbose);
395 395
             $verboseLog = stream_get_contents($verbose);
396 396
             Logger::log($verboseLog, LOG_DEBUG, [
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             ]);
401 401
             $this->info['verbose'] = $verboseLog;
402 402
         }
403
-        Logger::log($this->url . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]);
403
+        Logger::log($this->url.' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]);
404 404
         $this->info = array_merge($this->info, curl_getinfo($this->con));
405 405
     }
406 406
 
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
             $objects = scandir($dir);
24 24
             foreach ($objects as $object) {
25 25
                 if ($object != "." && $object != "..") {
26
-                    if (filetype($dir . "/" . $object) == "dir") {
27
-                        self::deleteDir($dir . "/" . $object);
28
-                    } else {
29
-                        unlink($dir . "/" . $object);
26
+                    if (filetype($dir."/".$object) == "dir") {
27
+                        self::deleteDir($dir."/".$object);
28
+                    }else {
29
+                        unlink($dir."/".$object);
30 30
                     }
31 31
                 }
32 32
             }
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $rootDirs = array("css", "js", "media", "font");
44 44
         foreach ($rootDirs as $dir) {
45
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
45
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
46 46
                 try {
47
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
48
-                } catch (\Exception $e) {
47
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
48
+                }catch (\Exception $e) {
49 49
                     Logger::log($e->getMessage());
50 50
                 }
51 51
             }
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
     {
62 62
         try {
63 63
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
64
-                throw new \Exception(t('Can\'t create directory ') . $dir);
64
+                throw new \Exception(t('Can\'t create directory ').$dir);
65 65
             }
66
-        } catch (\Exception $e) {
66
+        }catch (\Exception $e) {
67 67
             Logger::log($e->getMessage(), LOG_WARNING);
68 68
             if (!file_exists(dirname($dir))) {
69
-                throw new GeneratorException($e->getMessage() . $dir);
69
+                throw new GeneratorException($e->getMessage().$dir);
70 70
             }
71 71
         }
72 72
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function getTemplatePath()
79 79
     {
80
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
80
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
81 81
         return realpath($path);
82 82
     }
83 83
 
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
      * @throws \ReflectionException
97 97
      */
98 98
     public static function checkCustomNamespaceApi($namespace) {
99
-        if(!empty($namespace)) {
100
-            if(class_exists($namespace)) {
99
+        if (!empty($namespace)) {
100
+            if (class_exists($namespace)) {
101 101
                 $reflector = new \ReflectionClass($namespace);
102
-                if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
102
+                if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
103 103
                     throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501);
104
-                } elseif(!$reflector->isAbstract()) {
104
+                } elseif (!$reflector->isAbstract()) {
105 105
                     throw new GeneratorException(t('La clase definida debe ser abstracta'), 501);
106 106
                 }
107
-            } else {
107
+            }else {
108 108
                 throw new GeneratorException(t('La clase definida para extender la API no existe'), 501);
109 109
             }
110 110
         }
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
      * @return array
116 116
      */
117 117
     public static function getDomainPaths($domain) {
118
-        $domains = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json'), true);
118
+        $domains = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json'), true);
119 119
         $paths = [];
120
-        if(null !== $domains) {
120
+        if (null !== $domains) {
121 121
             $keyDomains = array_keys($domains);
122
-            foreach($keyDomains as $keyDomain) {
122
+            foreach ($keyDomains as $keyDomain) {
123 123
                 $key = strtoupper(str_replace(['@', '/'], '', $keyDomain));
124
-                if(strtoupper($domain) === $key) {
124
+                if (strtoupper($domain) === $key) {
125 125
                     $paths = $domains[$keyDomain];
126 126
                     break;
127 127
                 }
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public static function createRoot($path = WEB_DIR, OutputInterface $output = null) {
139 139
 
140
-        if(null === $output) {
140
+        if (null === $output) {
141 141
             $output = new ConsoleOutput();
142 142
         }
143 143
 
144 144
         GeneratorHelper::createDir($path);
145 145
         $paths = array("js", "css", "img", "media", "font");
146 146
         foreach ($paths as $htmlPath) {
147
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
147
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
148 148
         }
149 149
 
150 150
         // Generates the root needed files
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
         ];
158 158
         $output->writeln('Start creating html files');
159 159
         foreach ($files as $templates => $filename) {
160
-            $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig');
161
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
162
-                $output->writeln('Can\t create the file ' . $filename);
163
-            } else {
164
-                $output->writeln($filename . ' created successfully');
160
+            $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
161
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
162
+                $output->writeln('Can\t create the file '.$filename);
163
+            }else {
164
+                $output->writeln($filename.' created successfully');
165 165
             }
166 166
         }
167 167
 
168 168
         //Export base locale translations
169
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
170
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
171
-            GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
169
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
170
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
171
+            GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
172 172
         }
173 173
     }
174 174
 }
175 175
\ No newline at end of file
Please login to merge, or discard this patch.