Passed
Push — master ( 71a986...d378fe )
by Fran
04:06
created
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   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                         if (!preg_match('/^\@ROOT/i', $domain)) {
35 35
                             $modules[] = str_replace('/', '', str_replace('@', '', $domain));
36 36
                         }
37
-                    } catch (\Exception $e) {
37
+                    }catch (\Exception $e) {
38 38
                         $modules[] = $e->getMessage();
39 39
                     }
40 40
                 }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
          */
53 53
         public function extractApiEndpoints($module)
54 54
         {
55
-            $module_path = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Api";
55
+            $module_path = CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Api";
56 56
             $endpoints = [];
57 57
             if (file_exists($module_path)) {
58 58
                 $finder = new Finder();
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                 if (count($finder)) {
61 61
                     /** @var \SplFileInfo $file */
62 62
                     foreach ($finder as $file) {
63
-                        $namespace = "\\{$module}\\Api\\" . str_replace('.php', '', $file->getFilename());
63
+                        $namespace = "\\{$module}\\Api\\".str_replace('.php', '', $file->getFilename());
64 64
                         $endpoints[$namespace] = $this->extractApiInfo($namespace);
65 65
                     }
66 66
                 }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                         if (NULL !== $mInfo) {
90 90
                             $info[] = $mInfo;
91 91
                         }
92
-                    } catch (\Exception $e) {
92
+                    }catch (\Exception $e) {
93 93
                         Logger::getInstance()->errorLog($e->getMessage());
94 94
                     }
95 95
                 }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
          */
237 237
         protected function extractReturn($model, $comments = '')
238 238
         {
239
-            $modelDto  = [];
239
+            $modelDto = [];
240 240
             preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes);
241 241
             if (count($returnTypes)) {
242 242
                 // Extract principal DTO information
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                 } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
290 290
                     $payload = $this->extractDtoProperties($namespace);
291 291
                 }
292
-            } catch (\Exception $e) {
292
+            }catch (\Exception $e) {
293 293
                 Logger::getInstance()->errorLog($e->getMessage());
294 294
             }
295 295
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                         if (in_array($methodInfo['method'], ['POST', 'PUT'])) {
326 326
                             $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments);
327 327
                         }
328
-                    } catch (\Exception $e) {
328
+                    }catch (\Exception $e) {
329 329
                         jpre($e->getMessage());
330 330
                         Logger::getInstance()->errorLog($e->getMessage());
331 331
                     }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
          */
344 344
         public static function translateSwaggerFormats($format)
345 345
         {
346
-            switch(strtolower($format)) {
346
+            switch (strtolower($format)) {
347 347
                 case 'bool':
348 348
                 case 'boolean':
349 349
                     $swaggerType = 'boolean';
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
                             ]]);
405 405
                             if (array_key_exists($subDtoName, $subDto)) {
406 406
                                 $definitions = $subDto;
407
-                            } else {
407
+                            }else {
408 408
                                 $definitions[$subDtoName] = $subDto;
409 409
                             }
410 410
                             $dto['properties'][$field] = [
411
-                                '$ref' => "#/definitions/" . $subDtoName,
411
+                                '$ref' => "#/definitions/".$subDtoName,
412 412
                             ];
413
-                        } else {
413
+                        }else {
414 414
                             list($type, $format) = self::translateSwaggerFormats($format);
415 415
                             $dto['properties'][$field] = [
416 416
                                 "type" => $type,
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
                     "url" => Router::getInstance()->getRoute(''),
448 448
                 ]
449 449
             ];
450
-            foreach($endpoints as $model) {
450
+            foreach ($endpoints as $model) {
451 451
                 foreach ($model as $endpoint) {
452 452
                     $dtos += self::extractSwaggerDefinition($endpoint);
453 453
                 }
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
         protected function extractDtoName($dto, $isArray = false)
467 467
         {
468 468
             $dto = explode('\\', $dto);
469
-            $modelDto = array_pop($dto) . "Dto";
469
+            $modelDto = array_pop($dto)."Dto";
470 470
             if ($isArray) {
471 471
                 $modelDto .= "List";
472 472
             }
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/Security.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -415,7 +415,7 @@
 block discarded – undo
415 415
      * @param array $parts
416 416
      * @param int $partLength
417 417
      *
418
-     * @return array
418
+     * @return string[]
419 419
      */
420 420
     private static function extractTsAndMod(array &$parts, $partLength)
421 421
     {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         }
63 63
         $this->user = (array_key_exists(self::USER_ID_TOKEN, $this->session)) ? unserialize($this->session[self::USER_ID_TOKEN]) : NULL;
64 64
         $this->admin = (array_key_exists(self::ADMIN_ID_TOKEN, $this->session)) ? unserialize($this->session[self::ADMIN_ID_TOKEN]) : NULL;
65
-        if(null === $this->admin) {
65
+        if (null === $this->admin) {
66 66
             $this->checkAdmin();
67 67
         }
68 68
     }
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
     public static function save($user)
122 122
     {
123 123
         $admins = array();
124
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
125
-            $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE);
124
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
125
+            $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE);
126 126
         }
127
-        $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
127
+        $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
128 128
         $admins[$user['username']]['profile'] = $user['profile'];
129 129
 
130
-        return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT)));
130
+        return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT)));
131 131
     }
132 132
 
133 133
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
     public function getAdmins()
162 162
     {
163 163
         $admins = array();
164
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
165
-            $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE);
164
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
165
+            $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE);
166 166
         }
167 167
 
168 168
         return $admins;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     {
182 182
         Logger::log('Checking admin session');
183 183
         if (!$this->authorized && !$this->checked) {
184
-            if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
184
+            if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
185 185
                 $request = Request::getInstance();
186 186
                 $admins = $this->getAdmins();
187 187
                 //Sacamos las credenciales de la petición
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
                 }
193 193
                 if (!empty($user) && !empty($admins[$user])) {
194 194
                     $auth = $admins[$user]['hash'];
195
-                    $this->authorized = ($auth == sha1($user . $pass));
196
-                    if($this->authorized) {
195
+                    $this->authorized = ($auth == sha1($user.$pass));
196
+                    if ($this->authorized) {
197 197
                         $this->admin = array(
198 198
                             'alias' => $user,
199 199
                             'profile' => $admins[$user]['profile'],
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
         $axis = 0;
417 417
         $parts = array();
418 418
         try {
419
-            $partLength = floor(strlen($token) / 10);
420
-            for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) {
419
+            $partLength = floor(strlen($token)/10);
420
+            for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) {
421 421
                 $parts[] = substr($token, $axis, $partLength);
422 422
                 $axis += $partLength;
423 423
             }
424
-        } catch (\Exception $e) {
424
+        }catch (\Exception $e) {
425 425
             $partLength = 0;
426 426
         }
427 427
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
         $decoded = NULL;
462 462
         list($partLength, $parts) = self::extractTokenParts($token);
463 463
         list($ts, $mod) = self::extractTsAndMod($parts, $partLength);
464
-        $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2);
464
+        $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2);
465 465
         if (time() - (integer)$ts < 300 && $hashMod === $mod) {
466 466
             $decoded = implode('', $parts);
467 467
         }
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
     public static function generateToken($secret, $module = 'PSFS')
479 479
     {
480 480
         $ts = time();
481
-        $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2);
481
+        $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2);
482 482
         $hash = hash('sha256', $secret);
483
-        $insert = floor(strlen($hash) / strlen($ts));
483
+        $insert = floor(strlen($hash)/strlen($ts));
484 484
         $j = 0;
485 485
         $token = '';
486 486
         for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) {
487
-            $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2);
487
+            $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2);
488 488
             $j += $insert;
489 489
         }
490
-        $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts)));
490
+        $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts)));
491 491
         return $token;
492 492
     }
493 493
 
Please login to merge, or discard this patch.
src/base/Service.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@
 block discarded – undo
125 125
     }
126 126
 
127 127
     /**
128
-     * @param $header
129
-     * @param null $content
128
+     * @param string $header
129
+     * @param string $content
130 130
      *
131 131
      * @return $this
132 132
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
         $this->url = NULL;
178 178
         $this->params = array();
179 179
         $this->headers = array();
180
-        Logger::log("Context service for " . get_called_class() . " cleared!");
180
+        Logger::log("Context service for ".get_called_class()." cleared!");
181 181
     }
182 182
 
183 183
     /**
Please login to merge, or discard this patch.
src/base/Singleton.php 2 patches
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.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __construct()
22 22
     {
23
-        Logger::log(get_class($this) . ' constructor invoked');
23
+        Logger::log(get_class($this).' constructor invoked');
24 24
         $this->init();
25 25
     }
26 26
 
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
         $calledClass = get_called_class();
91 91
         try {
92 92
             $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass);
93
-            $setter = "set" . ucfirst($variable);
93
+            $setter = "set".ucfirst($variable);
94 94
             if (method_exists($calledClass, $setter)) {
95 95
                 $this->$setter($instance);
96
-            } else {
96
+            }else {
97 97
                 $this->$variable = $instance;
98 98
             }
99
-        } catch (\Exception $e) {
100
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR);
99
+        }catch (\Exception $e) {
100
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
101 101
         }
102 102
         return $this;
103 103
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     public function init()
109 109
     {
110 110
         if (!$this->isLoaded()) {
111
-            $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . sha1(get_class($this)) . ".json";
111
+            $cacheFilename = "reflections".DIRECTORY_SEPARATOR.sha1(get_class($this)).".json";
112 112
             /** @var \PSFS\base\Cache $cacheService */
113 113
             $cacheService = Cache::getInstance();
114 114
             /** @var \PSFS\base\config\Config $configService */
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
                 $this->load($property, true, $class);
124 124
             }
125 125
             $this->setLoaded();
126
-        } else {
127
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
126
+        }else {
127
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
128 128
         }
129 129
     }
130 130
 }
Please login to merge, or discard this patch.
src/base/Logger.php 2 patches
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.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @param string $msg
89 89
      * @param array $context
90 90
      *
91
-     * @return bool
91
+     * @return boolean|null
92 92
      */
93 93
     public function debugLog($msg = '', $context = [])
94 94
     {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
     /**
99 99
      * Método que escribe un log de Error
100
-     * @param $msg
100
+     * @param string $msg
101 101
      * @param array $context
102 102
      *
103 103
      * @return bool
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
     /**
111 111
      * Método que escribe un log de Warning
112
-     * @param $msg
112
+     * @param string $msg
113 113
      * @param array $context
114 114
      * @return bool
115 115
      */
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/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
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.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  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)) {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
49 49
     {
50 50
         $data = null;
51
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
51
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
52 52
         if (file_exists($absolutePath)) {
53 53
             $data = file_get_contents($absolutePath);
54 54
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
66 66
     {
67
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
67
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
68 68
         $lasModificationDate = filemtime($absolutePath);
69 69
         return ($lasModificationDate + $expires <= time());
70 70
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 break;
88 88
             case Cache::GZIP:
89 89
                 // TODO implementar
90
-                if(function_exists('gzuncompress')) {
90
+                if (function_exists('gzuncompress')) {
91 91
                     $data = gzuncompress($data);
92 92
                 }
93 93
                 break;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                 $data = Cache::transformData($data, Cache::GZIP);
113 113
                 break;
114 114
             case Cache::GZIP:
115
-                if(function_exists('gzcompress')) {
115
+                if (function_exists('gzcompress')) {
116 116
                     $data = gzcompress($data);
117 117
                 }
118 118
                 break;
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
145 145
     {
146 146
         $data = null;
147
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
147
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
148 148
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
149 149
                 $data = call_user_func($function);
150 150
                 $this->storeData($path, $data, $transform);
151
-            } else {
151
+            }else {
152 152
                 $data = $this->getDataFromFile($path, $transform);
153 153
             }
154 154
         }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $hash = "";
179 179
         $action = Security::getInstance()->getSessionKey("__CACHE__");
180 180
         if (null !== $action && $action["cache"] > 0) {
181
-            $hash = $action["http"] . " " . $action["slug"];
181
+            $hash = $action["http"]." ".$action["slug"];
182 182
         }
183 183
         return sha1($hash);
184 184
     }
Please login to merge, or discard this patch.