Completed
Push — master ( 04bd65...4036d4 )
by Fran
09:06
created
src/base/Logger.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -6,10 +6,8 @@
 block discarded – undo
6 6
     use Monolog\Handler\FirePHPHandler;
7 7
     use Monolog\Handler\StreamHandler;
8 8
     use Monolog\Logger as Monolog;
9
-    use Monolog\Processor\GitProcessor;
10 9
     use Monolog\Processor\MemoryUsageProcessor;
11 10
     use Monolog\Processor\UidProcessor;
12
-    use Monolog\Processor\WebProcessor;
13 11
     use PSFS\base\config\Config;
14 12
     use PSFS\base\types\SingletonTrait;
15 13
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@
 block discarded – undo
190 190
          * @param array $context
191 191
          */
192 192
         public static function log($msg, $type = LOG_DEBUG, $context = []) {
193
-            switch($type) {
193
+            switch ($type) {
194 194
                 case LOG_DEBUG:
195 195
                     Logger::getInstance()->debugLog($msg, $context);
196 196
                     break;
Please login to merge, or discard this patch.
src/base/Request.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -95,6 +95,10 @@
 block discarded – undo
95 95
      * @return string|null
96 96
      */
97 97
     public static function header($name) { return self::getInstance()->getHeader($name); }
98
+
99
+    /**
100
+     * @return string
101
+     */
98 102
     public function getHeader($name)
99 103
     {
100 104
         $header = null;
Please login to merge, or discard this patch.
src/bootstrap.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-    if(defined('PSFS_BOOTSTRAP_LOADED')) return;
2
+    if (defined('PSFS_BOOTSTRAP_LOADED')) return;
3 3
     use Symfony\Component\Finder\Finder;
4 4
 
5 5
     if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
Please login to merge, or discard this patch.
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,20 +1,40 @@
 block discarded – undo
1 1
 <?php
2
-    if(defined('PSFS_BOOTSTRAP_LOADED')) return;
2
+    if(defined('PSFS_BOOTSTRAP_LOADED')) {
3
+        return;
4
+    }
3 5
     use Symfony\Component\Finder\Finder;
4 6
 
5
-    if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
7
+    if (!defined('SOURCE_DIR')) {
8
+        define('SOURCE_DIR', __DIR__);
9
+    }
6 10
     if (preg_match('/vendor/', SOURCE_DIR))
7 11
     {
8
-        if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
9
-        if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
10
-    }else {
11
-        if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
12
-        if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
13
-    }
14
-    if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
15
-    if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
16
-    if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
17
-    if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
12
+        if (!defined('BASE_DIR')) {
13
+            define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
14
+        }
15
+        if (!defined('CORE_DIR')) {
16
+            define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
17
+        }
18
+    } else {
19
+        if (!defined('BASE_DIR')) {
20
+            define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
21
+        }
22
+        if (!defined('CORE_DIR')) {
23
+            define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
24
+        }
25
+    }
26
+    if (!defined('LOG_DIR')) {
27
+        define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
28
+    }
29
+    if (!defined('CACHE_DIR')) {
30
+        define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
31
+    }
32
+    if (!defined('CONFIG_DIR')) {
33
+        define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
34
+    }
35
+    if (!defined('WEB_DIR')) {
36
+        define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
37
+    }
18 38
 
19 39
     //Cargamos en memoria la función de desarrollo PRE
20 40
     if (!function_exists('pre')) {
Please login to merge, or discard this patch.
src/Dispatcher.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     use PSFS\base\Logger;
14 14
     use PSFS\base\Singleton;
15 15
 
16
-    require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php";
16
+    require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php";
17 17
 
18 18
     /**
19 19
      * Class Dispatcher
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
             Logger::log('Set locale to project');
77 77
             $this->locale = $this->config->get("default_language");
78 78
             // Load translations
79
-            putenv("LC_ALL=" . $this->locale);
79
+            putenv("LC_ALL=".$this->locale);
80 80
             setlocale(LC_ALL, $this->locale);
81 81
             // Load the locale path
82
-            $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
82
+            $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
83 83
             Config::createDir($locale_path);
84 84
             bindtextdomain('translations', $locale_path);
85 85
             textdomain('translations');
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
                     if (!$this->parser->isFile()) {
100 100
                         return $this->router->execute($this->actualUri);
101 101
                     }
102
-                } else {
102
+                }else {
103 103
                     return $this->router->getAdmin()->config();
104 104
                 }
105
-            } catch (ConfigException $c) {
105
+            }catch (ConfigException $c) {
106 106
                 return $this->dumpException($c);
107
-            } catch (SecurityException $s) {
107
+            }catch (SecurityException $s) {
108 108
                 return $this->security->notAuthorized($this->actualUri);
109
-            } catch (RouterException $r) {
109
+            }catch (RouterException $r) {
110 110
                 return $this->router->httpNotFound($r);
111
-            } catch (\Exception $e) {
111
+            }catch (\Exception $e) {
112 112
                 return $this->dumpException($e);
113 113
             }
114 114
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                     $use /= 1024;
151 151
                     break;
152 152
                 case "MBytes":
153
-                    $use /= (1024 * 1024);
153
+                    $use /= (1024*1024);
154 154
                     break;
155 155
                 case "Bytes":
156 156
                 default:
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             if ($this->config->getDebugMode()) {
177 177
                 Logger::log('Added handlers for errors');
178 178
                 //Warning & Notice handler
179
-                set_error_handler(function ($errno, $errstr, $errfile, $errline) {
179
+                set_error_handler(function($errno, $errstr, $errfile, $errline) {
180 180
                     Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]);
181 181
                     throw new \Exception($errstr, 500);
182 182
                 });
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
         private function initiateStats()
190 190
         {
191 191
             Logger::log('Initialicing stats (mem + ts)');
192
-            if(null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
192
+            if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
193 193
                 $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
194
-            } else {
194
+            }else {
195 195
                 $this->ts = $this->parser->getTs();
196 196
             }
197 197
             $this->mem = memory_get_usage();
Please login to merge, or discard this patch.
src/base/Singleton.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function __construct()
20 20
     {
21
-        Logger::log(get_class($this) . ' constructor invoked');
21
+        Logger::log(get_class($this).' constructor invoked');
22 22
     }
23 23
 
24 24
     /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param $value
42 42
      */
43 43
     public function __set($variable, $value) {
44
-        if(property_exists(get_class($this), $variable)) {
44
+        if (property_exists(get_class($this), $variable)) {
45 45
             $this->$variable = $value;
46 46
         }
47 47
     }
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
             $setter = "set".ucfirst($variable);
99 99
             if (method_exists($calledClass, $setter)) {
100 100
                 $this->$setter($instance);
101
-            } else {
101
+            }else {
102 102
                 $this->$variable = $instance;
103 103
             }
104
-        } catch (\Exception $e) {
105
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' ['  . $e->getLine() . ']', LOG_ERR);
104
+        }catch (\Exception $e) {
105
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
106 106
         }
107 107
         return $this;
108 108
     }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             }
129 129
             $this->setLoaded();
130 130
         }else {
131
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
131
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
132 132
         }
133 133
     }
134 134
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         if (null === $class) {
143 143
             $class = get_class($this);
144 144
         }
145
-        Logger::log('Extracting annotations properties from class ' . $class);
145
+        Logger::log('Extracting annotations properties from class '.$class);
146 146
         $selfReflector = new \ReflectionClass($class);
147 147
         if (false !== $selfReflector->getParentClass()) {
148 148
             $properties = $this->getClassProperties($selfReflector->getParentClass()->getName());
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
      */
183 183
     private function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)
184 184
     {
185
-        Logger::log('Create inyectable instance for ' . $classNameSpace . ' into ' . get_class($this));
185
+        Logger::log('Create inyectable instance for '.$classNameSpace.' into '.get_class($this));
186 186
         $reflector = new \ReflectionClass($calledClass);
187 187
         $property = $reflector->getProperty($variable);
188 188
         $varInstanceType = (null === $classNameSpace) ? $this->extractVarType($property->getDocComment()) : $classNameSpace;
189 189
         if (true === $singleton && method_exists($varInstanceType, "getInstance")) {
190 190
             $instance = $varInstanceType::getInstance();
191
-        } else {
191
+        }else {
192 192
             $instance = new $varInstanceType();
193 193
         }
194 194
         return $instance;
Please login to merge, or discard this patch.
src/base/types/Api.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
          *
181 181
          * @param ModelCriteria $query
182 182
          */
183
-        private function addOrders(ModelCriteria &$query)
183
+        private function addOrders(ModelCriteria & $query)
184 184
         {
185 185
             $orderAdded = FALSE;
186 186
             foreach ($this->order->getOrders() as $field => $direction) {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                     $orderAdded = TRUE;
189 189
                     if ($direction === Order::ASC) {
190 190
                         $query->addAscendingOrderByColumn($field);
191
-                    } else {
191
+                    }else {
192 192
                         $query->addDescendingOrderByColumn($field);
193 193
                     }
194 194
                 }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
          *
204 204
          * @param ModelCriteria $query
205 205
          */
206
-        private function addExtraColumns(ModelCriteria &$query)
206
+        private function addExtraColumns(ModelCriteria & $query)
207 207
         {
208 208
             if (!empty($this->extraColumns)) {
209 209
                 foreach ($this->extraColumns as $expression => $columnName) {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
          *
218 218
          * @param ModelCriteria $query
219 219
          */
220
-        protected function joinTables(ModelCriteria &$query)
220
+        protected function joinTables(ModelCriteria & $query)
221 221
         {
222 222
             //TODO for specific implementations
223 223
         }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
          *
228 228
          * @param ModelCriteria $query
229 229
          */
230
-        private function addFilters(ModelCriteria &$query)
230
+        private function addFilters(ModelCriteria & $query)
231 231
         {
232 232
             if (count($this->query) > 0) {
233 233
                 foreach ($this->query as $field => $value) {
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                             $text = preg_replace('/(\'|\")/', '', $value);
246 246
                             $text = preg_replace('/\ /', '%', $text);
247 247
                             $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE);
248
-                        } else {
248
+                        }else {
249 249
                             $query->filterBy($tableField, $value, Criteria::EQUAL);
250 250
                         }
251 251
                     }
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
                 list($page, $limit) = $this->extractPagination();
269 269
                 if ($limit == -1) {
270 270
                     $this->list = $query->find($this->con);
271
-                } else {
271
+                }else {
272 272
                     $this->list = $query->paginate($page, $limit, $this->con);
273 273
                 }
274
-            } catch (\Exception $e) {
274
+            }catch (\Exception $e) {
275 275
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
276 276
             }
277 277
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
                 $this->joinTables($query);
289 289
                 $this->addExtraColumns($query);
290 290
                 $this->model = $query->findPk($pk);
291
-            } catch (\Exception $e) {
291
+            }catch (\Exception $e) {
292 292
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
293 293
             }
294 294
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                     $saved = TRUE;
377 377
                     $model = $this->model->toArray();
378 378
                 }
379
-            } catch (\Exception $e) {
379
+            }catch (\Exception $e) {
380 380
                 jpre($e->getMessage(), TRUE);
381 381
                 Logger::getInstance()->errorLog($e->getMessage());
382 382
             }
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                         $this->model->delete($this->con);
406 406
                         $deleted = TRUE;
407 407
                     }
408
-                } catch (\Exception $e) {
408
+                }catch (\Exception $e) {
409 409
                     Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
410 410
                 }
411 411
             }
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
          */
450 450
         private function extractQuery()
451 451
         {
452
-            $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query");
452
+            $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query");
453 453
             /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */
454 454
             $query = $queryReflector->getMethod('create')->invoke(NULL);
455 455
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
             if ($this->con->inTransaction()) {
494 494
                 if ($status === 200) {
495 495
                     $this->con->commit();
496
-                } else {
496
+                }else {
497 497
                     $this->con->rollBack();
498 498
                 }
499 499
             }
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
             return $this->render('api.admin.html.twig', array(
538 538
                 "api"    => $this->getApi(),
539 539
                 "domain" => $this->domain,
540
-                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)),
540
+                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)),
541 541
             ));
542 542
         }
543 543
 
@@ -559,16 +559,16 @@  discard block
 block discarded – undo
559 559
             /** @var TableMap $map */
560 560
             $map = $this->getModelTableMap();
561 561
             $fields = $map::getTableMap();
562
-            foreach($fields->getFieldNames() as $field) {
562
+            foreach ($fields->getFieldNames() as $field) {
563 563
                 $fDto = new Field($field, _($field));
564 564
                 /** @var ColumnMap $mappedColumn */
565 565
                 $mappedColumn = $fields->getColumn($field);
566
-                if($mappedColumn->isForeignKey()) {
566
+                if ($mappedColumn->isForeignKey()) {
567 567
                     $fDto->type = Field::COMBO_TYPE;
568 568
                     $fDto->required = $mappedColumn->isNotNull();
569 569
                     $relatedModel = strtolower($mappedColumn->getRelation()->getForeignTable()->getPhpName());
570 570
                     $fDto->entity = $relatedModel;
571
-                    $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel . '-pk');
571
+                    $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel.'-pk');
572 572
                 } elseif ($mappedColumn->isPrimaryKey()) {
573 573
                     $fDto->type = Field::HIDDEN_TYPE;
574 574
                     $fDto->required = false;
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                 $return = $this->list->toArray();
596 596
                 $total = $this->list->getNbResults();
597 597
                 $pages = $this->list->getLastPage();
598
-            } catch (\Exception $e) {
598
+            }catch (\Exception $e) {
599 599
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
600 600
             }
601 601
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
             $return = array();
616 616
             if (NULL === $model) {
617 617
                 $code = 404;
618
-            } else {
618
+            }else {
619 619
                 $return = $model->toArray();
620 620
             }
621 621
 
Please login to merge, or discard this patch.
src/base/Service.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $this->url = NULL;
178 178
             $this->params = array();
179 179
             $this->headers = array();
180
-            Logger::log("Context service for " . get_called_class() . " cleared!");
180
+            Logger::log("Context service for ".get_called_class()." cleared!");
181 181
         }
182 182
 
183 183
         /**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
         protected function setOpts()
210 210
         {
211
-            switch(strtoupper($this->type)) {
211
+            switch (strtoupper($this->type)) {
212 212
                 case 'GET':
213 213
                 default:
214 214
                     curl_setopt($this->con, CURLOPT_CUSTOMREQUEST, "GET");
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
          */
60 60
         public function init()
61 61
         {
62
-            if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) {
62
+            if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) {
63 63
                 $this->hydrateRouting();
64 64
                 $this->simpatize();
65
-            } else {
66
-                list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE);
67
-                $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE);
65
+            }else {
66
+                list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE);
67
+                $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE);
68 68
             }
69 69
         }
70 70
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                     "success" => FALSE,
85 85
                     "error"   => $e->getMessage(),
86 86
                 )), 'application/json');
87
-            } else {
87
+            }else {
88 88
                 if (NULL === $e) {
89 89
                     Logger::log('Not found page throwed without previus exception');
90 90
                     $e = new \Exception(_('Page not found'), 404);
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
                 $this->checkRestrictedAccess($route);
126 126
                 //Search action and execute
127 127
                 return $this->searchAction($route);
128
-            } catch (AccessDeniedException $e) {
128
+            }catch (AccessDeniedException $e) {
129 129
                 Logger::getInstance()->debugLog(_('Solicitamos credenciales de acceso a zona restringida'));
130 130
                 if ('login' === Config::getInstance()->get('admin_login')) {
131 131
                     return $this->redirectLogin($route);
132
-                } else {
132
+                }else {
133 133
                     return $this->sentAuthHeader();
134 134
                 }
135
-            } catch (RouterException $r) {
135
+            }catch (RouterException $r) {
136 136
                 if (FALSE !== preg_match('/\/$/', $route)) {
137 137
                     if (preg_match('/admin/', $route)) {
138 138
                         $default = Config::getInstance()->get('admin_action');
139
-                    } else {
139
+                    }else {
140 140
                         $default = Config::getInstance()->get('home_action');
141 141
                     }
142 142
 
143 143
                     return $this->execute($this->getRoute($default));
144 144
                 }
145
-            } catch (\Exception $e) {
145
+            }catch (\Exception $e) {
146 146
                 Logger::getInstance()->errorLog($e->getMessage());
147 147
                 throw $e;
148 148
             }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             $corsEnabled = Config::getInstance()->get('cors.enabled');
160 160
             $request = Request::getInstance();
161 161
             if (NULL !== $corsEnabled && null !== $request->getServer('HTTP_REFERER')) {
162
-                if($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) {
162
+                if ($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) {
163 163
                     if (!$this->headersSent) {
164 164
                         // TODO include this headers in Template class output method
165 165
                         header("Access-Control-Allow-Credentials: true");
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                         header("Access-Control-Allow-Headers: Access-Control-Allow-Methods, Access-Control-Allow-Headers, Access-Control-Allow-Origin, Origin, X-Requested-With, Content-Type, Accept, Authorization, X-API-SEC-TOKEN, X-API-USER-TOKEN");
169 169
                         $this->headersSent = true;
170 170
                     }
171
-                    if(Request::getInstance()->getMethod() == 'OPTIONS') {
171
+                    if (Request::getInstance()->getMethod() == 'OPTIONS') {
172 172
                         Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests');
173
-                        header( "HTTP/1.1 200 OK" );
173
+                        header("HTTP/1.1 200 OK");
174 174
                         exit();
175 175
                     }
176 176
                 }
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
          */
186 186
         private function compareSlashes($routePattern, $path) {
187 187
             $pattern_sep = count(explode('/', $routePattern));
188
-            if(preg_match('/\/$/', $routePattern)) {
188
+            if (preg_match('/\/$/', $routePattern)) {
189 189
                 $pattern_sep--;
190 190
             }
191 191
             $path_sep = count(explode('/', $path));
192
-            if(preg_match('/\/$/', $path)) {
192
+            if (preg_match('/\/$/', $path)) {
193 193
                 $path_sep--;
194 194
             }
195 195
             return abs($pattern_sep - $path_sep) < 1;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                     $class = $this->getClassToCall($action);
219 219
                     try {
220 220
                         return $this->executeCachedRoute($route, $action, $class, $get);
221
-                    } catch (\Exception $e) {
221
+                    }catch (\Exception $e) {
222 222
                         Logger::log($e->getMessage(), LOG_ERR);
223 223
                         throw new RouterException($e->getMessage(), 404, $e);
224 224
                     }
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
             if (file_exists($modules)) {
309 309
                 $this->routing = $this->inspectDir($modules, "", $this->routing);
310 310
             }
311
-            $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
311
+            $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
312 312
             $home = Config::getInstance()->get('home_action');
313 313
             if (NULL !== $home || $home !== '') {
314 314
                 $home_params = NULL;
315 315
                 foreach ($this->routing as $pattern => $params) {
316 316
                     list($method, $route) = $this->extractHttpRoute($pattern);
317
-                    if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
317
+                    if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
318 318
                         $home_params = $params;
319 319
                     }
320 320
                 }
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php");
340 340
             foreach ($files as $file) {
341 341
                 $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
342
-                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing);
342
+                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing);
343 343
             }
344 344
             $this->finder = new Finder();
345 345
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
                                 $httpMethod = $this->extractReflectionHttpMethod($docComments);
381 381
                                 $visible = $this->extractReflectionVisibility($docComments);
382 382
                                 $expiration = $this->extractReflectionCacheability($docComments);
383
-                                $routing[$httpMethod . "#|#" . $regex] = array(
383
+                                $routing[$httpMethod."#|#".$regex] = array(
384 384
                                     "class"   => $namespace,
385 385
                                     "method"  => $method->getName(),
386 386
                                     "params"  => $params,
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
         {
411 411
             //Calculamos los dominios para las plantillas
412 412
             if ($class->hasConstant("DOMAIN")) {
413
-                $domain = "@" . $class->getConstant("DOMAIN") . "/";
414
-                $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
415
-                $path = realpath($path) . DIRECTORY_SEPARATOR;
413
+                $domain = "@".$class->getConstant("DOMAIN")."/";
414
+                $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
415
+                $path = realpath($path).DIRECTORY_SEPARATOR;
416 416
                 $tpl_path = "templates";
417 417
                 $public_path = "public";
418 418
                 $model_path = "models";
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
                     $model_path = ucfirst($model_path);
423 423
                 }
424 424
                 if ($class->hasConstant("TPL")) {
425
-                    $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL");
425
+                    $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL");
426 426
                 }
427 427
                 $this->domains[$domain] = array(
428
-                    "template" => $path . $tpl_path,
429
-                    "model"    => $path . $model_path,
430
-                    "public"   => $path . $public_path,
428
+                    "template" => $path.$tpl_path,
429
+                    "model"    => $path.$model_path,
430
+                    "public"   => $path.$public_path,
431 431
                 );
432 432
             }
433 433
 
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
          */
441 441
         public function simpatize()
442 442
         {
443
-            $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
444
-            $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
443
+            $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
444
+            $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
445 445
             $this->generateSlugs($absoluteTranslationFileName);
446 446
             Config::createDir(CONFIG_DIR);
447
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
447
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
448 448
 
449 449
             return $this;
450 450
         }
@@ -495,16 +495,16 @@  discard block
 block discarded – undo
495 495
         public function getRoute($slug = '', $absolute = FALSE, $params = NULL)
496 496
         {
497 497
             if (strlen($slug) === 0) {
498
-                return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
498
+                return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
499 499
             }
500 500
             if (NULL === $slug || !array_key_exists($slug, $this->slugs)) {
501 501
                 throw new RouterException(_("No existe la ruta especificada"));
502 502
             }
503
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
503
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
504 504
             if (!empty($params)) foreach ($params as $key => $value) {
505
-                $url = str_replace("{" . $key . "}", $value, $url);
505
+                $url = str_replace("{".$key."}", $value, $url);
506 506
             } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
507
-                $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
507
+                $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
508 508
             }
509 509
 
510 510
             return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -522,12 +522,12 @@  discard block
 block discarded – undo
522 522
                 if (preg_match('/^\/admin(\/|$)/', $routePattern)) {
523 523
                     if (preg_match('/^PSFS/', $params["class"])) {
524 524
                         $profile = "superadmin";
525
-                    } else {
525
+                    }else {
526 526
                         $profile = "admin";
527 527
                     }
528 528
                     if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) {
529 529
                         $_profile = ($params["visible"]) ? $profile : 'adminhidden';
530
-                        if(!array_key_exists($_profile, $routes)) {
530
+                        if (!array_key_exists($_profile, $routes)) {
531 531
                             $routes[$_profile] = array();
532 532
                         }
533 533
                         $routes[$_profile][] = $params["slug"];
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
         protected function getClassToCall($action)
575 575
         {
576 576
             Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
577
-            $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"];
577
+            $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"];
578 578
             $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass;
579 579
             return $class;
580 580
         }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
             $expr = preg_quote($expr, '/');
594 594
             $expr = str_replace('###', '(.*)', $expr);
595 595
             $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
596
-            $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
596
+            $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
597 597
             return $matched;
598 598
         }
599 599
 
@@ -630,9 +630,9 @@  discard block
 block discarded – undo
630 630
             if (count($parameters) > 0) foreach ($parameters as $param) {
631 631
                 if ($param->isOptional() && !is_array($param->getDefaultValue())) {
632 632
                     $params[$param->getName()] = $param->getDefaultValue();
633
-                    $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
633
+                    $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
634 634
                 }
635
-            } else $default = $regex;
635
+            }else $default = $regex;
636 636
 
637 637
             return array($regex, $default, $params);
638 638
         }
@@ -688,16 +688,16 @@  discard block
 block discarded – undo
688 688
          */
689 689
         protected function executeCachedRoute($route, $action, $class, $params = NULL)
690 690
         {
691
-            Logger::log('Executing route ' . $route);
691
+            Logger::log('Executing route '.$route);
692 692
             $this->session->setSessionKey("__CACHE__", $action);
693 693
             $cache = Cache::needCache();
694 694
             $execute = TRUE;
695 695
             if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
696 696
                 $cacheDataName = $this->cache->getRequestCacheHash();
697
-                $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () {
697
+                $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() {
698 698
                 });
699 699
                 if (NULL !== $cachedData) {
700
-                    $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () {
700
+                    $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() {
701 701
                     }, Cache::JSON);
702 702
                     Template::getInstance()->renderCache($cachedData, $headers);
703 703
                     $execute = FALSE;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
             $translations = array();
747 747
             if (file_exists($absoluteTranslationFileName)) {
748 748
                 include($absoluteTranslationFileName);
749
-            } else {
749
+            }else {
750 750
                 Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
751 751
             }
752 752
 
Please login to merge, or discard this patch.