@@ -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 | 26 | $code = ''; |
27 | - foreach($js as $name){ |
|
27 | + foreach ($js as $name) { |
|
28 | 28 | $file = self::$config['core']['js'].'/'.$name.'.js'; |
29 | - if(is_file($file)) $code .= file_get_contents($file); |
|
29 | + if (is_file($file)) $code .= file_get_contents($file); |
|
30 | 30 | } |
31 | 31 | $cache = self::$config['core']['js'].'/../cache/javascript.js'; |
32 | - file_put_contents($cache,$code); |
|
32 | + file_put_contents($cache, $code); |
|
33 | 33 | return '<script async src="http://'.self::$host.'/cache/javascript.js"></script>'; |
34 | 34 | } |
35 | 35 | |
36 | - public function compile(){ |
|
36 | + public function compile() { |
|
37 | 37 | # ... |
38 | 38 | } |
39 | 39 |
@@ -12,12 +12,17 @@ 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 | |
@@ -26,7 +31,9 @@ discard block |
||
26 | 31 | $code = ''; |
27 | 32 | foreach($js as $name){ |
28 | 33 | $file = self::$config['core']['js'].'/'.$name.'.js'; |
29 | - if(is_file($file)) $code .= file_get_contents($file); |
|
34 | + if(is_file($file)) { |
|
35 | + $code .= file_get_contents($file); |
|
36 | + } |
|
30 | 37 | } |
31 | 38 | $cache = self::$config['core']['js'].'/../cache/javascript.js'; |
32 | 39 | file_put_contents($cache,$code); |