Passed
Push — master ( ee5866...de68c3 )
by Fran
05:07
created
src/base/types/AuthApi.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
         {
27 27
             $namespace = explode('\\', $this->getModelTableMap());
28 28
             $module = strtolower($namespace[0]);
29
-            $secret = Config::getInstance()->get($module . '.api.secret');
29
+            $secret = Config::getInstance()->get($module.'.api.secret');
30 30
             if (NULL === $secret) {
31 31
                 $secret = Config::getInstance()->get("api.secret");
32 32
             }
33 33
             if (NULL === $secret) {
34 34
                 $auth = TRUE;
35
-            } else {
35
+            }else {
36 36
                 $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN');
37 37
                 if (array_key_exists('API_TOKEN', $this->query)) {
38 38
                     $token = $this->query['API_TOKEN'];
Please login to merge, or discard this patch.
src/base/types/interfaces/AuthInterface.php 1 patch
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -7,7 +7,19 @@
 block discarded – undo
7 7
  * @package PSFS\base\types\interfaces
8 8
  */
9 9
 interface AuthInterface {
10
+
11
+    /**
12
+     * @return boolean
13
+     */
10 14
     function isLogged();
15
+
16
+    /**
17
+     * @return boolean
18
+     */
11 19
     function isAdmin();
20
+
21
+    /**
22
+     * @return boolean
23
+     */
12 24
     function canDo($action);
13 25
 }
Please login to merge, or discard this patch.
src/base/types/interfaces/ControllerInterface.php 1 patch
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -7,6 +7,14 @@
 block discarded – undo
7 7
  * @package PSFS\base\types\interfaces
8 8
  */
9 9
 interface ControllerInterface {
10
+
11
+    /**
12
+     * @return string|null
13
+     */
10 14
     public function render($template, Array $vars = null);
15
+
16
+    /**
17
+     * @return void
18
+     */
11 19
     public function response($response, $type = 'text/html');
12 20
 }
Please login to merge, or discard this patch.
src/services/DocumentorService.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -371,7 +371,7 @@
 block discarded – undo
371 371
          * @param array $parts
372 372
          * @param int $partLength
373 373
          *
374
-         * @return array
374
+         * @return string[]
375 375
          */
376 376
         private static function extractTsAndMod(array &$parts, $partLength)
377 377
         {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -422,7 +422,7 @@
 block discarded – undo
422 422
                                 "type" => $type,
423 423
                             ];
424 424
                             if (strlen($format)) {
425
-                               $dto['properties'][$field]['format'] = $format;
425
+                                $dto['properties'][$field]['format'] = $format;
426 426
                             }
427 427
                         }
428 428
                     }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
                         if (!preg_match('/^\@ROOT/i', $domain)) {
34 34
                             $modules[] = str_replace('/', '', str_replace('@', '', $domain));
35 35
                         }
36
-                    } catch (\Exception $e) {
36
+                    }catch (\Exception $e) {
37 37
                         $modules[] = $e->getMessage();
38 38
                     }
39 39
                 }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
          */
52 52
         public function extractApiEndpoints($module)
53 53
         {
54
-            $module_path = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Api";
54
+            $module_path = CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Api";
55 55
             $endpoints = [];
56 56
             if (file_exists($module_path)) {
57 57
                 $finder = new Finder();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                 if (count($finder)) {
60 60
                     /** @var \SplFileInfo $file */
61 61
                     foreach ($finder as $file) {
62
-                        $namespace = "\\{$module}\\Api\\" . str_replace('.php', '', $file->getFilename());
62
+                        $namespace = "\\{$module}\\Api\\".str_replace('.php', '', $file->getFilename());
63 63
                         $endpoints[$namespace] = $this->extractApiInfo($namespace);
64 64
                     }
65 65
                 }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                         if (NULL !== $mInfo) {
89 89
                             $info[] = $mInfo;
90 90
                         }
91
-                    } catch (\Exception $e) {
91
+                    }catch (\Exception $e) {
92 92
                         Logger::getInstance()->errorLog($e->getMessage());
93 93
                     }
94 94
                 }
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
             if ($reflector->isSubclassOf(self::DTO_INTERFACE)) {
222 222
                 foreach ($reflector->getProperties(\ReflectionMethod::IS_PUBLIC) as $property) {
223 223
                     $type = $this->extractVarType($property->getDocComment());
224
-                    if(class_exists($type)) {
224
+                    if (class_exists($type)) {
225 225
                         $properties[$property->getName()] = $this->extractModelFields($type);
226
-                    } else {
226
+                    }else {
227 227
                         $properties[$property->getName()] = $type;
228 228
                     }
229 229
                 }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
          */
243 243
         protected function extractReturn($model, $comments = '')
244 244
         {
245
-            $modelDto  = [];
245
+            $modelDto = [];
246 246
             preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes);
247 247
             if (count($returnTypes)) {
248 248
                 // Extract principal DTO information
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                 } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
296 296
                     $payload = $this->extractDtoProperties($namespace);
297 297
                 }
298
-            } catch (\Exception $e) {
298
+            }catch (\Exception $e) {
299 299
                 Logger::getInstance()->errorLog($e->getMessage());
300 300
             }
301 301
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                         if (in_array($methodInfo['method'], ['POST', 'PUT'])) {
332 332
                             $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments);
333 333
                         }
334
-                    } catch (\Exception $e) {
334
+                    }catch (\Exception $e) {
335 335
                         jpre($e->getMessage());
336 336
                         Logger::getInstance()->errorLog($e->getMessage());
337 337
                     }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
          */
350 350
         public static function translateSwaggerFormats($format)
351 351
         {
352
-            switch(strtolower($format)) {
352
+            switch (strtolower($format)) {
353 353
                 case 'bool':
354 354
                 case 'boolean':
355 355
                     $swaggerType = 'boolean';
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
                             ]]);
411 411
                             if (array_key_exists($subDtoName, $subDto)) {
412 412
                                 $definitions = $subDto;
413
-                            } else {
413
+                            }else {
414 414
                                 $definitions[$subDtoName] = $subDto;
415 415
                             }
416 416
                             $dto['properties'][$field] = [
417
-                                '$ref' => "#/definitions/" . $subDtoName,
417
+                                '$ref' => "#/definitions/".$subDtoName,
418 418
                             ];
419
-                        } else {
419
+                        }else {
420 420
                             list($type, $format) = self::translateSwaggerFormats($format);
421 421
                             $dto['properties'][$field] = [
422 422
                                 "type" => $type,
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
                     "url" => Router::getInstance()->getRoute(''),
454 454
                 ]
455 455
             ];
456
-            foreach($endpoints as $model) {
456
+            foreach ($endpoints as $model) {
457 457
                 foreach ($model as $endpoint) {
458 458
                     $dtos += self::extractSwaggerDefinition($endpoint);
459 459
                 }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
         protected function extractDtoName($dto, $isArray = false)
473 473
         {
474 474
             $dto = explode('\\', $dto);
475
-            $modelDto = array_pop($dto) . "Dto";
475
+            $modelDto = array_pop($dto)."Dto";
476 476
             if ($isArray) {
477 477
                 $modelDto .= "List";
478 478
             }
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/services/GeneratorService.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -380,7 +380,7 @@
 block discarded – undo
380 380
                 if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
381 381
                     if (is_dir($filename_path)) {
382 382
                         self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
383
-                    }else {
383
+                    } else {
384 384
                         if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
385 385
                             throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
386 386
                         }
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
         /**
27 27
          * Método que revisa las traducciones directorio a directorio
28
-         * @param $path
28
+         * @param string $path
29 29
          * @param $locale
30 30
          * @return array
31 31
          */
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
          * @param string $module
66 66
          * @param boolean $force
67 67
          * @param string $type
68
-         * @param boolean $is_module
68
+         * @param boolean $isModule
69 69
          * @return mixed
70 70
          */
71 71
         public function createStructureModule($module, $force = false, $type = "", $isModule = false)
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 
100 100
         /**
101 101
          * Servicio que genera la estructura base
102
-         * @param $module
103
-         * @param $mod_path
102
+         * @param string $module
103
+         * @param string $mod_path
104 104
          * @param boolean $isModule
105 105
          */
106 106
         private function createModulePathTree($module, $mod_path, $isModule = false)
@@ -230,7 +230,6 @@  discard block
 block discarded – undo
230 230
         }
231 231
 
232 232
         /**
233
-         * @param string $module
234 233
          * @param string $mod_path
235 234
          * @param boolean $force
236 235
          * @return boolean
@@ -402,7 +401,7 @@  discard block
 block discarded – undo
402 401
          * Method that copy resources recursively
403 402
          * @param string $dest
404 403
          * @param boolean $force
405
-         * @param $filename_path
404
+         * @param string $filename_path
406 405
          * @param boolean $debug
407 406
          */
408 407
         public static function copyResources($dest, $force, $filename_path, $debug)
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
     use PSFS\base\exception\ConfigException;
7 7
     use PSFS\base\Service;
8 8
 
9
-    class GeneratorService extends Service{
9
+    class GeneratorService extends Service {
10 10
         /**
11 11
          * @Inyectable
12 12
          * @var \PSFS\base\config\Config Servicio de configuración
@@ -31,25 +31,25 @@  discard block
 block discarded – undo
31 31
          */
32 32
         public static function findTranslations($path, $locale)
33 33
         {
34
-            $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
35
-            $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
34
+            $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
35
+            $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
36 36
 
37 37
             $translations = array();
38
-            if(file_exists($path))
38
+            if (file_exists($path))
39 39
             {
40 40
                 $d = dir($path);
41
-                while(false !== ($dir = $d->read()))
41
+                while (false !== ($dir = $d->read()))
42 42
                 {
43 43
                     Config::createDir($locale_path);
44
-                    if(!file_exists($locale_path . 'translations.po')) {
45
-                        file_put_contents($locale_path . 'translations.po', '');
44
+                    if (!file_exists($locale_path.'translations.po')) {
45
+                        file_put_contents($locale_path.'translations.po', '');
46 46
                     }
47 47
                     $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir);
48
-                    $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ". $inspect_path . DIRECTORY_SEPARATOR ."*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po";
49
-                    if(is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./',$dir) == 0)
48
+                    $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ".$inspect_path.DIRECTORY_SEPARATOR."*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po";
49
+                    if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0)
50 50
                     {
51
-                        $res = _('Revisando directorio: ') . $inspect_path;
52
-                        $res .= _('Comando ejecutado: '). $cmd_php;
51
+                        $res = _('Revisando directorio: ').$inspect_path;
52
+                        $res .= _('Comando ejecutado: ').$cmd_php;
53 53
                         $res .= shell_exec($cmd_php);
54 54
                         usleep(10);
55 55
                         $translations[] = $res;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
          */
71 71
         public function createStructureModule($module, $force = false, $type = "", $isModule = false)
72 72
         {
73
-            $mod_path = CORE_DIR . DIRECTORY_SEPARATOR;
73
+            $mod_path = CORE_DIR.DIRECTORY_SEPARATOR;
74 74
             $module = ucfirst($module);
75 75
             $this->createModulePath($module, $mod_path, $isModule);
76 76
             $this->createModulePathTree($module, $mod_path, $isModule);
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
             // Creates the src folder
93 93
             Config::createDir($mod_path);
94 94
             // Create module path
95
-            if(false === $isModule) {
96
-                Config::createDir($mod_path . $module);
95
+            if (false === $isModule) {
96
+                Config::createDir($mod_path.$module);
97 97
             }
98 98
         }
99 99
 
@@ -108,20 +108,20 @@  discard block
 block discarded – undo
108 108
             //Creamos las carpetas CORE del módulo
109 109
             $this->log->infoLog("Generamos la estructura");
110 110
             $paths = array("Api", "Api/base", "Config", "Controller", "Form", "Models", "Public", "Templates", "Services", "Test");
111
-            $module_path = $isModule ? $mod_path : $mod_path . $module;
112
-            foreach($paths as $path) {
113
-                Config::createDir($module_path . DIRECTORY_SEPARATOR . $path);
111
+            $module_path = $isModule ? $mod_path : $mod_path.$module;
112
+            foreach ($paths as $path) {
113
+                Config::createDir($module_path.DIRECTORY_SEPARATOR.$path);
114 114
             }
115 115
             //Creamos las carpetas de los assets
116 116
             $htmlPaths = array("css", "js", "img", "media", "font");
117
-            foreach($htmlPaths as $path) {
118
-                Config::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path);
117
+            foreach ($htmlPaths as $path) {
118
+                Config::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path);
119 119
             }
120 120
 
121
-            if($isModule) {
121
+            if ($isModule) {
122 122
                 return $this->writeTemplateToFile(json_encode([
123
-                    "module" => "\\" . preg_replace('/(\\\|\/)/', '\\\\',$module),
124
-                ], JSON_PRETTY_PRINT), $mod_path . DIRECTORY_SEPARATOR . "module.json", true);
123
+                    "module" => "\\".preg_replace('/(\\\|\/)/', '\\\\', $module),
124
+                ], JSON_PRETTY_PRINT), $mod_path.DIRECTORY_SEPARATOR."module.json", true);
125 125
             }
126 126
         }
127 127
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
          */
136 136
         private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '', $isModule = false)
137 137
         {
138
-            $module_path = $isModule ? $mod_path : $mod_path . $module;
138
+            $module_path = $isModule ? $mod_path : $mod_path.$module;
139 139
             $this->generateControllerTemplate($module, $module_path, $force, $controllerType);
140 140
             $this->generateServiceTemplate($module, $module_path, $force);
141 141
             $this->genereateAutoloaderTemplate($module, $module_path, $force, $isModule);
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
          */
155 155
         private function createModuleModels($module, $path, $isModule = false)
156 156
         {
157
-            $module_path = $isModule ? $path : $path . $module;
158
-            $module_path = str_replace(BASE_DIR . DIRECTORY_SEPARATOR, '', $module_path);
157
+            $module_path = $isModule ? $path : $path.$module;
158
+            $module_path = str_replace(BASE_DIR.DIRECTORY_SEPARATOR, '', $module_path);
159 159
             //Generamos las clases de propel y la configuración
160
-            $exec = "export PATH=\$PATH:/opt/local/bin; " . BASE_DIR . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "propel ";
161
-            $schemaOpt = " --schema-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config";
162
-            $opt = " --config-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config --output-dir=" . CORE_DIR . " --verbose";
163
-            $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n" . $exec . "build" . $opt . $schemaOpt);
164
-            $ret = shell_exec($exec . "build" . $opt . $schemaOpt);
160
+            $exec = "export PATH=\$PATH:/opt/local/bin; ".BASE_DIR.DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."propel ";
161
+            $schemaOpt = " --schema-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config";
162
+            $opt = " --config-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config --output-dir=".CORE_DIR." --verbose";
163
+            $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n".$exec."build".$opt.$schemaOpt);
164
+            $ret = shell_exec($exec."build".$opt.$schemaOpt);
165 165
 
166 166
             $this->log->infoLog("[GENERATOR] Generamos clases invocando a propel:\n $ret");
167
-            $ret = shell_exec($exec . "sql:build" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config" . $schemaOpt);
167
+            $ret = shell_exec($exec."sql:build".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config".$schemaOpt);
168 168
             $this->log->infoLog("[GENERATOR] Generamos sql invocando a propel:\n $ret");
169
-            $ret = shell_exec($exec . "config:convert" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config");
169
+            $ret = shell_exec($exec."config:convert".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config");
170 170
             $this->log->infoLog("[GENERATOR] Generamos configuración invocando a propel:\n $ret");
171 171
         }
172 172
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 "class" => $class,
190 190
                 "controllerType" => $controllerType,
191 191
             ));
192
-            return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "Controller" . DIRECTORY_SEPARATOR . "{$class}Controller.php", $force);
192
+            return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."Controller".DIRECTORY_SEPARATOR."{$class}Controller.php", $force);
193 193
         }
194 194
 
195 195
         /**
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
         private function generateBaseApiTemplate($module, $mod_path, $force = false, $controllerType = "")
203 203
         {
204 204
             $created = true;
205
-            $modelPath = $mod_path . $module . DIRECTORY_SEPARATOR . 'Models';
206
-            if(file_exists($modelPath)) {
205
+            $modelPath = $mod_path.$module.DIRECTORY_SEPARATOR.'Models';
206
+            if (file_exists($modelPath)) {
207 207
                 $dir = dir($modelPath);
208
-                while($file = $dir->read()) {
209
-                    if(!in_array($file, array('.', '..')) && !preg_match('/Query\.php$/i', $file) && preg_match('/\.php$/i', $file)) {
208
+                while ($file = $dir->read()) {
209
+                    if (!in_array($file, array('.', '..')) && !preg_match('/Query\.php$/i', $file) && preg_match('/\.php$/i', $file)) {
210 210
                         $filename = str_replace(".php", "", $file);
211 211
                         $this->log->infoLog("Generamos Api BASES para {$filename}");
212 212
                         $this->createApiBaseFile($module, $mod_path, $filename);
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         {
227 227
             //Generamos el fichero de configuración
228 228
             $this->log->infoLog("Generamos fichero vacío de configuración");
229
-            return $this->writeTemplateToFile("<?php\n\t", $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", $force);
229
+            return $this->writeTemplateToFile("<?php\n\t", $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", $force);
230 230
         }
231 231
 
232 232
         /**
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
         {
240 240
             //Generamos el fichero de configuración
241 241
             $this->log->infoLog("Generamos ficheros para assets base");
242
-            $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", $force);
243
-            $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", $force);
242
+            $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", $force);
243
+            $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", $force);
244 244
             return ($css && $js);
245 245
         }
246 246
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                 "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
261 261
                 "class" => $class,
262 262
             ));
263
-            return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", $force);
263
+            return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", $force);
264 264
         }
265 265
 
266 266
         /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                 "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module),
281 281
                 "is_module" => $isModule,
282 282
             ));
283
-            return $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force);
283
+            return $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force);
284 284
         }
285 285
 
286 286
         /**
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                 "prefix" => preg_replace('/(\\\|\/)/', '', $module),
300 300
                 "db"     => $this->config->get("db_name"),
301 301
             ));
302
-            return $this->writeTemplateToFile($schema, $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", $force);
302
+            return $this->writeTemplateToFile($schema, $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", $force);
303 303
         }
304 304
 
305 305
         /**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
                 "db"     => $this->config->get("db_name"),
321 321
                 "namespace" => preg_replace('/(\\\|\/)/', '', $module),
322 322
             ));
323
-            return $this->writeTemplateToFile($build_properties, $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", $force);
323
+            return $this->writeTemplateToFile($build_properties, $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", $force);
324 324
         }
325 325
 
326 326
         /**
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             $index = $this->tpl->dump("generator/index.template.twig", array(
337 337
                 "module" => $module,
338 338
             ));
339
-            return $this->writeTemplateToFile($index, $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", $force);
339
+            return $this->writeTemplateToFile($index, $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", $force);
340 340
         }
341 341
 
342 342
         /**
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
             $created = false;
351 351
             if ($force || !file_exists($filename)) {
352 352
                 try {
353
-                    $this->cache->storeData($filename, $fileContent, Cache::TEXT,true);
353
+                    $this->cache->storeData($filename, $fileContent, Cache::TEXT, true);
354 354
                     $created = true;
355
-                } catch(\Exception $e) {
355
+                }catch (\Exception $e) {
356 356
                     $this->log->errorLog($e->getMessage());
357 357
                 }
358
-            } else{
359
-                $this->log->errorLog($filename . _(' not exists or cant write'));
358
+            }else {
359
+                $this->log->errorLog($filename._(' not exists or cant write'));
360 360
             }
361 361
             return $created;
362 362
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                 "api"            => $api
377 377
             ));
378 378
 
379
-            return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Api" . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true);
379
+            return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Api".DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true);
380 380
         }
381 381
 
382 382
         /**
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
                 "api"            => $api
396 396
             ));
397 397
 
398
-            return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Api" . DIRECTORY_SEPARATOR . "{$api}.php", $force);
398
+            return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Api".DIRECTORY_SEPARATOR."{$api}.php", $force);
399 399
         }
400 400
 
401 401
         /**
Please login to merge, or discard this patch.
src/services/AdminServices.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
     use PSFS\controller\Admin;
7 7
     use Symfony\Component\Finder\Finder;
8 8
 
9
-    class AdminServices extends Service{
9
+    class AdminServices extends Service {
10 10
 
11 11
         /**
12 12
          * @Inyectable
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
          */
31 31
         public function setAdminHeaders()
32 32
         {
33
-            if("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup");
33
+            if ("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup");
34 34
             $platform = trim(Config::getInstance()->get("platform_name"));
35 35
             header('HTTP/1.1 401 Unauthorized');
36
-            header('WWW-Authenticate: Basic Realm="' . $platform. '"');
36
+            header('WWW-Authenticate: Basic Realm="'.$platform.'"');
37 37
             echo _("Zona restringida");
38 38
             exit();
39 39
         }
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
         public function getAdmins()
46 46
         {
47 47
             $admins = $this->security->getAdmins();
48
-            if(!empty($admins))
48
+            if (!empty($admins))
49 49
             {
50
-                if(!$this->security->checkAdmin())
50
+                if (!$this->security->checkAdmin())
51 51
                 {
52 52
                     $this->setAdminHeaders();
53 53
                 }
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
          */
63 63
         private function parseAdmins(&$admins)
64 64
         {
65
-            if(!empty($admins)) foreach($admins as &$admin)
65
+            if (!empty($admins)) foreach ($admins as &$admin)
66 66
             {
67
-                if(isset($admin["profile"]))
67
+                if (isset($admin["profile"]))
68 68
                 {
69
-                    switch($admin["profile"]) {
69
+                    switch ($admin["profile"]) {
70 70
                         case sha1('admin'): $admin['class'] = 'warning'; break;
71 71
                         case sha1('superadmin'): $admin['class'] = 'info'; break;
72 72
                         default:
73 73
                         case sha1('user'): $admin['class'] = 'primary'; break;
74 74
                     }
75
-                }else{
75
+                }else {
76 76
                     $admin["class"] = "primary";
77 77
                 }
78 78
             }
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
             $files->files()->in(LOG_DIR)->name("*.log")->sortByModifiedTime();
89 89
             $logs = array();
90 90
             /** @var \SplFileInfo $file */
91
-            foreach($files as $file)
91
+            foreach ($files as $file)
92 92
             {
93
-                $size = $file->getSize() / 8 / 1024;
93
+                $size = $file->getSize()/8/1024;
94 94
                 $time = date("c", $file->getMTime());
95 95
                 $dateTime = new \DateTime($time);
96
-                if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array();
96
+                if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array();
97 97
                 $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array(
98 98
                     "filename" => $file->getFilename(),
99 99
                     "size" => round($size, 3)
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
             $files->files()->in(LOG_DIR)->name($selectedLog);
118 118
             $file = null;
119 119
             $log = array();
120
-            foreach($files as $match)
120
+            foreach ($files as $match)
121 121
             {
122 122
                 $file = $match;
123 123
                 break;
124 124
             }
125 125
             /** @var \SplFileInfo $file */
126
-            if(!empty($file))
126
+            if (!empty($file))
127 127
             {
128 128
                 $time = date("c", $file->getMTime());
129 129
                 $dateTime = new \DateTime($time);
130 130
                 $monthOpen = $dateTime->format("m");
131
-                $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename());
131
+                $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename());
132 132
                 krsort($content);
133 133
                 $detailLog = array();
134
-                foreach($content as &$line)
134
+                foreach ($content as &$line)
135 135
                 {
136 136
                     list($line, $detail) = $this->parseLogLine($line, $match);
137 137
                     $detailLog[] = array_merge(array(
138 138
                         "log" => $line,
139 139
                     ), $detail);
140
-                    if(count($detailLog) >= 1000) break;
140
+                    if (count($detailLog) >= 1000) break;
141 141
                 }
142 142
                 $log = $detailLog;
143 143
             }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
                 $type = (isset($match[1][0])) ? $match[1][0] : '';
168 168
                 $type = explode(".", $type);
169
-                $type = count($type)>1 ? $type[1] : $type[0];
169
+                $type = count($type) > 1 ? $type[1] : $type[0];
170 170
                 switch ($type) {
171 171
                     case 'INFO':
172 172
                         $detail["type"] = "success";
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                         break;
183 183
                 }
184 184
 
185
-            } catch (\Exception $e) {
185
+            }catch (\Exception $e) {
186 186
                 $detail = array(
187 187
                     "type" => "danger",
188 188
                 );
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
          */
32 32
         public function setAdminHeaders()
33 33
         {
34
-            if("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup");
34
+            if("login" === $this->config->get("admin_login")) {
35
+                return Admin::getInstance()->adminLogin("admin-setup");
36
+            }
35 37
             $platform = trim(Config::getInstance()->get("platform_name"));
36 38
             header('HTTP/1.1 401 Unauthorized');
37 39
             header('WWW-Authenticate: Basic Realm="' . $platform. '"');
@@ -63,17 +65,20 @@  discard block
 block discarded – undo
63 65
          */
64 66
         private function parseAdmins(&$admins)
65 67
         {
66
-            if(!empty($admins)) foreach($admins as &$admin)
68
+            if(!empty($admins)) {
69
+                foreach($admins as &$admin)
67 70
             {
68 71
                 if(isset($admin["profile"]))
69 72
                 {
70 73
                     switch($admin["profile"]) {
71
-                        case Security::MANAGER_ID_TOKEN: $admin['class'] = 'warning'; break;
74
+                        case Security::MANAGER_ID_TOKEN: $admin['class'] = 'warning';
75
+            }
76
+            break;
72 77
                         case Security::ADMIN_ID_TOKEN: $admin['class'] = 'info'; break;
73 78
                         default:
74 79
                         case Security::USER_ID_TOKEN: $admin['class'] = 'primary'; break;
75 80
                     }
76
-                }else{
81
+                } else{
77 82
                     $admin["class"] = "primary";
78 83
                 }
79 84
             }
@@ -94,7 +99,9 @@  discard block
 block discarded – undo
94 99
                 $size = $file->getSize() / 8 / 1024;
95 100
                 $time = date("c", $file->getMTime());
96 101
                 $dateTime = new \DateTime($time);
97
-                if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array();
102
+                if(!isset($logs[$dateTime->format("Y")])) {
103
+                    $logs[$dateTime->format("Y")] = array();
104
+                }
98 105
                 $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array(
99 106
                     "filename" => $file->getFilename(),
100 107
                     "size" => round($size, 3)
@@ -138,7 +145,9 @@  discard block
 block discarded – undo
138 145
                     $detailLog[] = array_merge(array(
139 146
                         "log" => $line,
140 147
                     ), $detail);
141
-                    if(count($detailLog) >= 1000) break;
148
+                    if(count($detailLog) >= 1000) {
149
+                        break;
150
+                    }
142 151
                 }
143 152
                 $log = $detailLog;
144 153
             }
@@ -162,7 +171,9 @@  discard block
 block discarded – undo
162 171
 
163 172
                     $detail = json_decode($match[0][0], TRUE);
164 173
                 }
165
-                if (empty($detail)) $detail = array();
174
+                if (empty($detail)) {
175
+                    $detail = array();
176
+                }
166 177
                 preg_match_all('/\>\ (.*):/i', $line, $match);
167 178
 
168 179
                 $type = (isset($match[1][0])) ? $match[1][0] : '';
Please login to merge, or discard this patch.
src/base/Request.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -121,6 +121,9 @@
 block discarded – undo
121 121
         return self::getInstance()->getHeader($name);
122 122
     }
123 123
 
124
+    /**
125
+     * @return string
126
+     */
124 127
     public function getHeader($name)
125 128
     {
126 129
         $header = null;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     {
217 217
         if (null === $url) $url = $this->server['HTTP_ORIGIN'];
218 218
         ob_start();
219
-        header('Location: ' . $url);
219
+        header('Location: '.$url);
220 220
         ob_end_clean();
221 221
         exit(_("Redireccionando..."));
222 222
     }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         $host = $this->getServerName();
261 261
         $protocol = $protocol ? $this->getProtocol() : '';
262 262
         $url = '';
263
-        if (!empty($host) && !empty($protocol)) $url = $protocol . $host;
263
+        if (!empty($host) && !empty($protocol)) $url = $protocol.$host;
264 264
         return $url;
265 265
     }
266 266
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,9 +8,10 @@  discard block
 block discarded – undo
8 8
     function getallheaders()
9 9
     {
10 10
         $headers = array();
11
-        foreach ($_SERVER as $h => $v)
12
-            if (preg_match('/HTTP_(.+)/', $h, $hp))
11
+        foreach ($_SERVER as $h => $v) {
12
+                    if (preg_match('/HTTP_(.+)/', $h, $hp))
13 13
                 $headers[$hp[1]] = $v;
14
+        }
14 15
         return $headers;
15 16
     }
16 17
 }
@@ -214,7 +215,9 @@  discard block
 block discarded – undo
214 215
      */
215 216
     public function redirect($url = null)
216 217
     {
217
-        if (null === $url) $url = $this->server['HTTP_ORIGIN'];
218
+        if (null === $url) {
219
+            $url = $this->server['HTTP_ORIGIN'];
220
+        }
218 221
         ob_start();
219 222
         header('Location: ' . $url);
220 223
         ob_end_clean();
@@ -260,7 +263,9 @@  discard block
 block discarded – undo
260 263
         $host = $this->getServerName();
261 264
         $protocol = $protocol ? $this->getProtocol() : '';
262 265
         $url = '';
263
-        if (!empty($host) && !empty($protocol)) $url = $protocol . $host;
266
+        if (!empty($host) && !empty($protocol)) {
267
+            $url = $protocol . $host;
268
+        }
264 269
         return $url;
265 270
     }
266 271
 
Please login to merge, or discard this patch.
src/base/Router.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
     /**
618 618
      * Método que extrae los parámetros de una función
619 619
      *
620
-     * @param array $sr
620
+     * @param string[] $sr
621 621
      * @param \ReflectionMethod $method
622 622
      *
623 623
      * @return array
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
      *
671 671
      * @param string $docComments
672 672
      *
673
-     * @return bool
673
+     * @return string
674 674
      */
675 675
     private function extractReflectionCacheability($docComments)
676 676
     {
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -286,8 +286,10 @@  discard block
 block discarded – undo
286 286
         $_route = explode("/", $url['path']);
287 287
         $_pattern = explode("/", $pattern);
288 288
         $get = array();
289
-        if (!empty($_pattern)) foreach ($_pattern as $index => $component) {
289
+        if (!empty($_pattern)) {
290
+            foreach ($_pattern as $index => $component) {
290 291
             $_get = array();
292
+        }
291 293
             preg_match_all('/^\{(.*)\}$/i', $component, $_get);
292 294
             if (!empty($_get[1]) && isset($_route[$index])) {
293 295
                 $get[array_pop($_get[1])] = $_route[$index];
@@ -502,8 +504,10 @@  discard block
 block discarded – undo
502 504
             throw new RouterException(_("No existe la ruta especificada"));
503 505
         }
504 506
         $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
505
-        if (!empty($params)) foreach ($params as $key => $value) {
507
+        if (!empty($params)) {
508
+            foreach ($params as $key => $value) {
506 509
             $url = str_replace("{" . $key . "}", $value, $url);
510
+        }
507 511
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
508 512
             $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
509 513
         }
@@ -628,12 +632,16 @@  discard block
 block discarded – undo
628 632
         $default = '';
629 633
         $params = array();
630 634
         $parameters = $method->getParameters();
631
-        if (count($parameters) > 0) foreach ($parameters as $param) {
635
+        if (count($parameters) > 0) {
636
+            foreach ($parameters as $param) {
632 637
             if ($param->isOptional() && !is_array($param->getDefaultValue())) {
633 638
                 $params[$param->getName()] = $param->getDefaultValue();
639
+        }
634 640
                 $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
635 641
             }
636
-        } else $default = $regex;
642
+        } else {
643
+            $default = $regex;
644
+        }
637 645
 
638 646
         return array($regex, $default, $params);
639 647
     }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function init()
56 56
     {
57
-        if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) {
57
+        if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) {
58 58
             $this->hydrateRouting();
59 59
             $this->simpatize();
60
-        } else {
61
-            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE);
62
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE);
60
+        }else {
61
+            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE);
62
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE);
63 63
         }
64 64
     }
65 65
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 "success" => FALSE,
80 80
                 "error" => $e->getMessage(),
81 81
             )), 'application/json');
82
-        } else {
82
+        }else {
83 83
             if (NULL === $e) {
84 84
                 Logger::log('Not found page throwed without previus exception');
85 85
                 $e = new \Exception(_('Page not found'), 404);
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function getAllRoutes() {
110 110
         $routes = [];
111
-        foreach($this->routing as $path => $route) {
112
-            if(array_key_exists('slug', $route)) {
111
+        foreach ($this->routing as $path => $route) {
112
+            if (array_key_exists('slug', $route)) {
113 113
                 $routes[$route['slug']] = $path;
114 114
             }
115 115
         }
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
             $this->checkRestrictedAccess($route);
135 135
             //Search action and execute
136 136
             $this->searchAction($route);
137
-        } catch (AccessDeniedException $e) {
137
+        }catch (AccessDeniedException $e) {
138 138
             Logger::log(_('Solicitamos credenciales de acceso a zona restringida'));
139 139
             if ('login' === Config::getInstance()->get('admin_login')) {
140 140
                 return $this->redirectLogin($route);
141
-            } else {
141
+            }else {
142 142
                 return $this->sentAuthHeader();
143 143
             }
144
-        } catch (RouterException $r) {
144
+        }catch (RouterException $r) {
145 145
             if (FALSE !== preg_match('/\/$/', $route)) {
146 146
                 if (preg_match('/admin/', $route)) {
147 147
                     $default = Config::getInstance()->get('admin_action');
148
-                } else {
148
+                }else {
149 149
                     $default = Config::getInstance()->get('home_action');
150 150
                 }
151 151
 
152 152
                 return $this->execute($this->getRoute($default));
153 153
             }
154
-        } catch (\Exception $e) {
154
+        }catch (\Exception $e) {
155 155
             Logger::log($e->getMessage(), LOG_ERR);
156 156
             throw $e;
157 157
         }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                 $class = $this->getClassToCall($action);
229 229
                 try {
230 230
                     $this->executeCachedRoute($route, $action, $class, $get);
231
-                } catch (\Exception $e) {
231
+                }catch (\Exception $e) {
232 232
                     Logger::log($e->getMessage(), LOG_ERR);
233 233
                     throw new RouterException($e->getMessage(), 404, $e);
234 234
                 }
@@ -317,19 +317,19 @@  discard block
 block discarded – undo
317 317
         $this->routing = $this->inspectDir($base, "PSFS", array());
318 318
         if (file_exists($modules)) {
319 319
             $module = "";
320
-            if(file_exists($modules . DIRECTORY_SEPARATOR . 'module.json')) {
321
-                $mod_cfg = json_decode(file_get_contents($modules . DIRECTORY_SEPARATOR . 'module.json'), true);
320
+            if (file_exists($modules.DIRECTORY_SEPARATOR.'module.json')) {
321
+                $mod_cfg = json_decode(file_get_contents($modules.DIRECTORY_SEPARATOR.'module.json'), true);
322 322
                 $module = $mod_cfg['module'];
323 323
             }
324 324
             $this->routing = $this->inspectDir($modules, $module, $this->routing);
325 325
         }
326
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
326
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
327 327
         $home = Config::getInstance()->get('home_action');
328 328
         if (NULL !== $home || $home !== '') {
329 329
             $home_params = NULL;
330 330
             foreach ($this->routing as $pattern => $params) {
331 331
                 list($method, $route) = $this->extractHttpRoute($pattern);
332
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
332
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
333 333
                     $home_params = $params;
334 334
                 }
335 335
             }
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php");
355 355
         foreach ($files as $file) {
356 356
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
357
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing);
357
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing);
358 358
         }
359 359
         $this->finder = new Finder();
360 360
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
                             $httpMethod = $this->extractReflectionHttpMethod($docComments);
405 405
                             $visible = $this->extractReflectionVisibility($docComments);
406 406
                             $expiration = $this->extractReflectionCacheability($docComments);
407
-                            $routing[$httpMethod . "#|#" . $regex] = array(
407
+                            $routing[$httpMethod."#|#".$regex] = array(
408 408
                                 "class" => $namespace,
409 409
                                 "method" => $method->getName(),
410 410
                                 "params" => $params,
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
     {
435 435
         //Calculamos los dominios para las plantillas
436 436
         if ($class->hasConstant("DOMAIN")) {
437
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
438
-            $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
439
-            $path = realpath($path) . DIRECTORY_SEPARATOR;
437
+            $domain = "@".$class->getConstant("DOMAIN")."/";
438
+            $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
439
+            $path = realpath($path).DIRECTORY_SEPARATOR;
440 440
             $tpl_path = "templates";
441 441
             $public_path = "public";
442 442
             $model_path = "models";
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
                 $model_path = ucfirst($model_path);
447 447
             }
448 448
             if ($class->hasConstant("TPL")) {
449
-                $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL");
449
+                $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL");
450 450
             }
451 451
             $this->domains[$domain] = array(
452
-                "template" => $path . $tpl_path,
453
-                "model" => $path . $model_path,
454
-                "public" => $path . $public_path,
452
+                "template" => $path.$tpl_path,
453
+                "model" => $path.$model_path,
454
+                "public" => $path.$public_path,
455 455
             );
456 456
         }
457 457
 
@@ -464,11 +464,11 @@  discard block
 block discarded – undo
464 464
      */
465 465
     public function simpatize()
466 466
     {
467
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
468
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
467
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
468
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
469 469
         $this->generateSlugs($absoluteTranslationFileName);
470 470
         Config::createDir(CONFIG_DIR);
471
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
471
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
472 472
 
473 473
         return $this;
474 474
     }
@@ -519,16 +519,16 @@  discard block
 block discarded – undo
519 519
     public function getRoute($slug = '', $absolute = FALSE, $params = NULL)
520 520
     {
521 521
         if (strlen($slug) === 0) {
522
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
522
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
523 523
         }
524 524
         if (NULL === $slug || !array_key_exists($slug, $this->slugs)) {
525 525
             throw new RouterException(_("No existe la ruta especificada"));
526 526
         }
527
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
527
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
528 528
         if (!empty($params)) foreach ($params as $key => $value) {
529
-            $url = str_replace("{" . $key . "}", $value, $url);
529
+            $url = str_replace("{".$key."}", $value, $url);
530 530
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
531
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
531
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
532 532
         }
533 533
 
534 534
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
             if (preg_match('/^\/admin(\/|$)/', $routePattern)) {
547 547
                 if (preg_match('/^\\\?PSFS/', $params["class"])) {
548 548
                     $profile = "superadmin";
549
-                } else {
549
+                }else {
550 550
                     $profile = "admin";
551 551
                 }
552 552
                 if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) {
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
     protected function getClassToCall($action)
599 599
     {
600 600
         Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
601
-        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"];
601
+        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"];
602 602
         $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass;
603 603
         return $class;
604 604
     }
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
         $expr = preg_quote($expr, '/');
618 618
         $expr = str_replace('###', '(.*)', $expr);
619 619
         $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
620
-        $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
620
+        $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
621 621
         return $matched;
622 622
     }
623 623
 
@@ -654,9 +654,9 @@  discard block
 block discarded – undo
654 654
         if (count($parameters) > 0) foreach ($parameters as $param) {
655 655
             if ($param->isOptional() && !is_array($param->getDefaultValue())) {
656 656
                 $params[$param->getName()] = $param->getDefaultValue();
657
-                $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
657
+                $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
658 658
             }
659
-        } else $default = $regex;
659
+        }else $default = $regex;
660 660
 
661 661
         return array($regex, $default, $params);
662 662
     }
@@ -712,16 +712,16 @@  discard block
 block discarded – undo
712 712
      */
713 713
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
714 714
     {
715
-        Logger::log('Executing route ' . $route);
715
+        Logger::log('Executing route '.$route);
716 716
         Security::getInstance()->setSessionKey("__CACHE__", $action);
717 717
         $cache = Cache::needCache();
718 718
         $execute = TRUE;
719 719
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
720 720
             $cacheDataName = $this->cache->getRequestCacheHash();
721
-            $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () {
721
+            $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() {
722 722
             });
723 723
             if (NULL !== $cachedData) {
724
-                $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () {
724
+                $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() {
725 725
                 }, Cache::JSON);
726 726
                 Template::getInstance()->renderCache($cachedData, $headers);
727 727
                 $execute = FALSE;
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
         $translations = array();
769 769
         if (file_exists($absoluteTranslationFileName)) {
770 770
             include($absoluteTranslationFileName);
771
-        } else {
771
+        }else {
772 772
             Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
773 773
         }
774 774
 
Please login to merge, or discard this patch.