1 | <?php declare(strict_types=1); |
||
22 | class Base implements Compiler |
||
23 | { |
||
24 | /** |
||
25 | * We represent the source file that needs to be compiled. |
||
26 | * |
||
27 | * @var SplFileInfo |
||
28 | */ |
||
29 | protected $file; |
||
30 | |||
31 | /** |
||
32 | * We represent the final destination asset file that will be created. |
||
33 | * |
||
34 | * @var SplFileInfo |
||
35 | */ |
||
36 | protected $destination; |
||
37 | |||
38 | /** |
||
39 | * If the $file is indeed a file we will read it's contents into this |
||
40 | * property. Remember it's possible that we are given a folder... |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $source = ''; |
||
45 | |||
46 | /** |
||
47 | * This basically tells us if we are allowed to minify the compiled source. |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $debug; |
||
52 | |||
53 | /** |
||
54 | * Only applies when building css assets. |
||
55 | * Used in conjuction with: ```vladkens/autoprefixer-php```. |
||
56 | * |
||
57 | * @var bool |
||
58 | */ |
||
59 | protected $autoprefix; |
||
60 | |||
61 | public function __construct(SplFileInfo $file, SplFileInfo $destination, bool $debug, bool $autoprefix) |
||
76 | |||
77 | /** |
||
78 | * @inheritDoc |
||
79 | * |
||
80 | * This implementation caters for both standard native Css and Js files |
||
81 | * that don't need any compiling as such. The less and sass compilers |
||
82 | * extend the css compiler. |
||
83 | */ |
||
84 | public function compile(): string |
||
104 | |||
105 | /** |
||
106 | * Creates the minfier object. |
||
107 | * |
||
108 | * @param SplFileInfo $file The original source file. |
||
109 | * @param string $source The source code to minify. |
||
110 | * @return Minifier A minifier for the given destination type. |
||
111 | */ |
||
112 | protected function getMinifier(SplFileInfo $file, string $source): Minifier |
||
128 | |||
129 | /** |
||
130 | * Based on if we are in debug mode and if the file is already minfied or |
||
131 | * not, this tells us if we actually need to perform any minification. |
||
132 | * |
||
133 | * @param SplFileInfo $file The original source file. |
||
134 | * @return bool If true we will run the minifier. |
||
135 | */ |
||
136 | protected function doWeNeedToMinify(SplFileInfo $file): bool |
||
144 | } |
||
145 |