Passed
Push — master ( de68c3...70f98a )
by Fran
03:25
created
src/base/Singleton.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
     public function __construct()
21 21
     {
22
-        Logger::log(get_class($this) . ' constructor invoked');
22
+        Logger::log(get_class($this).' constructor invoked');
23 23
     }
24 24
 
25 25
     /**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
         $calledClass = get_called_class();
107 107
         try {
108 108
             $instance = $this->constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass);
109
-            $setter = "set" . ucfirst($variable);
109
+            $setter = "set".ucfirst($variable);
110 110
             if (method_exists($calledClass, $setter)) {
111 111
                 $this->$setter($instance);
112
-            } else {
112
+            }else {
113 113
                 $this->$variable = $instance;
114 114
             }
115
-        } catch (\Exception $e) {
116
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR);
115
+        }catch (\Exception $e) {
116
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
117 117
         }
118 118
         return $this;
119 119
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     public function init()
125 125
     {
126 126
         if (!$this->isLoaded()) {
127
-            $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . sha1(get_class($this)) . ".json";
127
+            $cacheFilename = "reflections".DIRECTORY_SEPARATOR.sha1(get_class($this)).".json";
128 128
             /** @var \PSFS\base\Cache $cacheService */
129 129
             $cacheService = Cache::getInstance();
130 130
             /** @var \PSFS\base\config\Config $configService */
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
                 $this->load($property, true, $class);
140 140
             }
141 141
             $this->setLoaded();
142
-        } else {
143
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
142
+        }else {
143
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
144 144
         }
145 145
     }
146 146
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         if (null === $class) {
156 156
             $class = get_class($this);
157 157
         }
158
-        Logger::log('Extracting annotations properties from class ' . $class);
158
+        Logger::log('Extracting annotations properties from class '.$class);
159 159
         $selfReflector = new \ReflectionClass($class);
160 160
         if (false !== $selfReflector->getParentClass()) {
161 161
             $properties = $this->getClassProperties($selfReflector->getParentClass()->getName());
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
      */
197 197
     private function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)
198 198
     {
199
-        Logger::log('Create inyectable instance for ' . $classNameSpace . ' into ' . get_class($this));
199
+        Logger::log('Create inyectable instance for '.$classNameSpace.' into '.get_class($this));
200 200
         $reflector = new \ReflectionClass($calledClass);
201 201
         $property = $reflector->getProperty($variable);
202 202
         $varInstanceType = (null === $classNameSpace) ? $this->extractVarType($property->getDocComment()) : $classNameSpace;
203 203
         if (true === $singleton && method_exists($varInstanceType, "getInstance")) {
204 204
             $instance = $varInstanceType::getInstance();
205
-        } else {
205
+        }else {
206 206
             $instance = new $varInstanceType();
207 207
         }
208 208
         return $instance;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,9 +135,11 @@
 block discarded – undo
135 135
                 $cacheService->storeData($cacheFilename, $properties, Cache::JSON);
136 136
             }
137 137
             /** @var \ReflectionProperty $property */
138
-            if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) {
138
+            if (!empty($properties) && is_array($properties)) {
139
+                foreach ($properties as $property => $class) {
139 140
                 $this->load($property, true, $class);
140 141
             }
142
+            }
141 143
             $this->setLoaded();
142 144
         } else {
143 145
             Logger::log(get_class($this) . ' already loaded', LOG_INFO);
Please login to merge, or discard this patch.
src/base/config/Config.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected function init()
48 48
     {
49
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json")) {
49
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json")) {
50 50
             $this->loadConfigData();
51 51
         }
52 52
         return $this;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function getTemplatePath()
118 118
     {
119
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
119
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
120 120
         return realpath($path);
121 121
     }
122 122
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
         $final_data = self::saveExtraParams($data);
164 164
         $saved = false;
165 165
         try {
166
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", $final_data, Cache::JSON, true);
166
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", $final_data, Cache::JSON, true);
167 167
             Config::getInstance()->loadConfigData();
168 168
             $saved = true;
169
-        } catch (ConfigException $e) {
169
+        }catch (ConfigException $e) {
170 170
             Logger::log($e->getMessage(), LOG_ERR);
171 171
         }
172 172
         return $saved;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function getPropelParams()
200 200
     {
201
-        return Cache::getInstance()->getDataFromFile(__DIR__ . DIRECTORY_SEPARATOR . 'properties.json', Cache::JSON, true);
201
+        return Cache::getInstance()->getDataFromFile(__DIR__.DIRECTORY_SEPARATOR.'properties.json', Cache::JSON, true);
202 202
     }
203 203
 
204 204
     /**
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
     {
211 211
         try {
212 212
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
213
-                throw new \Exception(_('Can\'t create directory ') . $dir);
213
+                throw new \Exception(_('Can\'t create directory ').$dir);
214 214
             }
215
-        } catch (\Exception $e) {
215
+        }catch (\Exception $e) {
216 216
             Logger::log($e->getMessage(), LOG_WARNING);
217 217
             if (!file_exists(dirname($dir))) {
218
-                throw new ConfigException($e->getMessage() . $dir);
218
+                throw new ConfigException($e->getMessage().$dir);
219 219
             }
220 220
         }
221 221
     }
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
     {
228 228
         $rootDirs = array("css", "js", "media", "font");
229 229
         foreach ($rootDirs as $dir) {
230
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
230
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
231 231
                 try {
232
-                    @shell_exec("rm -rf " . WEB_DIR . DIRECTORY_SEPARATOR . $dir);
233
-                } catch (\Exception $e) {
232
+                    @shell_exec("rm -rf ".WEB_DIR.DIRECTORY_SEPARATOR.$dir);
233
+                }catch (\Exception $e) {
234 234
                     Logger::log($e->getMessage());
235 235
                 }
236 236
             }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public function loadConfigData()
244 244
     {
245
-        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", Cache::JSON, TRUE) ?: array();
245
+        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", Cache::JSON, TRUE) ?: array();
246 246
         $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE;
247 247
     }
248 248
 
Please login to merge, or discard this patch.
src/base/Logger.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 if (!defined("LOG_DIR")) {
16
-    Config::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
17
-    define("LOG_DIR", BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
16
+    Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs');
17
+    define("LOG_DIR", BASE_DIR.DIRECTORY_SEPARATOR.'logs');
18 18
 }
19 19
 
20 20
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $config = Config::getInstance();
44 44
         $args = func_get_args();
45 45
         list($logger, $debug, $path) = $this->setup($config, $args);
46
-        $this->stream = fopen($path . DIRECTORY_SEPARATOR . date("Ymd") . ".log", "a+");
46
+        $this->stream = fopen($path.DIRECTORY_SEPARATOR.date("Ymd").".log", "a+");
47 47
         $this->addPushLogger($logger, $debug, $config);
48 48
     }
49 49
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     private function createLoggerPath(Config $config)
186 186
     {
187 187
         $logger = $this->setLoggerName($config);
188
-        $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m');
188
+        $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m');
189 189
         Config::createDir($path);
190 190
 
191 191
         return $path;
Please login to merge, or discard this patch.
src/base/Template.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $this->setStatusHeader();
133 133
         $this->setAuthHeaders();
134 134
         $this->setCookieHeaders($cookies);
135
-        header('Content-type: ' . $contentType);
135
+        header('Content-type: '.$contentType);
136 136
 
137 137
     }
138 138
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
         Logger::log('Start output response');
149 149
         ob_start();
150 150
         $this->setReponseHeaders($contentType, $cookies);
151
-        header('Content-length: ' . strlen($output));
151
+        header('Content-length: '.strlen($output));
152 152
 
153 153
         $cache = Cache::needCache();
154 154
         if (false !== $cache && $this->status_code === 200 && $this->debug === false) {
155 155
             Logger::log('Saving output response into cache');
156 156
             $cacheName = $this->cache->getRequestCacheHash();
157
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName, $output);
158
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName . ".headers", headers_list(), Cache::JSON);
157
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName, $output);
158
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName.".headers", headers_list(), Cache::JSON);
159 159
         }
160 160
         echo $output;
161 161
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     {
173 173
         Logger::log('Close template render');
174 174
         $this->security->setSessionKey("lastRequest", array(
175
-            "url" => Request::getInstance()->getRootUrl() . Request::requestUri(),
175
+            "url" => Request::getInstance()->getRootUrl().Request::requestUri(),
176 176
             "ts" => microtime(true),
177 177
         ));
178 178
         $this->security->updateSession();
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
         $dump = '';
225 225
         try {
226 226
             $dump = $this->tpl->render($tpl, $vars);
227
-        } catch (\Exception $e) {
228
-            echo $e->getMessage() . "<pre>" . $e->getTraceAsString() . "</pre>";
227
+        }catch (\Exception $e) {
228
+            echo $e->getMessage()."<pre>".$e->getTraceAsString()."</pre>";
229 229
         }
230 230
         return $dump;
231 231
     }
@@ -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->loadTemplate(str_replace($tplDir . '/', '', $file));
364
-                } catch (\Exception $e) {
363
+                    $this->tpl->loadTemplate(str_replace($tplDir.'/', '', $file));
364
+                }catch (\Exception $e) {
365 365
                     Logger::log($e->getMessage(), LOG_ERR);
366 366
                 }
367 367
             }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
             unset($_SERVER["PHP_AUTH_USER"]);
432 432
             unset($_SERVER["PHP_AUTH_PW"]);
433 433
             header_remove("Authorization");
434
-        } else {
434
+        }else {
435 435
             header('Authorization:');
436 436
         }
437 437
     }
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
             Logger::log('Adding debug headers to render response');
459 459
             $vars["__DEBUG__"]["includes"] = get_included_files();
460 460
             $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
461
-            header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s');
462
-            header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes');
463
-            header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened');
461
+            header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s');
462
+            header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes');
463
+            header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened');
464 464
         }
465 465
 
466 466
         return $vars;
Please login to merge, or discard this patch.
src/autoload.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
21 21
             $path = str_replace("\\", DIRECTORY_SEPARATOR, $class);
22 22
 
23 23
             // filepath
24
-            $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php";
24
+            $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php";
25 25
             if (!file_exists($abs_path)) {
26
-                pre('&rarr;&nbsp;' . $class);
27
-                pre('&rarr;&nbsp;' . $path);
28
-                pre('&rarr;&nbsp;' . $abs_path);
26
+                pre('&rarr;&nbsp;'.$class);
27
+                pre('&rarr;&nbsp;'.$path);
28
+                pre('&rarr;&nbsp;'.$abs_path);
29 29
             }
30 30
 
31 31
             // require the file
Please login to merge, or discard this patch.
src/bootstrap.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 
5 5
 if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
6 6
 if (preg_match('/vendor/', SOURCE_DIR)) {
7
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
8
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
9
-} else {
10
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
11
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
7
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
8
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
9
+}else {
10
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
11
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
12 12
 }
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
13
+if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
14
+if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
15
+if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
16
+if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
17 17
 
18 18
 //Cargamos en memoria la función de desarrollo PRE
19 19
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,19 +1,39 @@
 block discarded – undo
1 1
 <?php
2
-if (defined('PSFS_BOOTSTRAP_LOADED')) return;
2
+if (defined('PSFS_BOOTSTRAP_LOADED')) {
3
+    return;
4
+}
3 5
 use Symfony\Component\Finder\Finder;
4 6
 
5
-if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
7
+if (!defined('SOURCE_DIR')) {
8
+    define('SOURCE_DIR', __DIR__);
9
+}
6 10
 if (preg_match('/vendor/', SOURCE_DIR)) {
7
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
8
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
9
-} else {
10
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
11
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
12
-}
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
11
+    if (!defined('BASE_DIR')) {
12
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
13
+    }
14
+    if (!defined('CORE_DIR')) {
15
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
16
+    }
17
+    } else {
18
+    if (!defined('BASE_DIR')) {
19
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
20
+    }
21
+    if (!defined('CORE_DIR')) {
22
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
23
+    }
24
+    }
25
+if (!defined('LOG_DIR')) {
26
+    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
27
+}
28
+if (!defined('CACHE_DIR')) {
29
+    define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
30
+}
31
+if (!defined('CONFIG_DIR')) {
32
+    define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
33
+}
34
+if (!defined('WEB_DIR')) {
35
+    define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
36
+}
17 37
 
18 38
 //Cargamos en memoria la función de desarrollo PRE
19 39
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
src/Dispatcher.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use PSFS\base\Logger;
14 14
 use PSFS\base\Singleton;
15 15
 
16
-require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php";
16
+require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php";
17 17
 
18 18
 /**
19 19
  * Class Dispatcher
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
     private function setLocale()
75 75
     {
76 76
         $this->locale = $this->config->get("default_language");
77
-        Logger::log('Set locale to project [' . $this->locale . ']');
77
+        Logger::log('Set locale to project ['.$this->locale.']');
78 78
         // Load translations
79
-        putenv("LC_ALL=" . $this->locale);
79
+        putenv("LC_ALL=".$this->locale);
80 80
         setlocale(LC_ALL, $this->locale);
81 81
         // Load the locale path
82
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
83
-        Logger::log('Set locale dir ' . $locale_path);
82
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
83
+        Logger::log('Set locale dir '.$locale_path);
84 84
         Config::createDir($locale_path);
85 85
         bindtextdomain('translations', $locale_path);
86 86
         textdomain('translations');
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
                 if (!$this->parser->isFile()) {
101 101
                     return $this->router->execute($this->actualUri);
102 102
                 }
103
-            } else {
103
+            }else {
104 104
                 return $this->router->getAdmin()->config();
105 105
             }
106
-        } catch (ConfigException $c) {
106
+        }catch (ConfigException $c) {
107 107
             return $this->dumpException($c);
108
-        } catch (SecurityException $s) {
108
+        }catch (SecurityException $s) {
109 109
             return $this->security->notAuthorized($this->actualUri);
110
-        } catch (RouterException $r) {
110
+        }catch (RouterException $r) {
111 111
             return $this->router->httpNotFound($r);
112
-        } catch (\Exception $e) {
112
+        }catch (\Exception $e) {
113 113
             return $this->dumpException($e);
114 114
         }
115 115
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                 $use /= 1024;
152 152
                 break;
153 153
             case "MBytes":
154
-                $use /= (1024 * 1024);
154
+                $use /= (1024*1024);
155 155
                 break;
156 156
             case "Bytes":
157 157
             default:
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         if ($this->config->getDebugMode()) {
178 178
             Logger::log('Added handlers for errors');
179 179
             //Warning & Notice handler
180
-            set_error_handler(function ($errno, $errstr, $errfile, $errline) {
180
+            set_error_handler(function($errno, $errstr, $errfile, $errline) {
181 181
                 Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]);
182 182
                 throw new \Exception($errstr, 500);
183 183
             });
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         Logger::log('Initialicing stats (mem + ts)');
193 193
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
194 194
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
195
-        } else {
195
+        }else {
196 196
             $this->ts = $this->parser->getTs();
197 197
         }
198 198
         $this->mem = memory_get_usage();
Please login to merge, or discard this patch.
src/base/Cache.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      */
30 30
     private function saveTextToFile($data, $path, $absolute = false)
31 31
     {
32
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
32
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
33 33
         $filename = basename($absolutePath);
34 34
         Config::createDir(str_replace($filename, "", $absolutePath));
35 35
         if (false === file_put_contents($absolutePath, $data)) {
36
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $absolutePath);
36
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$absolutePath);
37 37
         }
38 38
     }
39 39
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
48 48
     {
49 49
         $data = null;
50
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
50
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
51 51
         if (file_exists($absolutePath)) {
52 52
             $data = file_get_contents($absolutePath);
53 53
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
65 65
     {
66
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
66
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
67 67
         $lasModificationDate = filemtime($absolutePath);
68 68
         return ($lasModificationDate + $expires <= time());
69 69
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 break;
87 87
             case Cache::GZIP:
88 88
                 // TODO implementar
89
-                if(function_exists('gzuncompress')) {
89
+                if (function_exists('gzuncompress')) {
90 90
                     $data = gzuncompress($data);
91 91
                 }
92 92
                 break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                 $data = Cache::transformData($data, Cache::GZIP);
112 112
                 break;
113 113
             case Cache::GZIP:
114
-                if(function_exists('gzcompress')) {
114
+                if (function_exists('gzcompress')) {
115 115
                     $data = gzcompress($data);
116 116
                 }
117 117
                 break;
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
144 144
     {
145 145
         $data = null;
146
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
146
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
147 147
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
148 148
                 $data = call_user_func($function);
149 149
                 $this->storeData($path, $data, $transform);
150
-            } else {
150
+            }else {
151 151
                 $data = $this->getDataFromFile($path, $transform);
152 152
             }
153 153
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         $hash = "";
178 178
         $action = Security::getInstance()->getSessionKey("__CACHE__");
179 179
         if (null !== $action && $action["cache"] > 0) {
180
-            $hash = $action["http"] . " " . $action["slug"];
180
+            $hash = $action["http"]." ".$action["slug"];
181 181
         }
182 182
         return sha1($hash);
183 183
     }
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     /**
123 123
      * Método que guarda en fichero los datos pasados
124
-     * @param $path
124
+     * @param string $path
125 125
      * @param $data
126 126
      * @param int $transform
127 127
      * @param boolean $absolutePath
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
     /**
158 158
      * Método estático que revisa si se necesita cachear la respuesta de un servicio o no
159
-     * @return integer|boolean
159
+     * @return integer
160 160
      */
161 161
     public static function needCache()
162 162
     {
Please login to merge, or discard this patch.
src/command/CreateDocumentRoot.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@
 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')) {
44
+            if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
45 45
                 \PSFS\base\config\Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
46
-                \PSFS\Services\GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', 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 49
             $output->writeln("Document root generado en ".$path);
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\config\Config::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.