Passed
Push — master ( b343ab...6c6141 )
by Fran
02:55
created
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 = array())
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/base/dto/Dto.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct($hydrate = true)
20 20
     {
21 21
         parent::__construct();
22
-        if($hydrate) {
22
+        if ($hydrate) {
23 23
             $this->fromArray(Request::getInstance()->getData());
24 24
         }
25 25
     }
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
                 /** @var \ReflectionProperty $property */
48 48
                 foreach ($properties as $property) {
49 49
                     $value = $property->getValue($this);
50
-                    if(is_object($value) && method_exists($value, 'toArray')) {
50
+                    if (is_object($value) && method_exists($value, 'toArray')) {
51 51
                         $dto[$property->getName()] = $value->toArray();
52
-                    } elseif(is_array($value)) {
53
-                        foreach($value as &$arrValue) {
54
-                            if($arrValue instanceof Dto) {
52
+                    } elseif (is_array($value)) {
53
+                        foreach ($value as &$arrValue) {
54
+                            if ($arrValue instanceof Dto) {
55 55
                                 $arrValue = $arrValue->toArray();
56 56
                             }
57 57
                         }
58 58
                         $dto[$property->getName()] = $value;
59
-                    } else {
59
+                    }else {
60 60
                         $dto[$property->getName()] = $property->getValue($this);
61 61
                     }
62 62
                 }
63 63
             }
64
-        } catch (\Exception $e) {
65
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
64
+        }catch (\Exception $e) {
65
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
66 66
         }
67 67
         return $dto;
68 68
     }
@@ -85,26 +85,26 @@  discard block
 block discarded – undo
85 85
     protected function parseDtoField(array $properties, $key, $value = null) {
86 86
         list($type, $isArray) = $this->extractTypes($properties, $key);
87 87
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
88
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
89
-            if(null !== $value && is_array($value)) {
90
-                if(!array_key_exists($type, $this->__cache)) {
88
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
89
+            if (null !== $value && is_array($value)) {
90
+                if (!array_key_exists($type, $this->__cache)) {
91 91
                     $this->__cache[$type] = new $type(false);
92 92
                 }
93
-                if($isArray) {
93
+                if ($isArray) {
94 94
                     $this->$key = [];
95
-                    foreach($value as $data) {
96
-                        if(null !== $data && is_array($data)) {
95
+                    foreach ($value as $data) {
96
+                        if (null !== $data && is_array($data)) {
97 97
                             $dto = clone $this->__cache[$type];
98 98
                             $dto->fromArray($data);
99 99
                             array_push($this->$key, $dto);
100 100
                         }
101 101
                     }
102
-                } else {
102
+                }else {
103 103
                     $this->$key = clone $this->__cache[$type];
104 104
                     $this->$key->fromArray($value);
105 105
                 }
106 106
             }
107
-        } else {
107
+        }else {
108 108
             $this->castValue($key, $value, $type);
109 109
         }
110 110
     }
Please login to merge, or discard this patch.
src/base/extension/AssetsTokenParser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
         $tmp = [];
142 142
         if (null === $node) {
143 143
             $node = $value;
144
-        } else {
144
+        }else {
145 145
             $tmp = $this->getTmpAttribute($node);
146 146
         }
147 147
         if (null !== $node) {
Please login to merge, or discard this patch.
src/base/types/helpers/DeployHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     public static function updateCacheVar() {
18 18
         $now = new \DateTime(null, new \DateTimeZone(Config::getParam('project.timezone', 'Europe/Madrid')));
19 19
         $config = Config::getInstance()->dumpConfig();
20
-        $config[self::CACHE_VAR_TAG] = 'v' . $now->format('Ymd.His');
20
+        $config[self::CACHE_VAR_TAG] = 'v'.$now->format('Ymd.His');
21 21
         Config::save($config);
22 22
         return $config[self::CACHE_VAR_TAG];
23 23
     }
Please login to merge, or discard this patch.
src/controller/GeneratorController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function generateModule()
30 30
     {
31
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
31
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
32 32
         /* @var $form \PSFS\base\config\ConfigForm */
33 33
         $form = new ModuleForm();
34 34
         $form->build();
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
61 61
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente")));
62 62
                 // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
63
-            } catch (\Exception $e) {
64
-                Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
63
+            }catch (\Exception $e) {
64
+                Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
65 65
                 Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage()));
66 66
             }
67 67
         }
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
             $objects = scandir($dir);
24 24
             foreach ($objects as $object) {
25 25
                 if ($object != "." && $object != "..") {
26
-                    if (filetype($dir . "/" . $object) == "dir") {
27
-                        self::deleteDir($dir . "/" . $object);
28
-                    } else {
29
-                        unlink($dir . "/" . $object);
26
+                    if (filetype($dir."/".$object) == "dir") {
27
+                        self::deleteDir($dir."/".$object);
28
+                    }else {
29
+                        unlink($dir."/".$object);
30 30
                     }
31 31
                 }
32 32
             }
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $rootDirs = array("css", "js", "media", "font");
44 44
         foreach ($rootDirs as $dir) {
45
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
45
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
46 46
                 try {
47
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
48
-                } catch (\Exception $e) {
47
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
48
+                }catch (\Exception $e) {
49 49
                     syslog(LOG_INFO, $e->getMessage());
50 50
                 }
51 51
             }
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
     {
62 62
         try {
63 63
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
64
-                throw new \Exception(t('Can\'t create directory ') . $dir);
64
+                throw new \Exception(t('Can\'t create directory ').$dir);
65 65
             }
66
-        } catch (\Exception $e) {
66
+        }catch (\Exception $e) {
67 67
             syslog(LOG_WARNING, $e->getMessage());
68 68
             if (!file_exists(dirname($dir))) {
69
-                throw new GeneratorException($e->getMessage() . $dir);
69
+                throw new GeneratorException($e->getMessage().$dir);
70 70
             }
71 71
         }
72 72
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function getTemplatePath()
79 79
     {
80
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
80
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
81 81
         return realpath($path);
82 82
     }
83 83
 
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
      * @throws \ReflectionException
97 97
      */
98 98
     public static function checkCustomNamespaceApi($namespace) {
99
-        if(!empty($namespace)) {
100
-            if(class_exists($namespace)) {
99
+        if (!empty($namespace)) {
100
+            if (class_exists($namespace)) {
101 101
                 $reflector = new \ReflectionClass($namespace);
102
-                if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
102
+                if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
103 103
                     throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501);
104
-                } elseif(!$reflector->isAbstract()) {
104
+                } elseif (!$reflector->isAbstract()) {
105 105
                     throw new GeneratorException(t('La clase definida debe ser abstracta'), 501);
106 106
                 }
107
-            } else {
107
+            }else {
108 108
                 throw new GeneratorException(t('La clase definida para extender la API no existe'), 501);
109 109
             }
110 110
         }
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
      * @return array
116 116
      */
117 117
     public static function getDomainPaths($domain) {
118
-        $domains = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json'), true);
118
+        $domains = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json'), true);
119 119
         $paths = [];
120
-        if(null !== $domains) {
120
+        if (null !== $domains) {
121 121
             $keyDomains = array_keys($domains);
122
-            foreach($keyDomains as $keyDomain) {
122
+            foreach ($keyDomains as $keyDomain) {
123 123
                 $key = strtoupper(str_replace(['@', '/'], '', $keyDomain));
124
-                if(strtoupper($domain) === $key) {
124
+                if (strtoupper($domain) === $key) {
125 125
                     $paths = $domains[$keyDomain];
126 126
                     break;
127 127
                 }
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public static function createRoot($path = WEB_DIR, OutputInterface $output = null) {
139 139
 
140
-        if(null === $output) {
140
+        if (null === $output) {
141 141
             $output = new ConsoleOutput();
142 142
         }
143 143
 
144 144
         GeneratorHelper::createDir($path);
145 145
         $paths = array("js", "css", "img", "media", "font");
146 146
         foreach ($paths as $htmlPath) {
147
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
147
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
148 148
         }
149 149
 
150 150
         // Generates the root needed files
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
         ];
158 158
         $output->writeln('Start creating html files');
159 159
         foreach ($files as $templates => $filename) {
160
-            $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig');
161
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
162
-                $output->writeln('Can\t create the file ' . $filename);
163
-            } else {
164
-                $output->writeln($filename . ' created successfully');
160
+            $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
161
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
162
+                $output->writeln('Can\t create the file '.$filename);
163
+            }else {
164
+                $output->writeln($filename.' created successfully');
165 165
             }
166 166
         }
167 167
 
168 168
         //Export base locale translations
169
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
170
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
171
-            GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
169
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
170
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
171
+            GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
172 172
         }
173 173
     }
174 174
 }
175 175
\ No newline at end of file
Please login to merge, or discard this patch.
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.