Passed
Push — master ( 8a1c29...aa2240 )
by Fran
06:43
created
src/base/Security.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function getAdmins()
63 63
     {
64
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
64
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
65 65
     }
66 66
 
67 67
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                         ]);
110 110
                         $this->setSessionKey(AuthHelper::ADMIN_ID_TOKEN, $encrypted);
111 111
                     }
112
-                } else {
112
+                }else {
113 113
                     $this->admin = null;
114 114
                     $this->setSessionKey(AuthHelper::ADMIN_ID_TOKEN, null);
115 115
                 }
Please login to merge, or discard this patch.
src/base/types/helpers/AuthHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         if (NULL === $user || (array_key_exists($user, $admins) && empty($admins[$user]))) {
51 51
             list($user, $pass) = self::getAdminFromCookie();
52 52
         }
53
-        return array_key_exists($user, $admins) ? [$user, sha1($user . $pass)] : [null, null];
53
+        return array_key_exists($user, $admins) ? [$user, sha1($user.$pass)] : [null, null];
54 54
     }
55 55
 
56 56
     public static function checkComplexAuth(array $admins)
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         return base64_encode($encrypted_data);
93 93
     }
94 94
 
95
-    public static function decrypt(string $encrypted_data, string $key): false|string
95
+    public static function decrypt(string $encrypted_data, string $key): false | string
96 96
     {
97 97
         $encrypted_data = base64_decode($encrypted_data);
98 98
         $data = '';
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
         if (null === $userAgent && array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
114 114
             $userAgent = $_SERVER['HTTP_USER_AGENT'];
115 115
         }
116
-        $data = $user . Security::LOGGED_USER_TOKEN . $timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT) . Security::LOGGED_USER_TOKEN . ($userAgent ?? 'psfs');
117
-        return self::encrypt($data, sha1($user . $password));
116
+        $data = $user.Security::LOGGED_USER_TOKEN.$timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT).Security::LOGGED_USER_TOKEN.($userAgent ?? 'psfs');
117
+        return self::encrypt($data, sha1($user.$password));
118 118
     }
119 119
 
120 120
     public static function decodeToken(string $token, string $password): array
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                                     $user = $admin;
147 147
                                     $hash = $profile['hash'];
148 148
                                 }
149
-                            } catch (\Exception $exception) {
149
+                            }catch (\Exception $exception) {
150 150
                                 Logger::log($exception->getMessage(), LOG_ERR);
151 151
                             }
152 152
                             break;
Please login to merge, or discard this patch.
src/base/extension/CustomTranslateExtension.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $locale = $locale ?? self::$locale;
55 55
         // Gather always the base translations
56 56
         $standardTranslations = [];
57
-        self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $locale . '.json']);
57
+        self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $locale.'.json']);
58 58
         if (file_exists(self::$filename)) {
59 59
             $standardTranslations = json_decode(file_get_contents(self::$filename), true);
60 60
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     protected static function generateTranslationsKeys($locale) {
69 69
         self::$translationsKeys[$locale] = [];
70
-        foreach(self::$translations[$locale] as $key => $value) {
70
+        foreach (self::$translations[$locale] as $key => $value) {
71 71
             $tKey = mb_convert_case($key, MB_CASE_LOWER, "UTF-8");
72 72
             self::$translationsKeys[$locale][$tKey] = $key;
73 73
         }
@@ -86,42 +86,42 @@  discard block
 block discarded – undo
86 86
         self::$locale = $forceReload ? $session_locale : I18nHelper::extractLocale($session_locale);
87 87
         $locale = self::$locale;
88 88
         $version = $session->getSessionKey(self::LOCALE_CACHED_VERSION);
89
-        $configVersion = self::$locale . '_' . Config::getParam('cache.var', 'v1');
89
+        $configVersion = self::$locale.'_'.Config::getParam('cache.var', 'v1');
90 90
         if ($forceReload) {
91 91
             Inspector::stats('[translationsCheckLoad] Force translations reload', Inspector::SCOPE_DEBUG);
92 92
             self::dropInstance();
93 93
             $version = null;
94 94
             self::$translations[self::$locale] = [];
95 95
         }
96
-        if((!array_key_exists($locale, self::$translations) || count(self::$translations[$locale]) === 0) && strlen($locale) === 2) {
97
-            $locale = $locale . '_' . strtoupper($locale);
98
-            if(array_key_exists($locale, self::$translations)) {
96
+        if ((!array_key_exists($locale, self::$translations) || count(self::$translations[$locale]) === 0) && strlen($locale) === 2) {
97
+            $locale = $locale.'_'.strtoupper($locale);
98
+            if (array_key_exists($locale, self::$translations)) {
99 99
                 self::$translations[self::$locale] = self::$translations[$locale];
100 100
                 self::generateTranslationsKeys(self::$locale);
101 101
             }
102 102
         }
103
-        if(!array_key_exists($locale, self::$translations) || count(self::$translations[$locale]) === 0) {
103
+        if (!array_key_exists($locale, self::$translations) || count(self::$translations[$locale]) === 0) {
104 104
             Inspector::stats('[translationsCheckLoad] Extracting translations', Inspector::SCOPE_DEBUG);
105 105
             self::$generate = (boolean)Config::getParam('i18n.autogenerate', false);
106
-            if(null !== $version && $version === $configVersion) {
106
+            if (null !== $version && $version === $configVersion) {
107 107
                 Inspector::stats('[translationsCheckLoad] Translations loaded from session', Inspector::SCOPE_DEBUG);
108 108
                 self::$translations = $session->getSessionKey(self::LOCALE_CACHED_TAG);
109
-            } else {
109
+            }else {
110 110
                 if (!$useBase) {
111 111
                     $customKey = $customKey ?: $session->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY);
112 112
                 }
113 113
                 $standardTranslations = self::extractBaseTranslations();
114 114
                 // If the project has custom translations, gather them
115 115
                 if (null !== $customKey) {
116
-                    Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO);
117
-                    self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, $locale . '.json']);
116
+                    Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO);
117
+                    self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, $locale.'.json']);
118 118
                 } elseif (!empty($standardTranslations)) {
119 119
                     self::$translations[$locale] = $standardTranslations;
120 120
                     self::generateTranslationsKeys($locale);
121 121
                 }
122 122
                 // Finally we merge base and custom translations to complete all the i18n set
123 123
                 if (file_exists(self::$filename)) {
124
-                    Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . $locale . ']', LOG_INFO);
124
+                    Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.$locale.']', LOG_INFO);
125 125
                     self::$translations[$locale] = array_merge($standardTranslations, json_decode(file_get_contents(self::$filename), true));
126 126
                     self::generateTranslationsKeys($locale);
127 127
                     $session->setSessionKey(self::LOCALE_CACHED_TAG, self::$translations);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     public function getFilters()
149 149
     {
150 150
         return array(
151
-            new TwigFilter('trans', function ($message) {
151
+            new TwigFilter('trans', function($message) {
152 152
                 return self::_($message);
153 153
             }),
154 154
         );
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public static function _($message, $customKey = null, $forceReload = false)
172 172
     {
173
-        if(0 === count(self::$translations) || $forceReload) {
173
+        if (0 === count(self::$translations) || $forceReload) {
174 174
             self::translationsCheckLoad($customKey, $forceReload);
175 175
         }
176 176
         // Set default translation to catch missing strings
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
         $translation = $message;
179 179
         // Check if the message is already translated ignoring the string case
180 180
         $key = mb_convert_case($message, MB_CASE_LOWER, "UTF-8");
181
-        if(array_key_exists(self::$locale, self::$translationsKeys) && array_key_exists($key, self::$translationsKeys[self::$locale])) {
181
+        if (array_key_exists(self::$locale, self::$translationsKeys) && array_key_exists($key, self::$translationsKeys[self::$locale])) {
182 182
             $message = self::$translationsKeys[self::$locale][$key];
183 183
         }
184 184
         // Check if exists
185 185
         if (array_key_exists(self::$locale, self::$translations) && array_key_exists($message, self::$translations[self::$locale])) {
186 186
             $translation = self::$translations[self::$locale][$message];
187
-        } else if(!$forceReload && !$isDebugMode) {
187
+        }else if (!$forceReload && !$isDebugMode) {
188 188
             $translation = gettext($message);
189 189
         }
190 190
         if (self::$generate) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     protected static function generate($message, $translation)
201 201
     {
202
-        if(!array_key_exists(self::$locale, self::$translations)) {
202
+        if (!array_key_exists(self::$locale, self::$translations)) {
203 203
             self::$translations[self::$locale] = [];
204 204
             self::$translationsKeys[self::$locale] = [];
205 205
         }
Please login to merge, or discard this patch.