Passed
Push — master ( dce3c5...8912d1 )
by Fran
02:46
created
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.
src/base/types/helpers/I18nHelper.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $locale = Request::header('X-API-LANG', $default);
29 29
         if (empty($locale)) {
30 30
             $locale = Security::getInstance()->getSessionKey(self::PSFS_SESSION_LANGUAGE_KEY);
31
-            if(empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
31
+            if (empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
32 32
                 $BrowserLocales = explode(",", str_replace("-", "_", $_SERVER["HTTP_ACCEPT_LANGUAGE"])); // brosers use en-US, Linux uses en_US
33 33
                 for ($i = 0, $ct = count($BrowserLocales); $i < $ct; $i++) {
34 34
                     list($BrowserLocales[$i]) = explode(";", $BrowserLocales[$i]); //trick for "en;q=0.8"
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
         // TODO check more en locales
45 45
         if (strtolower($locale) === 'en') {
46 46
             $locale = 'en_GB';
47
-        } else {
48
-            $locale = $locale . '_' . strtoupper($locale);
47
+        }else {
48
+            $locale = $locale.'_'.strtoupper($locale);
49 49
         }
50 50
         $default_locales = explode(',', Config::getParam('i18n.locales', ''));
51 51
         if (!in_array($locale, array_merge($default_locales, self::$langs))) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $translations = array();
67 67
         if (file_exists($absoluteTranslationFileName)) {
68 68
             @include($absoluteTranslationFileName);
69
-        } else {
69
+        }else {
70 70
             Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
71 71
         }
72 72
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
     public static function setLocale($default = null)
82 82
     {
83 83
         $locale = self::extractLocale($default);
84
-        Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG);
84
+        Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG);
85 85
         // Load translations
86
-        putenv("LC_ALL=" . $locale);
86
+        putenv("LC_ALL=".$locale);
87 87
         setlocale(LC_ALL, $locale);
88 88
         // Load the locale path
89
-        $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
90
-        Logger::log('Set locale dir ' . $localePath);
89
+        $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
90
+        Logger::log('Set locale dir '.$localePath);
91 91
         GeneratorHelper::createDir($localePath);
92 92
         bindtextdomain('translations', $localePath);
93 93
         textdomain('translations');
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function checkI18Class($namespace) {
125 125
         $isI18n = false;
126
-        if(preg_match('/I18n$/i', $namespace)) {
126
+        if (preg_match('/I18n$/i', $namespace)) {
127 127
             $parentClass = preg_replace('/I18n$/i', '', $namespace);
128
-            if(Router::exists($parentClass)) {
128
+            if (Router::exists($parentClass)) {
129 129
                 $isI18n = true;
130 130
             }
131 131
         }
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
             ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'],
152 152
             ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'],
153 153
             ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'],
154
-            ['n', 'N', 'c', 'C',],
154
+            ['n', 'N', 'c', 'C', ],
155 155
         ];
156 156
 
157 157
         $text = filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
158
-        for($i = 0, $total = count($from); $i < $total; $i++) {
159
-            $text = str_replace($from[$i],$to[$i], $text);
158
+        for ($i = 0, $total = count($from); $i < $total; $i++) {
159
+            $text = str_replace($from[$i], $to[$i], $text);
160 160
         }
161 161
 
162 162
         return $text;
Please login to merge, or discard this patch.
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', Inspector::SCOPE_DEBUG);
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', Inspector::SCOPE_DEBUG);
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', Inspector::SCOPE_DEBUG);
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]), Inspector::SCOPE_DEBUG);
172
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]), Inspector::SCOPE_DEBUG);
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]), Inspector::SCOPE_DEBUG);
222
+            Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG);
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', Inspector::SCOPE_DEBUG);
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/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/extension/CustomTranslateExtension.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,34 +50,34 @@  discard block
 block discarded – undo
50 50
         $session = Security::getInstance();
51 51
         self::$locale = I18nHelper::extractLocale($session->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY));
52 52
         $version = $session->getSessionKey(self::LOCALE_CACHED_VERSION);
53
-        $configVersion = self::$locale . '_' . Config::getParam('cache.var', 'v1');
53
+        $configVersion = self::$locale.'_'.Config::getParam('cache.var', 'v1');
54 54
         if ($forceReload) {
55 55
             self::dropInstance();
56 56
             $version = null;
57 57
             self::$translations = [];
58 58
         }
59
-        if(count(self::$translations) === 0) {
59
+        if (count(self::$translations) === 0) {
60 60
             self::$generate = (boolean)Config::getParam('i18n.autogenerate', false);
61
-            if(null !== $version && $version === $configVersion) {
61
+            if (null !== $version && $version === $configVersion) {
62 62
                 self::$translations = $session->getSessionKey(self::LOCALE_CACHED_TAG);
63
-            } else {
63
+            }else {
64 64
                 if (!$useBase) {
65 65
                     $customKey = $customKey ?: $session->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY);
66 66
                 }
67 67
                 // Gather always the base translations
68 68
                 $standardTranslations = [];
69
-                self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']);
70
-                if(file_exists(self::$filename)) {
69
+                self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']);
70
+                if (file_exists(self::$filename)) {
71 71
                     $standardTranslations = json_decode(file_get_contents(self::$filename), true);
72 72
                 }
73 73
                 // If the project has custom translations, gather them
74 74
                 if (null !== $customKey) {
75
-                    Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO);
76
-                    self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']);
75
+                    Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO);
76
+                    self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']);
77 77
                 }
78 78
                 // Finally we merge base and custom translations to complete all the i18n set
79 79
                 if (file_exists(self::$filename)) {
80
-                    Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO);
80
+                    Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO);
81 81
                     self::$translations = array_merge($standardTranslations, json_decode(file_get_contents(self::$filename), true));
82 82
                     $session->setSessionKey(self::LOCALE_CACHED_TAG, self::$translations);
83 83
                     $session->setSessionKey(self::LOCALE_CACHED_VERSION, $configVersion);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     public function getFilters()
103 103
     {
104 104
         return array(
105
-            new TwigFilter('trans', function ($message) {
105
+            new TwigFilter('trans', function($message) {
106 106
                 return self::_($message);
107 107
             }),
108 108
         );
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         self::checkLoad($customKey, $forceReload);
128 128
         if (is_array(self::$translations) && array_key_exists($message, self::$translations)) {
129 129
             $translation = self::$translations[$message];
130
-        } else {
130
+        }else {
131 131
             $translation = gettext($message);
132 132
         }
133 133
         if (self::$generate) {
Please login to merge, or discard this patch.
src/base/types/helpers/ApiHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $mappedColumn = $tableMap->getColumnByPhpName($field);
36 36
         $required = $mappedColumn->isNotNull() && null === $mappedColumn->getDefaultValue();
37 37
         $fDto = self::parseFieldType($domain, $field, $behaviors, $mappedColumn, $required);
38
-        if(null !== $fDto) {
38
+        if (null !== $fDto) {
39 39
             self::checkPrimaryKey($fDto, $mappedColumn);
40 40
             self::applyCaseToNames($fDto, $mappedColumn);
41 41
         }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         if ($mappedColumn->getSize() > 100) {
153 153
             $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required);
154
-        } else {
154
+        }else {
155 155
             $fDto = self::generateStringField($field, $required);
156 156
         }
157 157
         return $fDto;
Please login to merge, or discard this patch.