Passed
Push — master ( 96a485...3c999b )
by Fran
02:49
created
src/base/Logger.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 
19 19
 
20 20
 if (!defined('LOG_DIR')) {
21
-    GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
22
-    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
21
+    GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs');
22
+    define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
23 23
 }
24 24
 
25 25
 /**
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $args = func_get_args();
59 59
         list($logger, $debug, $path) = $this->setup($args);
60
-        $this->stream = fopen($path . DIRECTORY_SEPARATOR . date('Ymd') . '.log', 'ab+');
60
+        $this->stream = fopen($path.DIRECTORY_SEPARATOR.date('Ymd').'.log', 'ab+');
61 61
         if (false !== $this->stream && is_resource($this->stream)) {
62 62
             $this->addPushLogger($logger, $debug);
63
-        } else {
63
+        }else {
64 64
             throw new ConfigException(t('Error creating logger'));
65 65
         }
66 66
         $this->logLevel = strtoupper(Config::getParam('log.level', 'NOTICE'));
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     private function createLoggerPath()
142 142
     {
143 143
         $logger = $this->setLoggerName();
144
-        $path = Config::getParam('default.log.path',LOG_DIR) . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m');
144
+        $path = Config::getParam('default.log.path', LOG_DIR).DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m');
145 145
         GeneratorHelper::createDir($path);
146 146
         return $path;
147 147
     }
Please login to merge, or discard this patch.
src/base/dto/Dto.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct($hydrate = true)
20 20
     {
21 21
         parent::__construct();
22
-        if($hydrate) {
22
+        if ($hydrate) {
23 23
             $this->fromArray(Request::getInstance()->getData());
24 24
         }
25 25
     }
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
                 /** @var \ReflectionProperty $property */
48 48
                 foreach ($properties as $property) {
49 49
                     $value = $property->getValue($this);
50
-                    if(is_object($value) && method_exists($value, 'toArray')) {
50
+                    if (is_object($value) && method_exists($value, 'toArray')) {
51 51
                         $dto[$property->getName()] = $value->toArray();
52
-                    } elseif(is_array($value)) {
53
-                        foreach($value as &$arrValue) {
54
-                            if($arrValue instanceof Dto) {
52
+                    } elseif (is_array($value)) {
53
+                        foreach ($value as &$arrValue) {
54
+                            if ($arrValue instanceof Dto) {
55 55
                                 $arrValue = $arrValue->toArray();
56 56
                             }
57 57
                         }
58 58
                         $dto[$property->getName()] = $value;
59
-                    } else {
59
+                    }else {
60 60
                         $type = InjectorHelper::extractVarType($property->getDocComment());
61 61
                         $dto[$property->getName()] = $this->checkCastedValue($property->getValue($this), $type);
62 62
                     }
63 63
                 }
64 64
             }
65
-        } catch (\Exception $e) {
66
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
65
+        }catch (\Exception $e) {
66
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
67 67
         }
68 68
         return $dto;
69 69
     }
@@ -86,26 +86,26 @@  discard block
 block discarded – undo
86 86
     protected function parseDtoField(array $properties, $key, $value = null) {
87 87
         list($type, $isArray) = $this->extractTypes($properties, $key);
88 88
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
89
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
90
-            if(null !== $value && is_array($value)) {
91
-                if(!array_key_exists($type, $this->__cache)) {
89
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
90
+            if (null !== $value && is_array($value)) {
91
+                if (!array_key_exists($type, $this->__cache)) {
92 92
                     $this->__cache[$type] = new $type(false);
93 93
                 }
94
-                if($isArray) {
94
+                if ($isArray) {
95 95
                     $this->$key = [];
96
-                    foreach($value as $data) {
97
-                        if(null !== $data && is_array($data)) {
96
+                    foreach ($value as $data) {
97
+                        if (null !== $data && is_array($data)) {
98 98
                             $dto = clone $this->__cache[$type];
99 99
                             $dto->fromArray($data);
100 100
                             array_push($this->$key, $dto);
101 101
                         }
102 102
                     }
103
-                } else {
103
+                }else {
104 104
                     $this->$key = clone $this->__cache[$type];
105 105
                     $this->$key->fromArray($value);
106 106
                 }
107 107
             }
108
-        } else {
108
+        }else {
109 109
             $this->castValue($key, $value, $type);
110 110
         }
111 111
     }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      * @return mixed
173 173
      */
174 174
     protected function checkCastedValue($rawValue, $type) {
175
-        if(null !== $rawValue) {
175
+        if (null !== $rawValue) {
176 176
             switch ($type) {
177 177
                 default:
178 178
                 case 'string':
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                     $value = (bool)$rawValue;
192 192
                     break;
193 193
             }
194
-        } else {
194
+        }else {
195 195
             $value = $rawValue;
196 196
         }
197 197
         return $value;
Please login to merge, or discard this patch.
src/base/types/CurlService.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $headers = [];
89 89
         foreach ($this->getHeaders() as $key => $value) {
90
-            $headers[] = $key . ': ' . $value;
90
+            $headers[] = $key.': '.$value;
91 91
         }
92 92
         $headers[self::PSFS_TRACK_HEADER] = Logger::getUid();
93 93
         if (count($headers)) {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             case Request::VERB_GET:
118 118
                 if (!empty($this->params)) {
119 119
                     $sep = false === strpos($this->getUrl(), '?') ? '?' : '';
120
-                    $this->setUrl($this->getUrl() . $sep . http_build_query($this->getParams()), false);
120
+                    $this->setUrl($this->getUrl().$sep.http_build_query($this->getParams()), false);
121 121
                 }
122 122
                 break;
123 123
             case Request::VERB_POST:
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         if ($this->isDebug() && is_resource($verbose)) {
150 150
             $this->dumpVerboseLogs($verbose);
151 151
         }
152
-        Logger::log($this->getUrl() . ' response: ', LOG_DEBUG, is_array($this->getRawResult()) ? $this->getRawResult() : [$this->getRawResult()]);
152
+        Logger::log($this->getUrl().' response: ', LOG_DEBUG, is_array($this->getRawResult()) ? $this->getRawResult() : [$this->getRawResult()]);
153 153
         $this->info = array_merge($this->info, curl_getinfo($this->con));
154 154
     }
155 155
 
Please login to merge, or discard this patch.
src/base/extension/traits/JsTrait.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
             foreach ($compiledFiles as $file) {
29 29
                 echo "\t\t<script type='text/javascript' src='{$file}'></script>\n";
30 30
             }
31
-        } else {
31
+        }else {
32 32
             $sri = $this->getJsSRIHash($hash, 'js');
33
-            echo "\t\t<script type='text/javascript' src='" . $baseUrl . "/js/" . $hash . ".js'" .
34
-                " crossorigin='anonymous' integrity='sha384-" . $sri . "'></script>\n";
33
+            echo "\t\t<script type='text/javascript' src='".$baseUrl."/js/".$hash.".js'".
34
+                " crossorigin='anonymous' integrity='sha384-".$sri."'></script>\n";
35 35
         }
36 36
     }
37 37
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected function putDebugJs($pathParts, $base, $file, $hash, array &$compiledFiles)
48 48
     {
49
-        $filePath = $hash . "_" . $pathParts[count($pathParts) - 1];
50
-        $compiledFiles[] = "/js/" . $filePath;
49
+        $filePath = $hash."_".$pathParts[count($pathParts) - 1];
50
+        $compiledFiles[] = "/js/".$filePath;
51 51
         $data = "";
52
-        if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file)) {
52
+        if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file)) {
53 53
             $data = file_get_contents($file);
54
-            AssetsHelper::storeContents($base . $filePath, $data);
54
+            AssetsHelper::storeContents($base.$filePath, $data);
55 55
         }
56 56
         return $data;
57 57
     }
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
      */
68 68
     protected function compileJs(array $files, $basePath, $hash, array &$compiledFiles)
69 69
     {
70
-        $base = $basePath . "js" . DIRECTORY_SEPARATOR;
70
+        $base = $basePath."js".DIRECTORY_SEPARATOR;
71 71
         $debug = Config::getParam('debug');
72
-        if ($debug || !file_exists($base . $hash . ".js")) {
72
+        if ($debug || !file_exists($base.$hash.".js")) {
73 73
             $data = '';
74 74
             if (0 < count($files)) {
75 75
                 $minifier = new JS();
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
                     if (file_exists($file)) {
79 79
                         if ($debug) {
80 80
                             $data = $this->putDebugJs($pathParts, $base, $file, $hash, $compiledFiles);
81
-                        } elseif (!file_exists($base . $hash . ".js")) {
81
+                        } elseif (!file_exists($base.$hash.".js")) {
82 82
                             $minifier->add($file);
83 83
                             //$data = $this->putProductionJs($base, $file, $data);
84 84
                         }
85 85
                     }
86 86
                 }
87
-                if($debug) {
88
-                    AssetsHelper::storeContents($base . $hash . ".js", $data);
89
-                } else {
87
+                if ($debug) {
88
+                    AssetsHelper::storeContents($base.$hash.".js", $data);
89
+                }else {
90 90
                     $this->dumpJs($hash, $base, $minifier);
91 91
                 }
92 92
                 unset($minifier);
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
         ini_set('memory_limit', -1);
108 108
         GeneratorHelper::createDir($base);
109 109
         if (Config::getParam('assets.obfuscate', false)) {
110
-            $minifier->gzip($base . $hash . ".js");
111
-        } else {
112
-            $minifier->minify($base . $hash . ".js");
110
+            $minifier->gzip($base.$hash.".js");
111
+        }else {
112
+            $minifier->minify($base.$hash.".js");
113 113
         }
114 114
     }
115 115
 }
Please login to merge, or discard this patch.
src/base/extension/traits/SRITrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 use PSFS\base\types\helpers\Inspector;
6 6
 use PSFS\base\types\traits\SingletonTrait;
7 7
 
8
-defined('CSS_SRI_FILENAME') or define('CSS_SRI_FILENAME', CACHE_DIR . DIRECTORY_SEPARATOR . 'css.sri.json');
9
-defined('JS_SRI_FILENAME') or define('JS_SRI_FILENAME', CACHE_DIR . DIRECTORY_SEPARATOR . 'js.sri.json');
8
+defined('CSS_SRI_FILENAME') or define('CSS_SRI_FILENAME', CACHE_DIR.DIRECTORY_SEPARATOR.'css.sri.json');
9
+defined('JS_SRI_FILENAME') or define('JS_SRI_FILENAME', CACHE_DIR.DIRECTORY_SEPARATOR.'js.sri.json');
10 10
 /**
11 11
  * Trait SRITrait
12 12
  * @package PSFS\base\extension\traits
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         /** @var Cache $cache */
33 33
         $cache = Cache::getInstance();
34 34
         $this->sri = $cache->getDataFromFile($this->sriFilename, Cache::JSON, true);
35
-        if(empty($this->sri)) {
35
+        if (empty($this->sri)) {
36 36
             $this->sri = [];
37 37
         }
38 38
     }
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
      * @throws \PSFS\base\exception\GeneratorException
45 45
      */
46 46
     protected function getSriHash($hash, $type = 'js') {
47
-        if(array_key_exists($hash, $this->sri)) {
47
+        if (array_key_exists($hash, $this->sri)) {
48 48
             $sriHash = $this->sri[$hash];
49
-        } else {
50
-            Inspector::stats('[SRITrait] Generating SRI for ' . $hash, Inspector::SCOPE_DEBUG);
51
-            $filename = WEB_DIR . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $hash . '.' . $type;
49
+        }else {
50
+            Inspector::stats('[SRITrait] Generating SRI for '.$hash, Inspector::SCOPE_DEBUG);
51
+            $filename = WEB_DIR.DIRECTORY_SEPARATOR.$type.DIRECTORY_SEPARATOR.$hash.'.'.$type;
52 52
             $sriHash = base64_encode(hash("sha384", file_get_contents($filename), true));
53 53
             $this->sri[$hash] = $sriHash;
54 54
             Cache::getInstance()->storeData($this->sriFilename, $this->sri, Cache::JSON, true);
Please login to merge, or discard this patch.
src/base/extension/traits/CssTrait.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
     protected function compileCss($basePath, $hash)
35 35
     {
36 36
         $debug = Config::getParam('debug');
37
-        $base = $basePath . "css" . DIRECTORY_SEPARATOR;
38
-        if ($debug || !file_exists($base . $hash . ".css")) {
37
+        $base = $basePath."css".DIRECTORY_SEPARATOR;
38
+        if ($debug || !file_exists($base.$hash.".css")) {
39 39
             $data = '';
40 40
             if (0 < count($this->files)) {
41 41
                 $minifier = new CSS();
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
                     $data = $this->processCssLine($file, $base, $data, $hash);
44 44
                 }
45 45
             }
46
-            if($debug) {
47
-                AssetsHelper::storeContents($base . $hash . ".css", $data);
48
-            } else {
46
+            if ($debug) {
47
+                AssetsHelper::storeContents($base.$hash.".css", $data);
48
+            }else {
49 49
                 $minifier = new CSS();
50 50
                 $minifier->add($data);
51 51
                 ini_set('max_execution_time', -1);
52 52
                 ini_set('memory_limit', -1);
53 53
                 GeneratorHelper::createDir($base);
54
-                $minifier->minify($base . $hash . ".css");
54
+                $minifier->minify($base.$hash.".css");
55 55
             }
56 56
             unset($minifier);
57 57
         }
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
         if (file_exists($file)) {
72 72
             $debug = Config::getParam('debug');
73 73
             $pathParts = explode("/", $file);
74
-            $filePath = $this->hash . "_" . $pathParts[count($pathParts) - 1];
75
-            if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file) || $debug) {
74
+            $filePath = $this->hash."_".$pathParts[count($pathParts) - 1];
75
+            if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file) || $debug) {
76 76
                 //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados
77
-                if (file_exists($base . $hash . ".css") && @unlink($base . $hash . ".css") === false) {
78
-                    throw new ConfigException("Can't unlink file " . $base . $hash . ".css");
77
+                if (file_exists($base.$hash.".css") && @unlink($base.$hash.".css") === false) {
78
+                    throw new ConfigException("Can't unlink file ".$base.$hash.".css");
79 79
                 }
80 80
                 $this->loopCssLines($file);
81 81
             }
82 82
             if ($debug) {
83 83
                 $data = file_get_contents($file);
84
-                AssetsHelper::storeContents($base . $filePath, $data);
85
-            } else {
84
+                AssetsHelper::storeContents($base.$filePath, $data);
85
+            }else {
86 86
                 $data .= file_get_contents($file);
87 87
             }
88
-            $this->compiledFiles[] = "/css/" . $filePath;
88
+            $this->compiledFiles[] = "/css/".$filePath;
89 89
         }
90 90
 
91 91
         return $data;
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
      */
118 118
     protected function extractCssResources($source, $file)
119 119
     {
120
-        Inspector::stats('[CssTrait] Start collecting resources from ' . $file, Inspector::SCOPE_DEBUG);
120
+        Inspector::stats('[CssTrait] Start collecting resources from '.$file, Inspector::SCOPE_DEBUG);
121 121
         $sourceFile = AssetsHelper::extractSourceFilename($source);
122
-        $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $sourceFile);
122
+        $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$sourceFile);
123 123
         $origPart = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig);
124 124
         try {
125 125
             if (count($source) > 1 && array_key_exists(1, $origPart)) {
126
-                $dest = $this->path . $origPart[1];
126
+                $dest = $this->path.$origPart[1];
127 127
                 GeneratorHelper::createDir(dirname($dest));
128 128
                 if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) {
129 129
                     if (@copy($orig, $dest) === FALSE) {
130
-                        throw new \RuntimeException('Can\' copy ' . $dest . '');
130
+                        throw new \RuntimeException('Can\' copy '.$dest.'');
131 131
                     }
132 132
                     Logger::log("$orig copiado a $dest", LOG_INFO);
133 133
                 }
134 134
             }
135
-        } catch (\Exception $e) {
135
+        }catch (\Exception $e) {
136 136
             Logger::log($e->getMessage(), LOG_ERR);
137 137
         }
138
-        Inspector::stats('[CssTrait] End collecting resources from ' . $file, Inspector::SCOPE_DEBUG);
138
+        Inspector::stats('[CssTrait] End collecting resources from '.$file, Inspector::SCOPE_DEBUG);
139 139
     }
140 140
 
141 141
     /**
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
             foreach ($compiledFiles as $file) {
150 150
                 echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>";
151 151
             }
152
-        } else {
152
+        }else {
153 153
             $sri = $this->getCssSRIHash($hash, 'css');
154
-            echo "\t\t<link href='" . $baseUrl . "/css/" . $hash . ".css' rel='stylesheet' " .
155
-            "crossorigin='anonymous' integrity='sha384-" . $sri . "'>";
154
+            echo "\t\t<link href='".$baseUrl."/css/".$hash.".css' rel='stylesheet' ".
155
+            "crossorigin='anonymous' integrity='sha384-".$sri."'>";
156 156
         }
157 157
     }
158 158
 }
Please login to merge, or discard this patch.
src/base/extension/AssetsNode.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,20 +34,20 @@
 block discarded – undo
34 34
         $scripts = $this->getNode("scripts");
35 35
 
36 36
         //Creamos el parser
37
-        $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\'' . $this->type . '\')')
37
+        $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\''.$this->type.'\')')
38 38
             ->raw(";\n");
39 39
 
40 40
         //Asociamos el hash
41
-        $compiler->write('$parser->setHash(\'' . $this->hash . '\')')
41
+        $compiler->write('$parser->setHash(\''.$this->hash.'\')')
42 42
             ->raw(";\n");
43 43
 
44 44
         //Inicializamos SRI
45
-        $compiler->write('$parser->init(\'' . $this->type . '\')')
45
+        $compiler->write('$parser->init(\''.$this->type.'\')')
46 46
             ->raw(";\n");
47 47
 
48 48
         //Asociamos los ficheros
49 49
         foreach ($scripts->getAttribute("value") as $value) {
50
-            $compiler->write('$parser->addFile(\'' . $value . '\')')->raw(";\n");
50
+            $compiler->write('$parser->addFile(\''.$value.'\')')->raw(";\n");
51 51
         }
52 52
 
53 53
         //Procesamos los ficheros
Please login to merge, or discard this patch.