Passed
Push — master ( 61c4e2...c8eeb1 )
by Fran
03:27
created
src/controller/base/Admin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public static function staticAdminLogon($route = null)
50 50
     {
51
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
51
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
52 52
             if ('login' !== Config::getInstance()->get('admin_login')) {
53 53
                 return AdminServices::getInstance()->setAdminHeaders();
54
-            } else {
54
+            }else {
55 55
                 $form = new LoginForm();
56 56
                 $form->setData(array("route" => $route));
57 57
                 $form->build();
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                     'form' => $form,
62 62
                 ));
63 63
             }
64
-        } else {
64
+        }else {
65 65
             return UserController::showAdminManager();
66 66
         }
67 67
     }
Please login to merge, or discard this patch.
src/base/config/Config.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     protected function init()
74 74
     {
75
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
75
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) {
76 76
             $this->loadConfigData();
77 77
         }
78 78
         return $this;
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
         $final_data = self::saveExtraParams($data);
171 171
         $saved = false;
172 172
         try {
173
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, $final_data, Cache::JSON, true);
173
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, $final_data, Cache::JSON, true);
174 174
             Config::getInstance()->loadConfigData();
175 175
             $saved = true;
176
-        } catch (ConfigException $e) {
176
+        }catch (ConfigException $e) {
177 177
             Logger::log($e->getMessage(), LOG_ERR);
178 178
         }
179 179
         return $saved;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function loadConfigData()
207 207
     {
208
-        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE,
208
+        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE,
209 209
             Cache::JSON,
210 210
             TRUE) ?: [];
211 211
         $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     /**
182 182
      * Method that returns a config value
183 183
      * @param string $param
184
-     * @param mixed $defaultValue
184
+     * @param boolean $defaultValue
185 185
      *
186 186
      * @return mixed|null
187 187
      */
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     /**
222 222
      * Static wrapper for extracting params
223 223
      * @param string $key
224
-     * @param mixed|null $defaultValue
224
+     * @param boolean|string $defaultValue
225 225
      * @return mixed|null
226 226
      */
227 227
     public static function getParam($key, $defaultValue = null)
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
             $objects = scandir($dir);
20 20
             foreach ($objects as $object) {
21 21
                 if ($object != "." && $object != "..") {
22
-                    if (filetype($dir . "/" . $object) == "dir") {
23
-                        self::deleteDir($dir . "/" . $object);
24
-                    } else {
25
-                        unlink($dir . "/" . $object);
22
+                    if (filetype($dir."/".$object) == "dir") {
23
+                        self::deleteDir($dir."/".$object);
24
+                    }else {
25
+                        unlink($dir."/".$object);
26 26
                     }
27 27
                 }
28 28
             }
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $rootDirs = array("css", "js", "media", "font");
40 40
         foreach ($rootDirs as $dir) {
41
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
41
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
42 42
                 try {
43
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
44
-                } catch (\Exception $e) {
43
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
44
+                }catch (\Exception $e) {
45 45
                     Logger::log($e->getMessage());
46 46
                 }
47 47
             }
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
     {
58 58
         try {
59 59
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
60
-                throw new \Exception(_('Can\'t create directory ') . $dir);
60
+                throw new \Exception(_('Can\'t create directory ').$dir);
61 61
             }
62
-        } catch (\Exception $e) {
62
+        }catch (\Exception $e) {
63 63
             Logger::log($e->getMessage(), LOG_WARNING);
64 64
             if (!file_exists(dirname($dir))) {
65
-                throw new GeneratorException($e->getMessage() . $dir);
65
+                throw new GeneratorException($e->getMessage().$dir);
66 66
             }
67 67
         }
68 68
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function getTemplatePath()
75 75
     {
76
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
76
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
77 77
         return realpath($path);
78 78
     }
79 79
 }
80 80
\ No newline at end of file
Please login to merge, or discard this patch.
src/command/CreateDocumentRoot.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
         new InputArgument('path', InputArgument::OPTIONAL, 'Path en el que crear el Document Root'),
14 14
     ))
15 15
     ->setDescription('Comando de creación del Document Root del projecto')
16
-    ->setCode(function (InputInterface $input, OutputInterface $output) {
16
+    ->setCode(function(InputInterface $input, OutputInterface $output) {
17 17
         // Creates the html path
18 18
         $path = $input->getArgument('path');
19 19
         if (empty($path)) $path = WEB_DIR;
20 20
         \PSFS\base\types\helpers\GeneratorHelper::createDir($path);
21 21
         $paths = array("js", "css", "img", "media", "font");
22 22
         foreach ($paths as $htmlPath) {
23
-            \PSFS\base\types\helpers\GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
23
+            \PSFS\base\types\helpers\GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
24 24
         }
25 25
 
26 26
         // Generates the root needed files
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
             'robots' => 'robots.txt',
33 33
         ];
34 34
         foreach ($files as $templates => $filename) {
35
-            $text = \PSFS\base\Template::getInstance()->dump("generator/html/" . $templates . '.html.twig');
36
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
37
-                $output->writeln('Can\t create the file ' . $filename);
38
-            } else {
39
-                $output->writeln($filename . ' created successfully');
35
+            $text = \PSFS\base\Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
36
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
37
+                $output->writeln('Can\t create the file '.$filename);
38
+            }else {
39
+                $output->writeln($filename.' created successfully');
40 40
             }
41 41
         }
42 42
 
43 43
         //Export base locale translations
44
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
45
-            \PSFS\base\types\helpers\GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
46
-            \PSFS\Services\GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
44
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
45
+            \PSFS\base\types\helpers\GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
46
+            \PSFS\Services\GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
47 47
         }
48 48
 
49
-        $output->writeln("Document root generado en " . $path);
49
+        $output->writeln("Document root generado en ".$path);
50 50
     });
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 use Symfony\Component\Console\Input\InputInterface;
7 7
 use Symfony\Component\Console\Output\OutputInterface;
8 8
 
9
-if (!isset($console)) $console = new Application();
9
+if (!isset($console)) {
10
+    $console = new Application();
11
+}
10 12
 $console
11 13
     ->register('psfs:create:root')
12 14
     ->setDefinition(array(
@@ -16,7 +18,9 @@  discard block
 block discarded – undo
16 18
     ->setCode(function (InputInterface $input, OutputInterface $output) {
17 19
         // Creates the html path
18 20
         $path = $input->getArgument('path');
19
-        if (empty($path)) $path = WEB_DIR;
21
+        if (empty($path)) {
22
+            $path = WEB_DIR;
23
+        }
20 24
         \PSFS\base\types\helpers\GeneratorHelper::createDir($path);
21 25
         $paths = array("js", "css", "img", "media", "font");
22 26
         foreach ($paths as $htmlPath) {
Please login to merge, or discard this patch.
src/Dispatcher.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use PSFS\base\types\helpers\GeneratorHelper;
17 17
 use PSFS\controller\ConfigController;
18 18
 
19
-require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php";
19
+require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php";
20 20
 
21 21
 /**
22 22
  * Class Dispatcher
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
     private function setLocale()
78 78
     {
79 79
         $this->locale = $this->config->get("default_language");
80
-        Logger::log('Set locale to project [' . $this->locale . ']');
80
+        Logger::log('Set locale to project ['.$this->locale.']');
81 81
         // Load translations
82
-        putenv("LC_ALL=" . $this->locale);
82
+        putenv("LC_ALL=".$this->locale);
83 83
         setlocale(LC_ALL, $this->locale);
84 84
         // Load the locale path
85
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
86
-        Logger::log('Set locale dir ' . $locale_path);
85
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
86
+        Logger::log('Set locale dir '.$locale_path);
87 87
         GeneratorHelper::createDir($locale_path);
88 88
         bindtextdomain('translations', $locale_path);
89 89
         textdomain('translations');
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
                 if (!$this->parser->isFile()) {
105 105
                     return $this->router->execute($this->actualUri);
106 106
                 }
107
-            } else {
107
+            }else {
108 108
                 return ConfigController::getInstance()->config();
109 109
             }
110
-        } catch (ConfigException $c) {
110
+        }catch (ConfigException $c) {
111 111
             return $this->dumpException($c);
112
-        } catch (SecurityException $s) {
112
+        }catch (SecurityException $s) {
113 113
             return $this->security->notAuthorized($this->actualUri);
114
-        } catch (UserAuthException $u) {
114
+        }catch (UserAuthException $u) {
115 115
             $this->redirectToHome();
116
-        } catch (RouterException $r) {
116
+        }catch (RouterException $r) {
117 117
             return $this->router->httpNotFound($r);
118
-        } catch (\Exception $e) {
118
+        }catch (\Exception $e) {
119 119
             return $this->dumpException($e);
120 120
         }
121 121
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                 $use /= 1024;
163 163
                 break;
164 164
             case "MBytes":
165
-                $use /= (1024 * 1024);
165
+                $use /= (1024*1024);
166 166
                 break;
167 167
             case "Bytes":
168 168
             default:
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         if ($this->config->getDebugMode() && $this->config->get('errors.strict', false)) {
189 189
             Logger::log('Added handlers for errors');
190 190
             //Warning & Notice handler
191
-            set_error_handler(function ($errno, $errstr, $errfile, $errline) {
191
+            set_error_handler(function($errno, $errstr, $errfile, $errline) {
192 192
                 Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]);
193 193
                 throw new \Exception($errstr, 500);
194 194
             });
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         Logger::log('Initializing stats (mem + ts)');
204 204
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
205 205
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
206
-        } else {
206
+        }else {
207 207
             $this->ts = $this->parser->getTs();
208 208
         }
209 209
         $this->mem = memory_get_usage();
Please login to merge, or discard this patch.
src/base/extension/TemplateFunctions.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@
 block discarded – undo
144 144
      * @param string $path
145 145
      * @param $domains
146 146
      *
147
-     * @return mixed
147
+     * @return string
148 148
      */
149 149
     private static function extractPathname($path, $domains)
150 150
     {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 
40 40
         $file_path = "";
41 41
         if (!file_exists($file_path)) {
42
-            $file_path = BASE_DIR . $string;
42
+            $file_path = BASE_DIR.$string;
43 43
         }
44 44
         $filename_path = AssetsParser::findDomainPath($string, $file_path);
45 45
 
46 46
         $file_path = self::processAsset($string, $name, $return, $filename_path);
47
-        $return_path = (empty($name)) ? Request::getInstance()->getRootUrl() . '/' . $file_path : $name;
47
+        $return_path = (empty($name)) ? Request::getInstance()->getRootUrl().'/'.$file_path : $name;
48 48
         return ($return) ? $return_path : '';
49 49
     }
50 50
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $router = Router::getInstance();
62 62
         try {
63 63
             return $router->getRoute($path, $absolute, $params);
64
-        } catch (\Exception $e) {
64
+        }catch (\Exception $e) {
65 65
             return $router->getRoute('', $absolute, $params);
66 66
         }
67 67
     }
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
     private static function putResourceContent($name, $filename_path, $base, $file_path)
188 188
     {
189 189
         $data = file_get_contents($filename_path);
190
-        if (!empty($name)) file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data);
191
-        else file_put_contents($base . $file_path, $data);
190
+        if (!empty($name)) file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);
191
+        else file_put_contents($base.$file_path, $data);
192 192
     }
193 193
 
194 194
     /**
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
         if (file_exists($filename_path)) {
207 207
             list($base, $html_base, $file_path) = AssetsParser::calculateAssetPath($string, $name, $return, $filename_path);
208 208
             //Creamos el directorio si no existe
209
-            GeneratorHelper::createDir($base . $html_base);
209
+            GeneratorHelper::createDir($base.$html_base);
210 210
             //Si se ha modificado
211
-            if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($filename_path)) {
211
+            if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($filename_path)) {
212 212
                 if ($html_base == 'css') {
213 213
                     self::processCssLines($filename_path);
214 214
                 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -187,8 +187,11 @@
 block discarded – undo
187 187
     private static function putResourceContent($name, $filename_path, $base, $file_path)
188 188
     {
189 189
         $data = file_get_contents($filename_path);
190
-        if (!empty($name)) file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data);
191
-        else file_put_contents($base . $file_path, $data);
190
+        if (!empty($name)) {
191
+            file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data);
192
+        } else {
193
+            file_put_contents($base . $file_path, $data);
194
+        }
192 195
     }
193 196
 
194 197
     /**
Please login to merge, or discard this patch.
src/base/Template.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use PSFS\base\extension\TemplateFunctions;
9 9
 use PSFS\base\types\helpers\GeneratorHelper;
10 10
 use PSFS\base\types\helpers\ResponseHelper;
11
-use PSFS\base\types\helpers\TemplateHelper;
12 11
 use PSFS\base\types\SingletonTrait;
13 12
 
14 13
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         ResponseHelper::setStatusHeader($this->status_code);
130 130
         ResponseHelper::setAuthHeaders($this->public_zone);
131 131
         ResponseHelper::setCookieHeaders($cookies);
132
-        header('Content-type: ' . $contentType);
132
+        header('Content-type: '.$contentType);
133 133
 
134 134
     }
135 135
 
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
         Logger::log('Start output response');
146 146
         ob_start();
147 147
         $this->setReponseHeaders($contentType, $cookies);
148
-        header('Content-length: ' . strlen($output));
148
+        header('Content-length: '.strlen($output));
149 149
 
150 150
         $cache = Cache::needCache();
151 151
         if (false !== $cache && $this->status_code === Template::STATUS_OK && $this->debug === false) {
152 152
             Logger::log('Saving output response into cache');
153 153
             $cacheName = $this->cache->getRequestCacheHash();
154
-            $tmpDir = substr($cacheName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheName, 2, 2) . DIRECTORY_SEPARATOR;
155
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheName, $output);
156
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheName . ".headers", headers_list(), Cache::JSON);
154
+            $tmpDir = substr($cacheName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheName, 2, 2).DIRECTORY_SEPARATOR;
155
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheName, $output);
156
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheName.".headers", headers_list(), Cache::JSON);
157 157
         }
158 158
         echo $output;
159 159
 
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
     {
171 171
         Logger::log('Close template render');
172 172
         Security::getInstance()->setSessionKey("lastRequest", array(
173
-            "url" => Request::getInstance()->getRootUrl() . Request::requestUri(),
173
+            "url" => Request::getInstance()->getRootUrl().Request::requestUri(),
174 174
             "ts" => microtime(true),
175 175
         ));
176 176
         Security::getInstance()->updateSession();
177
-        Logger::log('End request: ' . Request::requestUri(), LOG_INFO);
177
+        Logger::log('End request: '.Request::requestUri(), LOG_INFO);
178 178
         exit;
179 179
     }
180 180
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
         $dump = '';
225 225
         try {
226 226
             $dump = $this->tpl->render($tpl, $vars);
227
-        } catch (\Exception $e) {
227
+        }catch (\Exception $e) {
228 228
             Logger::log($e->getMessage(), LOG_ERR);
229 229
         }
230 230
         return $dump;
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     public function regenerateTemplates()
339 339
     {
340 340
         $this->generateTemplatesCache();
341
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true);
341
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true);
342 342
         $translations = [];
343 343
         if (is_array($domains)) {
344 344
             $translations = $this->parsePathTranslations($domains);
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
             // force compilation
361 361
             if ($file->isFile()) {
362 362
                 try {
363
-                    $this->tpl->load(str_replace($tplDir . '/', '', $file));
364
-                } catch (\Exception $e) {
363
+                    $this->tpl->load(str_replace($tplDir.'/', '', $file));
364
+                }catch (\Exception $e) {
365 365
                     Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]);
366 366
                 }
367 367
             }
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
      */
436 436
     private function loadDomains()
437 437
     {
438
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true);
438
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true);
439 439
         if (null !== $domains) {
440 440
             foreach ($domains as $domain => $paths) {
441 441
                 $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain));
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         $this->cache = Cache::getInstance();
453 453
         $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath());
454 454
         $this->tpl = new \Twig_Environment($loader, array(
455
-            'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig',
455
+            'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig',
456 456
             'debug' => (bool)$this->debug,
457 457
             'auto_reload' => Config::getParam('twig.auto_reload', TRUE),
458 458
         ));
Please login to merge, or discard this patch.
src/base/types/Form.php 3 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,6 +48,9 @@  discard block
 block discarded – undo
48 48
         return $this;
49 49
     }
50 50
 
51
+    /**
52
+     * @param string|null $action
53
+     */
51 54
     public function setAction($action)
52 55
     {
53 56
         $this->action = $action;
@@ -562,7 +565,7 @@  discard block
 block discarded – undo
562 565
     }
563 566
 
564 567
     /**
565
-     * @param $token_field
568
+     * @param string $token_field
566 569
      * @return bool
567 570
      */
568 571
     protected function existsFormToken($token_field)
@@ -594,7 +597,7 @@  discard block
 block discarded – undo
594 597
     /**
595 598
      * Método que extrae el valor de un campo del formulario del modelo
596 599
      * @param $field
597
-     * @param $value
600
+     * @param ObjectCollection $value
598 601
      * @param $type
599 602
      * @return mixed
600 603
      */
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
     public function add($name, array $value = array())
70 70
     {
71 71
         $this->fields[$name] = $value;
72
-        $this->fields[$name]['name'] = $this->getName() . "[{$name}]";
73
-        $this->fields[$name]['id'] = $this->getName() . '_' . $name;
72
+        $this->fields[$name]['name'] = $this->getName()."[{$name}]";
73
+        $this->fields[$name]['id'] = $this->getName().'_'.$name;
74 74
         $this->fields[$name]['placeholder'] = (array_key_exists('placeholder', $value)) ? $value['placeholder'] : $name;
75 75
         $this->fields[$name]['hasLabel'] = (array_key_exists('hasLabel', $value)) ? $value['hasLabel'] : true;
76 76
         return $this;
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         }
134 134
         if ('' !== $hash_orig) {
135 135
             $this->crfs = sha1($hash_orig);
136
-            $this->add($this->getName() . '_token', array(
136
+            $this->add($this->getName().'_token', array(
137 137
                 "type" => "hidden",
138 138
                 "value" => $this->crfs,
139 139
             ));
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     public function isValid()
203 203
     {
204 204
         $valid = true;
205
-        $token_field = $this->getName() . '_token';
205
+        $token_field = $this->getName().'_token';
206 206
         //Controlamos CSRF token
207 207
         if (!$this->existsFormToken($token_field)) {
208 208
             $this->errors[$token_field] = _('Formulario no válido');
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         $data = array();
275 275
         if (count($this->fields) > 0) {
276 276
             foreach ($this->fields as $key => $field) {
277
-                if (self::SEPARATOR !== $key && $key !== ($this->getName() . "_token")) {
277
+                if (self::SEPARATOR !== $key && $key !== ($this->getName()."_token")) {
278 278
                     $data[$key] = (array_key_exists('value', $field)) ? $field["value"] : null;
279 279
                 }
280 280
             }
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
             $model = $this->getHydratedModel();
390 390
             $model->save();
391 391
             $save = true;
392
-            Logger::getInstance()->infoLog(get_class($this->model) . " guardado con id " . $this->model->getPrimaryKey());
393
-        } catch (\Exception $e) {
392
+            Logger::getInstance()->infoLog(get_class($this->model)." guardado con id ".$this->model->getPrimaryKey());
393
+        }catch (\Exception $e) {
394 394
             Logger::getInstance()->errorLog($e->getMessage());
395 395
             throw new FormException($e->getMessage(), $e->getCode(), $e);
396 396
         }
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
         if (null === $value) {
410 410
             $isEmpty = true;
411 411
             // Empty Array check
412
-        } else if (is_array($value) && 0 === count($value)) {
412
+        }else if (is_array($value) && 0 === count($value)) {
413 413
             $isEmpty = true;
414 414
             // Empty string check
415
-        } else if (0 === strlen(preg_replace('/(\ |\r|\n)/m', '', $value))) {
415
+        }else if (0 === strlen(preg_replace('/(\ |\r|\n)/m', '', $value))) {
416 416
             $isEmpty = true;
417 417
         }
418 418
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             && array_key_exists($key, $field)
440 440
             && !array_key_exists('error', $field[$key])
441 441
             && !empty($field["value"])
442
-            && preg_match('/' . $field['pattern'] . '/', $field['value']) === 0
442
+            && preg_match('/'.$field['pattern'].'/', $field['value']) === 0
443 443
         ) {
444 444
             $this->setError($key, str_replace('%s', "<strong>{$key}</strong>", _("El campo %s no tiene un formato válido")));
445 445
             $field["error"] = $this->getError($key);
@@ -461,10 +461,10 @@  discard block
 block discarded – undo
461 461
         if (array_key_exists($key, $data[$form_name])) {
462 462
             if (preg_match("/id/i", $key) && ($data[$form_name][$key] === 0 || $data[$form_name][$key] === "%" || $data[$form_name][$key] === "")) {
463 463
                 $field["value"] = null;
464
-            } else {
464
+            }else {
465 465
                 $field["value"] = $data[$form_name][$key];
466 466
             }
467
-        } else {
467
+        }else {
468 468
             unset($field["value"]);
469 469
         }
470 470
         return array($data, $field);
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
      */
479 479
     private function hydrateModelField($key, $value)
480 480
     {
481
-        $setter = "set" . ucfirst($key);
482
-        $getter = "get" . ucfirst($key);
481
+        $setter = "set".ucfirst($key);
482
+        $getter = "get".ucfirst($key);
483 483
         if (method_exists($this->model, $setter)) {
484 484
             if (method_exists($this->model, $getter)) {
485 485
                 $tmp = $this->model->$getter();
@@ -504,16 +504,16 @@  discard block
 block discarded – undo
504 504
     {
505 505
         //Extraemos el dato del modelo relacionado si existe el getter
506 506
         $method = null;
507
-        if (array_key_exists('class_data', $field) && method_exists($val, "get" . $field["class_data"])) {
508
-            $class_method = "get" . $field["class_data"];
507
+        if (array_key_exists('class_data', $field) && method_exists($val, "get".$field["class_data"])) {
508
+            $class_method = "get".$field["class_data"];
509 509
             $class = $val->$class_method();
510
-            if (array_key_exists('class_id', $field) && method_exists($class, "get" . $field["class_id"])) {
511
-                $method = "get" . $field["class_id"];
510
+            if (array_key_exists('class_id', $field) && method_exists($class, "get".$field["class_id"])) {
511
+                $method = "get".$field["class_id"];
512 512
                 $data[] = $class->$method();
513
-            } else {
513
+            }else {
514 514
                 $data[] = $class->getPrimaryKey();
515 515
             }
516
-        } else {
516
+        }else {
517 517
             $data[] = $val;
518 518
         }
519 519
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     private function extractModelFieldValue($key, $field)
530 530
     {
531 531
         //Extraemos el valor del campo del modelo
532
-        $method = "get" . ucfirst($key);
532
+        $method = "get".ucfirst($key);
533 533
         $type = (array_key_exists('type', $field)) ? $field["type"] : "text";
534 534
         //Extraemos los campos del modelo
535 535
         if (method_exists($this->model, $method)) {
@@ -539,16 +539,16 @@  discard block
 block discarded – undo
539 539
                 //Si es una relación múltiple
540 540
                 if ($value instanceof ObjectCollection) {
541 541
                     $field = $this->computeModelFieldValue($field, $value, $type);
542
-                } else { //O una relación unitaria
542
+                }else { //O una relación unitaria
543 543
                     if (method_exists($value, "__toString")) {
544 544
                         $field["value"] = $value;
545 545
                     } elseif ($value instanceof \DateTime) {
546 546
                         $field["value"] = $value->format("Y-m-d H:i:s");
547
-                    } else {
547
+                    }else {
548 548
                         $field["value"] = $value->getPrimaryKey();
549 549
                     }
550 550
                 }
551
-            } else {
551
+            }else {
552 552
                 $field["value"] = $value;
553 553
             }
554 554
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,9 @@
 block discarded – undo
212 212
         //Validamos los campos del formulario
213 213
         if ($valid && count($this->fields) > 0) {
214 214
             foreach ($this->fields as $key => &$field) {
215
-                if ($key === $token_field || $key === self::SEPARATOR) continue;
215
+                if ($key === $token_field || $key === self::SEPARATOR) {
216
+                    continue;
217
+                }
216 218
                 list($field, $valid) = $this->checkFieldValidation($field, $key);
217 219
             }
218 220
         }
Please login to merge, or discard this patch.
src/base/types/helpers/ApiHelper.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@
 block discarded – undo
199 199
 
200 200
     /**
201 201
      * @param ColumnMap $column
202
-     * @param ModelCriteria $quwuery
202
+     * @param ModelCriteria $query
203 203
      * @param mixed $value
204 204
      */
205 205
     private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null)
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             } elseif ($mappedColumn->isText()) {
41 41
                 if ($mappedColumn->getSize() > 100) {
42 42
                     $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required);
43
-                } else {
43
+                }else {
44 44
                     $fDto = self::generateStringField($field, $required);
45 45
                 }
46 46
             } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $fDto->entity = $relatedModel;
84 84
         $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName());
85 85
         $fDto->relatedField = $relatedField->getPhpName();
86
-        $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel);
86
+        $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel);
87 87
         return $fDto;
88 88
     }
89 89
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     {
191 191
         try {
192 192
             $column = $tableMap->getColumnByPhpName($field);
193
-        } catch (\Exception $e) {
193
+        }catch (\Exception $e) {
194 194
             Logger::log($e->getMessage(), LOG_ERR);
195 195
             $column = null;
196 196
         }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      * @param ModelCriteria $quwuery
203 203
      * @param mixed $value
204 204
      */
205
-    private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null)
205
+    private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null)
206 206
     {
207 207
         $tableField = $column->getPhpName();
208 208
         if (preg_match('/^<=/', $value)) {
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
         } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) {
217 217
             $text = preg_replace('/(\'|\")/', '', $value);
218 218
             $text = preg_replace('/\ /', '%', $text);
219
-            $query->filterBy($tableField, '%' . $text . '%', Criteria::LIKE);
220
-        } else {
219
+            $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE);
220
+        }else {
221 221
             $query->filterBy($tableField, $value, Criteria::EQUAL);
222 222
         }
223 223
     }
@@ -228,24 +228,24 @@  discard block
 block discarded – undo
228 228
      * @param array $extraColumns
229 229
      * @param mixed $value
230 230
      */
231
-    public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null)
231
+    public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null)
232 232
     {
233 233
         $exp = 'CONCAT(';
234 234
         $sep = '';
235 235
         foreach ($tableMap->getColumns() as $column) {
236 236
             if ($column->isText()) {
237
-                $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")';
237
+                $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")';
238 238
                 $sep = ', " ", ';
239 239
             }
240 240
         }
241 241
         foreach ($extraColumns as $extra => $name) {
242
-            $exp .= $sep . $extra;
242
+            $exp .= $sep.$extra;
243 243
             $sep = ', " ", ';
244 244
         }
245 245
         $exp .= ")";
246 246
         $text = preg_replace('/(\'|\")/', '', $value);
247 247
         $text = preg_replace('/\ /', '%', $text);
248
-        $query->where($exp . Criteria::LIKE . '"%' . $text . '%"');
248
+        $query->where($exp.Criteria::LIKE.'"%'.$text.'%"');
249 249
     }
250 250
 
251 251
     /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      * @param string $field
256 256
      * @param mixed $value
257 257
      */
258
-    public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null)
258
+    public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null)
259 259
     {
260 260
         if ($column = self::checkFieldExists($tableMap, $field)) {
261 261
             self::addQueryFilter($column, $query, $value);
Please login to merge, or discard this patch.