@@ -7,33 +7,33 @@ |
||
7 | 7 | private static $host; |
8 | 8 | private static $config; |
9 | 9 | |
10 | - public function __construct(){ |
|
10 | + public function __construct() { |
|
11 | 11 | # Config |
12 | 12 | self::$config = (new Config)->get(); |
13 | 13 | # Host |
14 | 14 | self::$host = parse_url('http://'.$_SERVER['HTTP_HOST']); |
15 | - if(isset(self::$host['host'])) self::$host = self::$host['host']; |
|
15 | + if (isset(self::$host['host'])) self::$host = self::$host['host']; |
|
16 | 16 | else self::$host = '/'; |
17 | 17 | } |
18 | 18 | |
19 | - public function add($js){ |
|
20 | - if(!is_array($js)) $js = [$js]; |
|
21 | - self::$list = array_merge(self::$list,$js); |
|
19 | + public function add($js) { |
|
20 | + if (!is_array($js)) $js = [$js]; |
|
21 | + self::$list = array_merge(self::$list, $js); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function get(){ |
|
24 | + public function get() { |
|
25 | 25 | $js = array_unique(self::$list); |
26 | - if(!empty($js)) $jsQuery = '?'.implode(':',$js); |
|
26 | + if (!empty($js)) $jsQuery = '?'.implode(':', $js); |
|
27 | 27 | else $jsQuery = ''; |
28 | 28 | return '<script async src="http://'.self::$host.'/javascript.js'.$jsQuery.'"></script>'; |
29 | 29 | } |
30 | 30 | |
31 | - public function compile($query){ |
|
31 | + public function compile($query) { |
|
32 | 32 | $js = $query; |
33 | 33 | $code = ''; |
34 | - foreach($js as $name){ |
|
34 | + foreach ($js as $name) { |
|
35 | 35 | $file = self::$config['core']['js'].'/'.$name.'.js'; |
36 | - if(is_file($file)) $code .= file_get_contents($file); |
|
36 | + if (is_file($file)) $code .= file_get_contents($file); |
|
37 | 37 | } |
38 | 38 | $minifier = new \MatthiasMullie\Minify\JS(); |
39 | 39 | $minifier->add($code); |
@@ -12,19 +12,27 @@ discard block |
||
12 | 12 | self::$config = (new Config)->get(); |
13 | 13 | # Host |
14 | 14 | self::$host = parse_url('http://'.$_SERVER['HTTP_HOST']); |
15 | - if(isset(self::$host['host'])) self::$host = self::$host['host']; |
|
16 | - else self::$host = '/'; |
|
15 | + if(isset(self::$host['host'])) { |
|
16 | + self::$host = self::$host['host']; |
|
17 | + } else { |
|
18 | + self::$host = '/'; |
|
19 | + } |
|
17 | 20 | } |
18 | 21 | |
19 | 22 | public function add($js){ |
20 | - if(!is_array($js)) $js = [$js]; |
|
23 | + if(!is_array($js)) { |
|
24 | + $js = [$js]; |
|
25 | + } |
|
21 | 26 | self::$list = array_merge(self::$list,$js); |
22 | 27 | } |
23 | 28 | |
24 | 29 | public function get(){ |
25 | 30 | $js = array_unique(self::$list); |
26 | - if(!empty($js)) $jsQuery = '?'.implode(':',$js); |
|
27 | - else $jsQuery = ''; |
|
31 | + if(!empty($js)) { |
|
32 | + $jsQuery = '?'.implode(':',$js); |
|
33 | + } else { |
|
34 | + $jsQuery = ''; |
|
35 | + } |
|
28 | 36 | return '<script async src="http://'.self::$host.'/javascript.js'.$jsQuery.'"></script>'; |
29 | 37 | } |
30 | 38 | |
@@ -33,7 +41,9 @@ discard block |
||
33 | 41 | $code = ''; |
34 | 42 | foreach($js as $name){ |
35 | 43 | $file = self::$config['core']['js'].'/'.$name.'.js'; |
36 | - if(is_file($file)) $code .= file_get_contents($file); |
|
44 | + if(is_file($file)) { |
|
45 | + $code .= file_get_contents($file); |
|
46 | + } |
|
37 | 47 | } |
38 | 48 | $minifier = new \MatthiasMullie\Minify\JS(); |
39 | 49 | $minifier->add($code); |