Passed
Push — master ( f17d15...6b8654 )
by Fran
02:50
created
src/base/types/helpers/FileHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function readFile($path) {
25 25
         $data = false;
26
-        if(file_exists($path)) {
26
+        if (file_exists($path)) {
27 27
             $data = @file_get_contents($path);
28 28
         }
29 29
         return $data;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @return string
37 37
      */
38 38
     public static function generateHashFilename($verb, $slug, array $query = []) {
39
-        return sha1(strtolower($verb) . ' ' . $slug . ' ' . strtolower(http_build_query($query)));
39
+        return sha1(strtolower($verb).' '.$slug.' '.strtolower(http_build_query($query)));
40 40
     }
41 41
 
42 42
     /**
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
     public static function generateCachePath(array $action, array $query = []) {
48 48
         $class = GeneratorHelper::extractClassFromNamespace($action['class']);
49 49
         $filename = self::generateHashFilename($action['http'], $action['slug'], $query);
50
-        $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2);
51
-        return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR;
50
+        $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2);
51
+        return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR;
52 52
     }
53 53
 
54 54
     /**
Please login to merge, or discard this patch.
src/base/types/helpers/InjectorHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
                 $isRequired = self::checkIsRequired($property->getDocComment());
28 28
                 $label = self::getLabel($property->getDocComment());
29 29
                 $isArray = (bool)preg_match('/\[\]$/', $instanceType);
30
-                if($isArray) {
30
+                if ($isArray) {
31 31
                     $instanceType = str_replace('[]', '', $instanceType);
32 32
                 }
33
-                if($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
33
+                if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
34 34
                     list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType);
35 35
                     $variables[$property->getName()] = [
36 36
                         'type' => $type,
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
                         'required' => $isRequired,
39 39
                         'description' => $label,
40 40
                     ];
41
-                } else {
41
+                }else {
42 42
                     $instance = new \ReflectionClass($instanceType);
43 43
                     $variables[$property->getName()] = [
44 44
                         'is_array' => $isArray,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         // Extract description
125 125
         $label = null;
126 126
         preg_match('/@label\ (.*)\n/i', $doc, $matches);
127
-        if(count($matches)) {
127
+        if (count($matches)) {
128 128
             $label = _($matches[1]);
129 129
         }
130 130
         return $label;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     public static function getDefaultValue($doc) {
138 138
         $default = null;
139 139
         preg_match('/@default\ (.*)\n/i', $doc, $matches);
140
-        if(count($matches)) {
140
+        if (count($matches)) {
141 141
             $default = $matches[1];
142 142
         }
143 143
         return $default;
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)
154 154
     {
155
-        Logger::log('Create inyectable instance for ' . $classNameSpace);
155
+        Logger::log('Create inyectable instance for '.$classNameSpace);
156 156
         $reflector = new \ReflectionClass($calledClass);
157 157
         $property = $reflector->getProperty($variable);
158 158
         $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace;
159 159
         if (true === $singleton && method_exists($varInstanceType, 'getInstance')) {
160 160
             $instance = $varInstanceType::getInstance();
161
-        } else {
161
+        }else {
162 162
             $instance = new $varInstanceType();
163 163
         }
164 164
         return $instance;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     public static function getClassProperties($class)
173 173
     {
174 174
         $properties = [];
175
-        Logger::log('Extracting annotations properties from class ' . $class);
175
+        Logger::log('Extracting annotations properties from class '.$class);
176 176
         $selfReflector = new \ReflectionClass($class);
177 177
         if (false !== $selfReflector->getParentClass()) {
178 178
             $properties = self::getClassProperties($selfReflector->getParentClass()->getName());
Please login to merge, or discard this patch.
src/base/Cache.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         GeneratorHelper::createDir(dirname($path));
56 56
         if (false === FileHelper::writeFile($path, $data)) {
57
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
57
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
58 58
         }
59 59
     }
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]);
70 70
         $data = null;
71
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
71
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
72 72
         if (file_exists($absolutePath)) {
73 73
             $data = FileHelper::readFile($absolutePath);
74 74
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
85 85
     {
86 86
         Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]);
87
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
87
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
88 88
         $lasModificationDate = filemtime($absolutePath);
89 89
         return ($lasModificationDate + $expires <= time());
90 90
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]);
153 153
         $data = self::transformData($data, $transform);
154
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
154
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
155 155
         $this->saveTextToFile($data, $absolutePath);
156 156
     }
157 157
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $data = null;
170 170
         Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]);
171
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
172 172
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
173 173
                 $data = $function();
174 174
                 $this->storeData($path, $data, $transform, false, $expires);
175
-            } else {
175
+            }else {
176 176
                 $data = $this->getDataFromFile($path, $transform);
177 177
             }
178 178
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     public function flushCache() {
227
-        if(Config::getParam('cache.data.enable', false)) {
227
+        if (Config::getParam('cache.data.enable', false)) {
228 228
             Logger::log('Flushing cache', LOG_DEBUG);
229 229
             $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR);
230
-            if(is_array($action)) {
231
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
232
-                if(!file_exists($hashPath)) {
233
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
230
+            if (is_array($action)) {
231
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
232
+                if (!file_exists($hashPath)) {
233
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
234 234
                 }
235 235
                 FileHelper::deleteDir($hashPath);
236 236
             }
Please login to merge, or discard this patch.
src/base/config/Config.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected function init()
76 76
     {
77
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
77
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) {
78 78
             $this->loadConfigData();
79 79
         }
80 80
         return $this;
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
             $final_data = array_filter($final_data, function($key, $value) {
191 191
                 return in_array($key, self::$required, true) || !empty($value);
192 192
             }, ARRAY_FILTER_USE_BOTH);
193
-            $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT)));
193
+            $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT)));
194 194
             self::getInstance()->loadConfigData();
195 195
             $saved = true;
196
-        } catch (ConfigException $e) {
196
+        }catch (ConfigException $e) {
197 197
             Logger::log($e->getMessage(), LOG_ERR);
198 198
         }
199 199
         return $saved;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function loadConfigData()
227 227
     {
228
-        $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: [];
228
+        $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: [];
229 229
         $this->debug = array_key_exists('debug', $this->config) ? (bool)$this->config['debug'] : FALSE;
230 230
     }
231 231
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public static function getParam($key, $defaultValue = null, $module = null)
248 248
     {
249
-        if(null !== $module) {
250
-            return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue));
249
+        if (null !== $module) {
250
+            return self::getParam(strtolower($module).'.'.$key, self::getParam($key, $defaultValue));
251 251
         }
252 252
         $param = self::getInstance()->get($key);
253 253
         return (null !== $param) ? $param : $defaultValue;
Please login to merge, or discard this patch.
src/base/Security.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             session_start();
74 74
         }
75 75
         // Fix for phpunits
76
-        if(!isset($_SESSION)) {
76
+        if (!isset($_SESSION)) {
77 77
             $_SESSION = [];
78 78
         }
79 79
     }
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
     public static function save($user)
128 128
     {
129 129
         $saved = true;
130
-        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
131
-        $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
130
+        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
131
+        $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
132 132
         $admins[$user['username']]['profile'] = $user['profile'];
133 133
 
134
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
134
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
135 135
         return $saved;
136 136
     }
137 137
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function getAdmins()
176 176
     {
177
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
177
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
178 178
     }
179 179
 
180 180
     /**
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 if (!empty($user) && !empty($admins[$user])) {
201 201
                     $auth = $admins[$user]['hash'];
202
-                    $this->authorized = ($auth === sha1($user . $pass));
202
+                    $this->authorized = ($auth === sha1($user.$pass));
203 203
                     if ($this->authorized) {
204
-                        $this->updateAdmin($user , $admins[$user]['profile']);
204
+                        $this->updateAdmin($user, $admins[$user]['profile']);
205 205
                         ResponseHelper::setCookieHeaders([
206 206
                             [
207 207
                                 'name' => $this->getHash(),
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                         ]);
213 213
                         $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}"));
214 214
                     }
215
-                } else {
215
+                }else {
216 216
                     $this->admin = null;
217 217
                     $this->setSessionKey(self::ADMIN_ID_TOKEN, null);
218 218
                 }
Please login to merge, or discard this patch.
src/base/types/helpers/ApiFormHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     public static function checkApiActions($namespace, $domain, $api) {
18 18
         $actions = [];
19 19
         $reflector = new \ReflectionClass($namespace);
20
-        if(null !== $reflector) {
21
-            foreach($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) {
20
+        if (null !== $reflector) {
21
+            foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) {
22 22
                 $docComments = $apiAction->getDocComment();
23 23
                 $action = self::extractAction($docComments);
24
-                if(null !== $action) {
24
+                if (null !== $action) {
25 25
                     list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain);
26 26
                     list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route);
27 27
                     $formAction = new FormAction();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $action = null;
46 46
         if (false !== preg_match('/@action\s+([^\s]+)/', $doc, $matches)) {
47
-            if(count($matches) > 1) {
47
+            if (count($matches) > 1) {
48 48
                 list(, $action) = $matches;
49 49
             }
50 50
         }
Please login to merge, or discard this patch.
src/bootstrap.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,20 +6,20 @@  discard block
 block discarded – undo
6 6
 
7 7
 defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__);
8 8
 if (preg_match('/vendor/', SOURCE_DIR)) {
9
-    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
10
-    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
11
-} else {
12
-    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
13
-    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
9
+    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
10
+    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
11
+}else {
12
+    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
13
+    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
14 14
 }
15
-defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
16
-defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
17
-defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
18
-defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
19
-defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
20
-defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
15
+defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor');
16
+defined('LOG_DIR') or define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
17
+defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
18
+defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
19
+defined('WEB_DIR') or define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
20
+defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
21 21
 
22
-if(!class_exists(bootstrap::class)) {
22
+if (!class_exists(bootstrap::class)) {
23 23
     /**
24 24
      * Class Bootstrap
25 25
      * @package PSFS
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
     class bootstrap {
28 28
         protected static $loaded = false;
29 29
         public static function load() {
30
-            if(!self::$loaded) {
30
+            if (!self::$loaded) {
31 31
                 defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true);
32
-                if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO);
32
+                if (class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO);
33 33
                 self::$loaded = true;
34 34
             }
35 35
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@
 block discarded – undo
29 29
         public static function load() {
30 30
             if(!self::$loaded) {
31 31
                 defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true);
32
-                if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO);
32
+                if(class_exists("\\PSFS\\base\\Logger")) {
33
+                    \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO);
34
+                }
33 35
                 self::$loaded = true;
34 36
             }
35 37
         }
Please login to merge, or discard this patch.
src/base/extension/CustomTranslateExtension.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,22 +27,22 @@  discard block
 block discarded – undo
27 27
      * @param bool $use_base
28 28
      */
29 29
     protected static function checkLoad($custom_key = null, $force_reload = false, $use_base = false) {
30
-        if($force_reload) self::dropInstance();
30
+        if ($force_reload) self::dropInstance();
31 31
         self::$locale = I18nHelper::extractLocale(Security::getInstance()->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY));
32 32
         self::$generate = (boolean)Config::getParam('i18n.autogenerate', false);
33
-        if(!$use_base) {
33
+        if (!$use_base) {
34 34
             $custom_key = $custom_key ?: Security::getInstance()->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY);
35 35
         }
36
-        if(null !== $custom_key) {
37
-            Logger::log('[' . self::class . '] Custom key detected: ' . $custom_key, LOG_INFO);
38
-            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $custom_key, self::$locale . '.json']);
39
-        } else {
40
-            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']);
36
+        if (null !== $custom_key) {
37
+            Logger::log('['.self::class.'] Custom key detected: '.$custom_key, LOG_INFO);
38
+            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $custom_key, self::$locale.'.json']);
39
+        }else {
40
+            self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']);
41 41
         }
42
-        if(file_exists(self::$filename)) {
43
-            Logger::log('[' . self::class . '] Custom locale detected: ' . $custom_key . ' [' . self::$locale . ']', LOG_INFO);
42
+        if (file_exists(self::$filename)) {
43
+            Logger::log('['.self::class.'] Custom locale detected: '.$custom_key.' ['.self::$locale.']', LOG_INFO);
44 44
             self::$translations = json_decode(file_get_contents(self::$filename), true);
45
-        } elseif(null !== $custom_key) {
45
+        } elseif (null !== $custom_key) {
46 46
             self::checkLoad(null, $force_reload, true);
47 47
         }
48 48
     }
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public static function _($message, $custom_key = null, $force_reload = false) {
85 85
         self::checkLoad($custom_key, $force_reload);
86
-        if(array_key_exists($message, self::$translations)) {
87
-            $translation =  self::$translations[$message];
88
-        } else {
86
+        if (array_key_exists($message, self::$translations)) {
87
+            $translation = self::$translations[$message];
88
+        }else {
89 89
             $translation = gettext($message);
90 90
         }
91
-        if(self::$generate) {
91
+        if (self::$generate) {
92 92
             self::generate($message, $translation);
93 93
         }
94 94
         return $translation;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      * @param string $translation
100 100
      */
101 101
     protected static function generate($message, $translation) {
102
-        if(!array_key_exists($message, self::$translations)) {
102
+        if (!array_key_exists($message, self::$translations)) {
103 103
             self::$translations[$message] = $translation;
104 104
         }
105 105
         file_put_contents(self::$filename, json_encode(array_unique(self::$translations), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@
 block discarded – undo
27 27
      * @param bool $use_base
28 28
      */
29 29
     protected static function checkLoad($custom_key = null, $force_reload = false, $use_base = false) {
30
-        if($force_reload) self::dropInstance();
30
+        if($force_reload) {
31
+            self::dropInstance();
32
+        }
31 33
         self::$locale = I18nHelper::extractLocale(Security::getInstance()->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY));
32 34
         self::$generate = (boolean)Config::getParam('i18n.autogenerate', false);
33 35
         if(!$use_base) {
Please login to merge, or discard this patch.
src/base/dto/JsonResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
         $this->success = $result;
44 44
         $this->total = $total ?: (is_array($data) ? count($data) : 0);
45 45
         $this->pages = $pages;
46
-        if(null !== $message) {
46
+        if (null !== $message) {
47 47
             $this->message = $message;
48 48
         }
49 49
     }
Please login to merge, or discard this patch.