Passed
Push — master ( 96a485...3c999b )
by Fran
02:49
created
src/services/AdminServices.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $platform = trim(Config::getInstance()->get('platform.name'));
35 35
         header('HTTP/1.1 401 Unauthorized');
36
-        header('WWW-Authenticate: Basic Realm="' . $platform . '"');
36
+        header('WWW-Authenticate: Basic Realm="'.$platform.'"');
37 37
         echo t('Zona restringida');
38 38
         exit();
39 39
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                             $admin['class'] = 'primary';
76 76
                             break;
77 77
                     }
78
-                } else {
78
+                }else {
79 79
                     $admin['class'] = 'primary';
80 80
                 }
81 81
             }
Please login to merge, or discard this patch.
src/base/Template.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $dump = '';
121 121
         try {
122 122
             $dump = $this->tpl->render($tpl, $vars);
123
-        } catch (\Exception $e) {
123
+        }catch (\Exception $e) {
124 124
             Logger::log($e->getMessage(), LOG_ERR);
125 125
         }
126 126
         return $dump;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     public function regenerateTemplates()
148 148
     {
149 149
         $this->generateTemplatesCache();
150
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true);
150
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true);
151 151
         $translations = [];
152 152
         if (is_array($domains)) {
153 153
             $translations = $this->parsePathTranslations($domains);
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
             // force compilation
173 173
             if ($file->isFile()) {
174 174
                 try {
175
-                    $this->tpl->load(str_replace($tplDir . '/', '', $file));
176
-                } catch (\Exception $e) {
175
+                    $this->tpl->load(str_replace($tplDir.'/', '', $file));
176
+                }catch (\Exception $e) {
177 177
                     Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]);
178 178
                 }
179 179
             }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      */
254 254
     private function loadDomains()
255 255
     {
256
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true);
256
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true);
257 257
         if (null !== $domains) {
258 258
             foreach ($domains as $domain => $paths) {
259 259
                 $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain));
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     {
269 269
         $loader = new FilesystemLoader(GeneratorHelper::getTemplatePath());
270 270
         $this->tpl = new Environment($loader, array(
271
-            'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig',
271
+            'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig',
272 272
             'debug' => (bool)$this->debug,
273 273
             'auto_reload' => Config::getParam('twig.autoreload', TRUE),
274 274
         ));
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +37 added lines, -37 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(Api::class)) {
102
+                if (!$reflector->isSubclassOf(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
         }
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public static function createRoot($path = WEB_DIR, OutputInterface $output = null, $quiet = false) {
120 120
 
121
-        if(null === $output) {
121
+        if (null === $output) {
122 122
             $output = new ConsoleOutput();
123 123
         }
124 124
 
125 125
         GeneratorHelper::createDir($path);
126 126
         $paths = array("js", "css", "img", "media", "font");
127 127
         foreach ($paths as $htmlPath) {
128
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
128
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
129 129
         }
130 130
 
131 131
         // Generates the root needed files
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
         ];
139 139
         $output->writeln('Start creating html files');
140 140
         foreach ($files as $templates => $filename) {
141
-            $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig');
142
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
143
-                if(!$quiet) {
144
-                    $output->writeln('Can\t create the file ' . $filename);
141
+            $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
142
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
143
+                if (!$quiet) {
144
+                    $output->writeln('Can\t create the file '.$filename);
145 145
                 }
146
-            } else {
147
-                if(!$quiet) {
148
-                    $output->writeln($filename . ' created successfully');
146
+            }else {
147
+                if (!$quiet) {
148
+                    $output->writeln($filename.' created successfully');
149 149
                 }
150 150
             }
151 151
         }
152 152
 
153 153
         //Export base locale translations
154
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
155
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
156
-            self::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
154
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
155
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
156
+            self::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
157 157
         }
158 158
     }
159 159
 
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
     {
170 170
         if (file_exists($filenamePath)) {
171 171
             $destfolder = basename($filenamePath);
172
-            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
172
+            if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
173 173
                 if (is_dir($filenamePath)) {
174
-                    self::copyr($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
175
-                } else {
176
-                    if (@copy($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
177
-                        throw new ConfigException("Can't copy " . $filenamePath . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
174
+                    self::copyr($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
175
+                }else {
176
+                    if (@copy($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
177
+                        throw new ConfigException("Can't copy ".$filenamePath." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
178 178
                     }
179 179
                 }
180 180
             }
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
         self::createDir($dst);
193 193
         while (false !== ($file = readdir($dir))) {
194 194
             if (($file != '.') && ($file != '..')) {
195
-                if (is_dir($src . '/' . $file)) {
196
-                    self::copyr($src . '/' . $file, $dst . '/' . $file);
197
-                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
198
-                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
195
+                if (is_dir($src.'/'.$file)) {
196
+                    self::copyr($src.'/'.$file, $dst.'/'.$file);
197
+                } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) {
198
+                    throw new ConfigException("Can't copy ".$src." to ".$dst);
199 199
                 }
200 200
             }
201 201
         }
Please login to merge, or discard this patch.
src/base/Security.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function getAdmins()
66 66
     {
67
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
67
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
68 68
     }
69 69
 
70 70
     /**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 }
90 90
                 if (!empty($user) && !empty($admins[$user])) {
91 91
                     $auth = $admins[$user]['hash'];
92
-                    $this->authorized = ($auth === sha1($user . $pass));
92
+                    $this->authorized = ($auth === sha1($user.$pass));
93 93
                     if ($this->authorized) {
94 94
                         $this->updateAdmin($user, $admins[$user]['profile']);
95 95
                         ResponseHelper::setCookieHeaders([
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                         ]);
103 103
                         $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}"));
104 104
                     }
105
-                } else {
105
+                }else {
106 106
                     $this->admin = null;
107 107
                     $this->setSessionKey(self::ADMIN_ID_TOKEN, null);
108 108
                 }
Please login to merge, or discard this patch.
src/base/types/traits/Security/SessionTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function hasSessionKey($key) {
33 33
         $exists = false;
34
-        if(array_key_exists($key, $this->session)) {
34
+        if (array_key_exists($key, $this->session)) {
35 35
             $exists = true;
36 36
         }
37 37
         return $exists;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             session_start();
57 57
         }
58 58
         // Fix for phpunits
59
-        if(!isset($_SESSION)) {
59
+        if (!isset($_SESSION)) {
60 60
             $_SESSION = [];
61 61
         }
62 62
         $this->session = null === $_SESSION ? [] : $_SESSION;
Please login to merge, or discard this patch.
src/base/types/traits/Security/ProfileTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,11 +86,11 @@
 block discarded – undo
86 86
     public static function save($user)
87 87
     {
88 88
         $saved = true;
89
-        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
90
-        $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
89
+        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
90
+        $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
91 91
         $admins[$user['username']]['profile'] = $user['profile'];
92 92
 
93
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
93
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
94 94
         return $saved;
95 95
     }
96 96
 
Please login to merge, or discard this patch.
src/base/types/helpers/AssetsHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -69,21 +69,21 @@  discard block
 block discarded – undo
69 69
     {
70 70
         $path = explode("/", $string);
71 71
         $originalFilename = end($path);
72
-        $base = WEB_DIR . DIRECTORY_SEPARATOR;
72
+        $base = WEB_DIR.DIRECTORY_SEPARATOR;
73 73
         $debug = Config::getParam('debug');
74 74
         $cache = Config::getParam('cache.var');
75
-        $cache = $cache ? '.' . $cache : '';
75
+        $cache = $cache ? '.'.$cache : '';
76 76
         $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión
77 77
         $mime = finfo_file($finfo, $filenamePath);
78 78
         $extension = explode(".", $string);
79 79
         $extension = end($extension);
80
-        $file = "/" . substr(md5($string), 0, 8) . "." . $extension;
80
+        $file = "/".substr(md5($string), 0, 8).".".$extension;
81 81
         finfo_close($finfo);
82 82
         if (preg_match('/\.css$/i', $string)) {
83
-            $file = "/" . substr(md5($string), 0, 8) . "$cache.css";
83
+            $file = "/".substr(md5($string), 0, 8)."$cache.css";
84 84
             $htmlBase = "css";
85 85
         } elseif (preg_match('/\.js$/i', $string)) {
86
-            $file = "/" . substr(md5($string), 0, 8) . "$cache.js";
86
+            $file = "/".substr(md5($string), 0, 8)."$cache.js";
87 87
             $htmlBase = "js";
88 88
         } elseif (preg_match("/image/i", $mime)) {
89 89
             $htmlBase = "img";
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
             $file = $name;
99 99
         }
100 100
         if ($debug) {
101
-            $file = str_replace("." . $extension, "_" . $originalFilename, $file);
101
+            $file = str_replace(".".$extension, "_".$originalFilename, $file);
102 102
         }
103
-        $filePath = $htmlBase . $file;
103
+        $filePath = $htmlBase.$file;
104 104
 
105 105
         return array($base, $htmlBase, $filePath);
106 106
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     {
116 116
         GeneratorHelper::createDir(dirname($path));
117 117
         if ("" !== $content && false === file_put_contents($path, $content)) {
118
-            throw new ConfigException(t('No se tienen permisos para escribir en ' . $path));
118
+            throw new ConfigException(t('No se tienen permisos para escribir en '.$path));
119 119
         }
120 120
     }
121 121
 }
Please login to merge, or discard this patch.
src/controller/DocumentorController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
      */
70 70
     public function swaggerUi($domain)
71 71
     {
72
-        if(!Router::getInstance()->domainExists($domain)) {
72
+        if (!Router::getInstance()->domainExists($domain)) {
73 73
             throw new RouterException('Domains is empty');
74 74
         }
75 75
         return $this->render('swagger.html.twig', [
Please login to merge, or discard this patch.
src/controller/base/Admin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@
 block discarded – undo
38 38
         if (self::isTest()) {
39 39
             throw new UserAuthException();
40 40
         }
41
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
41
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
42 42
             return AdminServices::getInstance()->setAdminHeaders();
43
-        } else {
43
+        }else {
44 44
             return UserController::showAdminManager();
45 45
         }
46 46
     }
Please login to merge, or discard this patch.