Passed
Push — master ( 8ea9d3...4c87c8 )
by Fran
02:50
created
src/base/extension/traits/CssTrait.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
     protected function compileCss($basePath, $hash)
31 31
     {
32 32
         $debug = Config::getParam('debug');
33
-        $base = $basePath . "css" . DIRECTORY_SEPARATOR;
34
-        if ($debug || !file_exists($base . $hash . ".css")) {
33
+        $base = $basePath."css".DIRECTORY_SEPARATOR;
34
+        if ($debug || !file_exists($base.$hash.".css")) {
35 35
             $data = '';
36 36
             if (0 < count($this->files)) {
37 37
                 $minifier = new CSS();
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
                     $data = $this->processCssLine($file, $base, $data, $hash);
40 40
                 }
41 41
             }
42
-            if($debug) {
43
-                AssetsHelper::storeContents($base . $hash . ".css", $data);
44
-            } else {
42
+            if ($debug) {
43
+                AssetsHelper::storeContents($base.$hash.".css", $data);
44
+            }else {
45 45
                 $minifier = new CSS();
46 46
                 $minifier->add($data);
47 47
                 ini_set('max_execution_time', -1);
48 48
                 ini_set('memory_limit', -1);
49 49
                 GeneratorHelper::createDir($base);
50
-                $minifier->minify($base . $hash . ".css");
50
+                $minifier->minify($base.$hash.".css");
51 51
             }
52 52
             unset($minifier);
53 53
         }
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
         if (file_exists($file)) {
68 68
             $debug = Config::getParam('debug');
69 69
             $pathParts = explode("/", $file);
70
-            $filePath = $this->hash . "_" . $pathParts[count($pathParts) - 1];
71
-            if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file) || $debug) {
70
+            $filePath = $this->hash."_".$pathParts[count($pathParts) - 1];
71
+            if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file) || $debug) {
72 72
                 //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados
73
-                if (file_exists($base . $hash . ".css") && @unlink($base . $hash . ".css") === false) {
74
-                    throw new ConfigException("Can't unlink file " . $base . $hash . ".css");
73
+                if (file_exists($base.$hash.".css") && @unlink($base.$hash.".css") === false) {
74
+                    throw new ConfigException("Can't unlink file ".$base.$hash.".css");
75 75
                 }
76 76
                 $this->loopCssLines($file);
77 77
             }
78 78
             if ($debug) {
79 79
                 $data = file_get_contents($file);
80
-                AssetsHelper::storeContents($base . $filePath, $data);
81
-            } else {
80
+                AssetsHelper::storeContents($base.$filePath, $data);
81
+            }else {
82 82
                 $data .= file_get_contents($file);
83 83
             }
84
-            $this->compiledFiles[] = "/css/" . $filePath;
84
+            $this->compiledFiles[] = "/css/".$filePath;
85 85
         }
86 86
 
87 87
         return $data;
@@ -113,25 +113,25 @@  discard block
 block discarded – undo
113 113
      */
114 114
     protected function extractCssResources($source, $file)
115 115
     {
116
-        Inspector::stats('[CssTrait] Start collecting resources from ' . $file, Inspector::SCOPE_DEBUG);
116
+        Inspector::stats('[CssTrait] Start collecting resources from '.$file, Inspector::SCOPE_DEBUG);
117 117
         $sourceFile = AssetsHelper::extractSourceFilename($source);
118
-        $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $sourceFile);
118
+        $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$sourceFile);
119 119
         $origPart = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig);
120 120
         try {
121 121
             if (count($source) > 1 && array_key_exists(1, $origPart)) {
122
-                $dest = $this->path . $origPart[1];
122
+                $dest = $this->path.$origPart[1];
123 123
                 GeneratorHelper::createDir(dirname($dest));
124 124
                 if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) {
125 125
                     if (@copy($orig, $dest) === FALSE) {
126
-                        throw new \RuntimeException('Can\' copy ' . $dest . '');
126
+                        throw new \RuntimeException('Can\' copy '.$dest.'');
127 127
                     }
128 128
                     Logger::log("$orig copiado a $dest", LOG_INFO);
129 129
                 }
130 130
             }
131
-        } catch (\Exception $e) {
131
+        }catch (\Exception $e) {
132 132
             Logger::log($e->getMessage(), LOG_ERR);
133 133
         }
134
-        Inspector::stats('[CssTrait] End collecting resources from ' . $file, Inspector::SCOPE_DEBUG);
134
+        Inspector::stats('[CssTrait] End collecting resources from '.$file, Inspector::SCOPE_DEBUG);
135 135
     }
136 136
 
137 137
     /**
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
             foreach ($compiledFiles as $file) {
147 147
                 echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>";
148 148
             }
149
-        } else {
150
-            echo "\t\t<link href='" . $baseUrl . "/css/" . $hash . ".css' rel='stylesheet' " .
149
+        }else {
150
+            echo "\t\t<link href='".$baseUrl."/css/".$hash.".css' rel='stylesheet' ".
151 151
                 //"crossorigin='anonymous' integrity='sha384-" . $sri . "'>";
152 152
                 "media='screen, print'>";
153 153
         }
Please login to merge, or discard this patch.
src/base/extension/traits/JsTrait.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
             foreach ($compiledFiles as $file) {
25 25
                 echo "\t\t<script type='text/javascript' src='{$file}'></script>\n";
26 26
             }
27
-        } else {
28
-            echo "\t\t<script type='text/javascript' src='" . $baseUrl . "/js/" . $hash . ".js'" .
27
+        }else {
28
+            echo "\t\t<script type='text/javascript' src='".$baseUrl."/js/".$hash.".js'".
29 29
                 //" crossorigin='anonymous' integrity='sha384-" . $sri . "'></script>\n";
30 30
                 "></script>\n";
31 31
         }
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      */
43 43
     protected function putDebugJs($pathParts, $base, $file, $hash, array &$compiledFiles)
44 44
     {
45
-        $filePath = $hash . "_" . $pathParts[count($pathParts) - 1];
46
-        $compiledFiles[] = "/js/" . $filePath;
45
+        $filePath = $hash."_".$pathParts[count($pathParts) - 1];
46
+        $compiledFiles[] = "/js/".$filePath;
47 47
         $data = "";
48
-        if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file)) {
48
+        if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file)) {
49 49
             $data = file_get_contents($file);
50
-            AssetsHelper::storeContents($base . $filePath, $data);
50
+            AssetsHelper::storeContents($base.$filePath, $data);
51 51
         }
52 52
         return $data;
53 53
     }
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function compileJs(array $files, $basePath, $hash, array &$compiledFiles)
65 65
     {
66
-        $base = $basePath . "js" . DIRECTORY_SEPARATOR;
66
+        $base = $basePath."js".DIRECTORY_SEPARATOR;
67 67
         $debug = Config::getParam('debug');
68
-        if ($debug || !file_exists($base . $hash . ".js")) {
68
+        if ($debug || !file_exists($base.$hash.".js")) {
69 69
             $data = '';
70 70
             if (0 < count($files)) {
71 71
                 $minifier = new JS();
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
                     if (file_exists($file)) {
75 75
                         if ($debug) {
76 76
                             $data = $this->putDebugJs($pathParts, $base, $file, $hash, $compiledFiles);
77
-                        } elseif (!file_exists($base . $hash . ".js")) {
77
+                        } elseif (!file_exists($base.$hash.".js")) {
78 78
                             $minifier->add($file);
79 79
                             //$data = $this->putProductionJs($base, $file, $data);
80 80
                         }
81 81
                     }
82 82
                 }
83
-                if($debug) {
84
-                    AssetsHelper::storeContents($base . $hash . ".js", $data);
85
-                } else {
83
+                if ($debug) {
84
+                    AssetsHelper::storeContents($base.$hash.".js", $data);
85
+                }else {
86 86
                     $this->dumpJs($hash, $base, $minifier);
87 87
                 }
88 88
                 unset($minifier);
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
         ini_set('memory_limit', -1);
104 104
         GeneratorHelper::createDir($base);
105 105
         if (Config::getParam('assets.obfuscate', false)) {
106
-            $minifier->gzip($base . $hash . ".js");
107
-        } else {
108
-            $minifier->minify($base . $hash . ".js");
106
+            $minifier->gzip($base.$hash.".js");
107
+        }else {
108
+            $minifier->minify($base.$hash.".js");
109 109
         }
110 110
     }
111 111
 }
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +38 added lines, -38 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
             }
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public static function createDir($dir)
61 61
     {
62
-        if(!empty($dir)) {
62
+        if (!empty($dir)) {
63 63
             try {
64 64
                 if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
65
-                    throw new \Exception(t('Can\'t create directory ') . $dir);
65
+                    throw new \Exception(t('Can\'t create directory ').$dir);
66 66
                 }
67
-            } catch (\Exception $e) {
67
+            }catch (\Exception $e) {
68 68
                 syslog(LOG_WARNING, $e->getMessage());
69 69
                 if (!file_exists(dirname($dir))) {
70
-                    throw new GeneratorException($e->getMessage() . $dir);
70
+                    throw new GeneratorException($e->getMessage().$dir);
71 71
                 }
72 72
             }
73 73
         }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public static function getTemplatePath()
81 81
     {
82
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
82
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
83 83
         return realpath($path);
84 84
     }
85 85
 
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
      * @throws \ReflectionException
99 99
      */
100 100
     public static function checkCustomNamespaceApi($namespace) {
101
-        if(!empty($namespace)) {
102
-            if(class_exists($namespace)) {
101
+        if (!empty($namespace)) {
102
+            if (class_exists($namespace)) {
103 103
                 $reflector = new \ReflectionClass($namespace);
104
-                if(!$reflector->isSubclassOf(Api::class)) {
104
+                if (!$reflector->isSubclassOf(Api::class)) {
105 105
                     throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501);
106
-                } elseif(!$reflector->isAbstract()) {
106
+                } elseif (!$reflector->isAbstract()) {
107 107
                     throw new GeneratorException(t('La clase definida debe ser abstracta'), 501);
108 108
                 }
109
-            } else {
109
+            }else {
110 110
                 throw new GeneratorException(t('La clase definida para extender la API no existe'), 501);
111 111
             }
112 112
         }
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public static function createRoot($path = WEB_DIR, OutputInterface $output = null, $quiet = false) {
122 122
 
123
-        if(null === $output) {
123
+        if (null === $output) {
124 124
             $output = new ConsoleOutput();
125 125
         }
126 126
 
127 127
         GeneratorHelper::createDir($path);
128 128
         $paths = array("js", "css", "img", "media", "font");
129 129
         foreach ($paths as $htmlPath) {
130
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
130
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
131 131
         }
132 132
 
133 133
         // Generates the root needed files
@@ -140,22 +140,22 @@  discard block
 block discarded – undo
140 140
         ];
141 141
         $output->writeln('Start creating html files');
142 142
         foreach ($files as $templates => $filename) {
143
-            $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig');
144
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
145
-                if(!$quiet) {
146
-                    $output->writeln('Can\t create the file ' . $filename);
143
+            $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
144
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
145
+                if (!$quiet) {
146
+                    $output->writeln('Can\t create the file '.$filename);
147 147
                 }
148
-            } else {
149
-                if(!$quiet) {
150
-                    $output->writeln($filename . ' created successfully');
148
+            }else {
149
+                if (!$quiet) {
150
+                    $output->writeln($filename.' created successfully');
151 151
                 }
152 152
             }
153 153
         }
154 154
 
155 155
         //Export base locale translations
156
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
157
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
158
-            self::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
156
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
157
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
158
+            self::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
159 159
         }
160 160
     }
161 161
 
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
     {
172 172
         if (file_exists($filenamePath)) {
173 173
             $destfolder = basename($filenamePath);
174
-            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
174
+            if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
175 175
                 if (is_dir($filenamePath)) {
176
-                    self::copyr($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
177
-                } else {
178
-                    if (@copy($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
179
-                        throw new ConfigException("Can't copy " . $filenamePath . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
176
+                    self::copyr($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
177
+                }else {
178
+                    if (@copy($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
179
+                        throw new ConfigException("Can't copy ".$filenamePath." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
180 180
                     }
181 181
                 }
182 182
             }
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
         self::createDir($dst);
195 195
         while (false !== ($file = readdir($dir))) {
196 196
             if (($file != '.') && ($file != '..')) {
197
-                if (is_dir($src . '/' . $file)) {
198
-                    self::copyr($src . '/' . $file, $dst . '/' . $file);
199
-                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
200
-                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
197
+                if (is_dir($src.'/'.$file)) {
198
+                    self::copyr($src.'/'.$file, $dst.'/'.$file);
199
+                } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) {
200
+                    throw new ConfigException("Can't copy ".$src." to ".$dst);
201 201
                 }
202 202
             }
203 203
         }
Please login to merge, or discard this patch.