Passed
Push — master ( c82035...9f9933 )
by Fran
02:32
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/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/types/traits/Helper/OptionTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @return OptionTrait
49 49
      */
50 50
     public function dropOption($key) {
51
-        if(array_key_exists($key, $this->options)) {
51
+        if (array_key_exists($key, $this->options)) {
52 52
             unset($this->options[$key]);
53 53
         }
54 54
         return $this;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @return mixed|null
60 60
      */
61 61
     public function getOption($key) {
62
-        if(array_key_exists($key, $this->options)) {
62
+        if (array_key_exists($key, $this->options)) {
63 63
             return $this->options[$key];
64 64
         }
65 65
         return null;
Please login to merge, or discard this patch.
src/base/types/traits/BoostrapTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace PSFS\base\types\traits;
3 3
 
4
-if(!defined('PSFS_BOOSTRAP_TRAT_LOADED')) {
4
+if (!defined('PSFS_BOOSTRAP_TRAT_LOADED')) {
5 5
     /**
6 6
      * Class BoostrapTrait
7 7
      * @package PSFS\base\types
@@ -10,5 +10,5 @@  discard block
 block discarded – undo
10 10
     {
11 11
     }
12 12
     define('PSFS_BOOSTRAP_TRAT_LOADED', true);
13
-    require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php';
13
+    require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'bootstrap.php';
14 14
 }
Please login to merge, or discard this patch.
src/base/dto/Order.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         if (preg_match('/^asc$/i', $direction)) {
64 64
             return self::ASC;
65
-        } else {
65
+        }else {
66 66
             return self::DESC;
67 67
         }
68 68
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function fromArray(array $object = [])
83 83
     {
84
-        foreach($object as $field => $order) {
84
+        foreach ($object as $field => $order) {
85 85
             $this->addOrder($field, $order);
86 86
         }
87 87
     }
Please login to merge, or discard this patch.
src/controller/RouteController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
             $router->simpatize();
58 58
             Security::getInstance()->setFlash("callback_message", t("Rutas generadas correctamente"));
59 59
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
60
-        } catch (Exception $e) {
60
+        }catch (Exception $e) {
61 61
             Logger::log($e->getMessage(), LOG_ERR);
62 62
             Security::getInstance()->setFlash("callback_message", t("Algo no ha salido bien, revisa los logs"));
63 63
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
Please login to merge, or discard this patch.