Test Failed
Push — master ( 79af4d...00f9a5 )
by Fran
02:26
created
src/base/types/traits/SystemTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
                 $use /= 1024;
38 38
                 break;
39 39
             case "MBytes":
40
-                $use /= (1024 * 1024);
40
+                $use /= (1024*1024);
41 41
                 break;
42 42
             case "Bytes":
43 43
             default:
@@ -61,34 +61,34 @@  discard block
 block discarded – undo
61 61
     protected function bindWarningAsExceptions()
62 62
     {
63 63
         Inspector::stats('[SystemTrait] Added handlers for errors', Inspector::SCOPE_DEBUG);
64
-        if(Config::getParam('debug')) {
64
+        if (Config::getParam('debug')) {
65 65
             Logger::log('Setting error_reporting as E_ALL');
66 66
             ini_set('error_reporting', E_ALL);
67 67
             ini_set('display_errors', 1);
68 68
         }
69 69
         //Warning & Notice handler
70
-        set_error_handler(function ($errno, $errstr, $errfile, $errline) {
70
+        set_error_handler(function($errno, $errstr, $errfile, $errline) {
71 71
             Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]);
72 72
             return true;
73 73
         }, E_ALL | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
74 74
 
75
-        register_shutdown_function(function () {
75
+        register_shutdown_function(function() {
76 76
             $error = error_get_last() or json_last_error() or preg_last_error() or \DateTime::getLastErrors();
77
-            if( $error !== NULL) {
77
+            if ($error !== NULL) {
78 78
                 $errno   = $error["type"];
79 79
                 $errfile = $error["file"];
80 80
                 $errline = $error["line"];
81 81
                 $errstr  = $error["message"];
82 82
                 Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]);
83
-                if(null !== Config::getParam('log.slack.hook')) {
83
+                if (null !== Config::getParam('log.slack.hook')) {
84 84
                     SlackHelper::getInstance()->trace($errstr, $errfile, $errline, $error);
85 85
                 }
86 86
             }
87 87
 
88
-            if(self::getTs() > 10 && null !== Config::getParam('log.slack.hook')) {
88
+            if (self::getTs() > 10 && null !== Config::getParam('log.slack.hook')) {
89 89
                 SlackHelper::getInstance()->trace('Slow service endpoint', '', '', [
90
-                    'time' => round(self::getTs(), 3) . ' secs',
91
-                    'memory' => round(self::getMem('MBytes'), 3) . ' Mb',
90
+                    'time' => round(self::getTs(), 3).' secs',
91
+                    'memory' => round(self::getMem('MBytes'), 3).' Mb',
92 92
                 ]);
93 93
             }
94 94
             return false;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         Inspector::stats('[SystemTrait] Initializing stats (mem + ts)');
104 104
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
105 105
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
106
-        } else {
106
+        }else {
107 107
             $this->ts = PSFS_START_TS;
108 108
         }
109 109
         $this->mem = PSFS_START_MEM;
Please login to merge, or discard this patch.
src/base/types/traits/JsonTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function json($response, $statusCode = 200)
27 27
     {
28
-        if(Config::getParam('profiling.enable')) {
29
-            if(is_array($response)) {
28
+        if (Config::getParam('profiling.enable')) {
29
+            if (is_array($response)) {
30 30
                 $response['profiling'] = Inspector::getStats();
31
-            } elseif($response instanceof JsonResponse) {
31
+            } elseif ($response instanceof JsonResponse) {
32 32
                 $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats(Config::getParam('log.level')));
33 33
             }
34 34
         }
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
         $this->decodeJsonResponse($response);
37 37
 
38 38
         $mask = JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING;
39
-        if(Config::getParam('output.json.strict_numbers')) {
39
+        if (Config::getParam('output.json.strict_numbers')) {
40 40
             $mask = JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK;
41 41
         }
42 42
 
43 43
         $data = json_encode($response, $mask);
44
-        if(json_last_error() !== JSON_ERROR_NONE) {
44
+        if (json_last_error() !== JSON_ERROR_NONE) {
45 45
             Logger::log(json_last_error_msg(), LOG_CRIT);
46 46
         }
47 47
 
48
-        if(Config::getParam('angular.protection', false)) {
49
-            $data = ")]}',\n" . $data;
48
+        if (Config::getParam('angular.protection', false)) {
49
+            $data = ")]}',\n".$data;
50 50
         }
51 51
         $this->setStatus($statusCode);
52 52
         ResponseHelper::setDebugHeaders([]);
Please login to merge, or discard this patch.
src/base/types/helpers/Inspector.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public static function stats($name = null, $scope = self::SCOPE_PROFILE) {
34 34
         self::$debug[] = self::collect($name);
35
-        if($scope === self::SCOPE_PROFILE) {
35
+        if ($scope === self::SCOPE_PROFILE) {
36 36
             self::$profiling[] = self::collect($name);
37 37
         }
38 38
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     protected static function calculateStats(array $stats, $timestamp, $mem = 0, $files = 0) {
48 48
         return [
49 49
             'ts' => round($stats['ts'] - $timestamp, 4),
50
-            'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4),
50
+            'mem' => round(($stats['mem'] - $mem)/1024/1024, 4),
51 51
             'files' => $stats['files'] - $files,
52 52
             'name' => $stats['name'],
53 53
         ];
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $mem = defined('PSFS_START_MEM') ? PSFS_START_MEM : 0;
64 64
         $files = 0;
65 65
         $scopeSelected = $scope === self::SCOPE_DEBUG ? self::$debug : self::$profiling;
66
-        foreach($scopeSelected as &$value) {
66
+        foreach ($scopeSelected as &$value) {
67 67
             $value = self::calculateStats($value, $timestamp, $mem, $files);
68 68
         }
69 69
         $scopeSelected[] = self::calculateStats(self::collect('Profiling collect ends'), $timestamp, $mem, $files);
Please login to merge, or discard this patch.
src/base/Cache.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         GeneratorHelper::createDir(dirname($path));
57 57
         if (false === FileHelper::writeFile($path, $data)) {
58
-            throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
58
+            throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ').$path);
59 59
         }
60 60
     }
61 61
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         Inspector::stats('[Cache] Gathering data from cache', Inspector::SCOPE_DEBUG);
71 71
         $data = null;
72
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
72
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
73 73
         if (file_exists($absolutePath)) {
74 74
             $data = FileHelper::readFile($absolutePath);
75 75
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
86 86
     {
87 87
         Inspector::stats('[Cache] Checking expiration', Inspector::SCOPE_DEBUG);
88
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
88
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
89 89
         $lasModificationDate = filemtime($absolutePath);
90 90
         return ($lasModificationDate + $expires <= time());
91 91
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     {
153 153
         Inspector::stats('[Cache] Store data in cache', Inspector::SCOPE_DEBUG);
154 154
         $data = self::transformData($data, $transform);
155
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
155
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
156 156
         $this->saveTextToFile($data, $absolutePath);
157 157
     }
158 158
 
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     public function readFromCache($path, $expires = 300, $function = null, $transform = Cache::TEXT)
169 169
     {
170 170
         $data = null;
171
-        Inspector::stats('[Cache] Reading data from cache: ' . json_encode(['path' => $path]), Inspector::SCOPE_DEBUG);
172
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]), Inspector::SCOPE_DEBUG);
172
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
173 173
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
174 174
                 $data = $function();
175 175
                 $this->storeData($path, $data, $transform, false, $expires);
176
-            } else {
176
+            }else {
177 177
                 $data = $this->getDataFromFile($path, $transform);
178 178
             }
179 179
         }
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
             $query[Api::HEADER_API_LANG] = Request::header(Api::HEADER_API_LANG, 'es');
220 220
             $filename = FileHelper::generateHashFilename($action['http'], $action['slug'], $query);
221 221
             $hashPath = FileHelper::generateCachePath($action, $query);
222
-            Inspector::stats('[Cache] Cache file calculated: ' . json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG);
222
+            Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG);
223 223
             Logger::log('Cache file calculated', LOG_DEBUG, ['file' => $filename, 'hash' => $hashPath]);
224 224
         }
225 225
         return [$hashPath, $filename];
226 226
     }
227 227
 
228 228
     public function flushCache() {
229
-        if(Config::getParam('cache.data.enable', false)) {
229
+        if (Config::getParam('cache.data.enable', false)) {
230 230
             Inspector::stats('[Cache] Flushing cache', Inspector::SCOPE_DEBUG);
231 231
             $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR);
232
-            if(is_array($action)) {
233
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
234
-                if(!file_exists($hashPath)) {
235
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
232
+            if (is_array($action)) {
233
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
234
+                if (!file_exists($hashPath)) {
235
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
236 236
                 }
237 237
                 FileHelper::deleteDir($hashPath);
238 238
             }
Please login to merge, or discard this patch.
src/base/config/Config.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     protected function init()
87 87
     {
88
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
88
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) {
89 89
             $this->loadConfigData();
90 90
         }
91 91
         return $this;
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
             $finalData = array_filter($finalData, function($key, $value) {
202 202
                 return in_array($key, self::$required, true) || !empty($value);
203 203
             }, ARRAY_FILTER_USE_BOTH);
204
-            $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT)));
204
+            $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT)));
205 205
             self::getInstance()->loadConfigData();
206 206
             $saved = true;
207
-        } catch (ConfigException $e) {
207
+        }catch (ConfigException $e) {
208 208
             Logger::log($e->getMessage(), LOG_ERR);
209 209
         }
210 210
         return $saved;
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function loadConfigData()
238 238
     {
239
-        $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: [];
239
+        $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: [];
240 240
         $this->debug = array_key_exists('debug', $this->config) ? (bool)$this->config['debug'] : FALSE;
241
-        if(array_key_exists('cache.var', $this->config)) {
241
+        if (array_key_exists('cache.var', $this->config)) {
242 242
             Security::getInstance()->setSessionKey('config.cache.var', $this->config['cache.var']);
243 243
         }
244 244
     }
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
      */
261 261
     public static function getParam($key, $defaultValue = null, $module = null)
262 262
     {
263
-        if(null !== $module) {
264
-            return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue));
263
+        if (null !== $module) {
264
+            return self::getParam(strtolower($module).'.'.$key, self::getParam($key, $defaultValue));
265 265
         }
266 266
         $param = self::getInstance()->get($key);
267 267
         return (null !== $param) ? $param : $defaultValue;
Please login to merge, or discard this patch.
src/base/types/helpers/ServiceHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     const TYPE_HTTP = 2;
12 12
 
13 13
     public static function parseRawData($type, $params) {
14
-        switch($type) {
14
+        switch ($type) {
15 15
             default:
16 16
             case self::TYPE_HTTP:
17 17
                 $parsedParams = http_build_query($params);
Please login to merge, or discard this patch.
src/base/Logger.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 
19 19
 
20 20
 if (!defined('LOG_DIR')) {
21
-    GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
22
-    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
21
+    GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs');
22
+    define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
23 23
 }
24 24
 
25 25
 /**
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $args = func_get_args();
59 59
         list($logger, $debug, $path) = $this->setup($args);
60
-        $this->stream = fopen($path . DIRECTORY_SEPARATOR . date('Ymd') . '.log', 'a+');
60
+        $this->stream = fopen($path.DIRECTORY_SEPARATOR.date('Ymd').'.log', 'a+');
61 61
         if (is_resource($this->stream)) {
62 62
             $this->addPushLogger($logger, $debug);
63
-        } else {
63
+        }else {
64 64
             throw new ConfigException(t('Error creating logger'));
65 65
         }
66 66
         $this->logLevel = strtoupper(Config::getParam('log.level', 'NOTICE'));
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     private function createLoggerPath()
142 142
     {
143 143
         $logger = $this->setLoggerName();
144
-        $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m');
144
+        $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m');
145 145
         GeneratorHelper::createDir($path);
146 146
         return $path;
147 147
     }
Please login to merge, or discard this patch.
src/base/types/CurlService.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $headers = [];
89 89
         foreach ($this->getHeaders() as $key => $value) {
90
-            $headers[] = $key . ': ' . $value;
90
+            $headers[] = $key.': '.$value;
91 91
         }
92 92
         $headers[self::PSFS_TRACK_HEADER] = Logger::getUid();
93 93
         if (count($headers)) {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             case Request::VERB_GET:
118 118
                 if (!empty($this->params)) {
119 119
                     $sep = false === strpos($this->getUrl(), '?') ? '?' : '';
120
-                    $this->setUrl($this->getUrl() . $sep . http_build_query($this->getParams()), false);
120
+                    $this->setUrl($this->getUrl().$sep.http_build_query($this->getParams()), false);
121 121
                 }
122 122
                 break;
123 123
             case Request::VERB_POST:
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         if ($this->isDebug() && is_resource($verbose)) {
150 150
             $this->dumpVerboseLogs($verbose);
151 151
         }
152
-        Logger::log($this->getUrl() . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]);
152
+        Logger::log($this->getUrl().' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]);
153 153
         $this->info = array_merge($this->info, curl_getinfo($this->con));
154 154
     }
155 155
 
Please login to merge, or discard this patch.
src/base/types/traits/Helper/ParameterTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      * @return ParameterTrait
50 50
      */
51 51
     public function dropParam($key) {
52
-        if(array_key_exists($key, $this->params)) {
52
+        if (array_key_exists($key, $this->params)) {
53 53
             unset($this->params[$key]);
54 54
         }
55 55
         return $this;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @return mixed|null
61 61
      */
62 62
     public function getParam($key) {
63
-        if(array_key_exists($key, $this->params)) {
63
+        if (array_key_exists($key, $this->params)) {
64 64
             return $this->params[$key];
65 65
         }
66 66
         return null;
Please login to merge, or discard this patch.