Passed
Push — master ( d0de83...2b31d6 )
by Fran
04:36
created
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');
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');
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');
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]));
172
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]));
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]));
222
+            Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]));
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');
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/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/types/helpers/ServiceHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     }
16 16
 
17 17
     public static function parseRawData($type, $params) {
18
-        switch($type) {
18
+        switch ($type) {
19 19
             default:
20 20
             case self::TYPE_HTTP:
21 21
                 $parsedParams = http_build_query($params);
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/extension/CustomTranslateExtension.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
             $customKey = $customKey ?: Security::getInstance()->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY);
55 55
         }
56 56
         if (null !== $customKey) {
57
-            Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO);
58
-            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']);
59
-        } else {
60
-            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']);
57
+            Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO);
58
+            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']);
59
+        }else {
60
+            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']);
61 61
         }
62 62
         if (file_exists(self::$filename)) {
63
-            Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO);
63
+            Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO);
64 64
             self::$translations = json_decode(file_get_contents(self::$filename), true);
65 65
         } elseif (null !== $customKey) {
66 66
             self::checkLoad(null, $forceReload, true);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     public function getFilters()
82 82
     {
83 83
         return array(
84
-            new TwigFilter('trans', function ($message) {
84
+            new TwigFilter('trans', function($message) {
85 85
                 return self::_($message);
86 86
             }),
87 87
         );
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         self::checkLoad($customKey, $forceReload);
107 107
         if (array_key_exists($message, self::$translations)) {
108 108
             $translation = self::$translations[$message];
109
-        } else {
109
+        }else {
110 110
             $translation = gettext($message);
111 111
         }
112 112
         if (self::$generate) {
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/RouterHelper.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
     {
21 21
         Inspector::stats('[RouterHelper] Getting class to call for executing the request action');
22 22
         Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
23
-        $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class'];
23
+        $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class'];
24 24
         $reflectionClass = new \ReflectionClass($actionClass);
25
-        if($reflectionClass->hasMethod('getInstance')) {
25
+        if ($reflectionClass->hasMethod('getInstance')) {
26 26
             $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']);
27
-        } else {
27
+        }else {
28 28
             $class = new $actionClass;
29 29
         }
30 30
         return $class;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $expr = preg_quote($expr, '/');
114 114
         $expr = str_replace('###', '(.*)', $expr);
115 115
         $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
116
-        $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
116
+        $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
117 117
         return $matched;
118 118
     }
119 119
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public static function extractDomainInfo(\ReflectionClass $class, $domain)
126 126
     {
127
-        $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
127
+        $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
128 128
         $templatesPath = 'templates';
129 129
         $publicPath = 'public';
130 130
         $modelsPath = 'models';
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
             $modelsPath = ucfirst($modelsPath);
135 135
         }
136 136
         if ($class->hasConstant('TPL')) {
137
-            $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL');
137
+            $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL');
138 138
         }
139 139
         return [
140 140
             'base' => $path,
141
-            'template' => $path . $templatesPath,
142
-            'model' => $path . $modelsPath,
143
-            'public' => $path . $publicPath,
141
+            'template' => $path.$templatesPath,
142
+            'model' => $path.$modelsPath,
143
+            'public' => $path.$publicPath,
144 144
         ];
145 145
     }
146 146
 
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
             foreach ($parameters as $param) {
165 165
                 if ($param->isOptional() && !is_array($param->getDefaultValue())) {
166 166
                     $params[$param->getName()] = $param->getDefaultValue();
167
-                    $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
168
-                } elseif(!$param->isOptional()) {
167
+                    $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
168
+                } elseif (!$param->isOptional()) {
169 169
                     $requirements[] = $param->getName();
170 170
                 }
171 171
             }
172
-        } else {
172
+        }else {
173 173
             $default = $regex;
174 174
         }
175 175
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             $httpMethod = self::extractReflectionHttpMethod($docComments);
266 266
             $icon = self::extractDocIcon($docComments);
267 267
             $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments));
268
-            $route = $httpMethod . "#|#" . $regex;
268
+            $route = $httpMethod."#|#".$regex;
269 269
             $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route);
270 270
             $info = [
271 271
                 'method' => $method->getName(),
Please login to merge, or discard this patch.