1 | <?php |
||
11 | class Minify |
||
12 | { |
||
13 | /** |
||
14 | * Cache bust file path |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $strCacheBustFile; |
||
19 | |||
20 | /** |
||
21 | * Public folder path |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $strPublicFolderPath; |
||
26 | |||
27 | /** |
||
28 | * File types supported |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $arrFileTypes; |
||
33 | |||
34 | /** |
||
35 | * Destination file extension |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $strDestinationExtension; |
||
40 | |||
41 | /** |
||
42 | * Destination folder |
||
43 | * |
||
44 | * @var |
||
45 | */ |
||
46 | protected $strDestinationFolder; |
||
47 | |||
48 | /** |
||
49 | * Destination file |
||
50 | * |
||
51 | * @var |
||
52 | */ |
||
53 | protected $strDestinationFile; |
||
54 | |||
55 | /** |
||
56 | * Set env to dev |
||
57 | * |
||
58 | * @var |
||
59 | */ |
||
60 | protected $blnIsDev; |
||
61 | |||
62 | /** |
||
63 | * Create a new Minifier Instance |
||
64 | * |
||
65 | * Minify constructor. |
||
66 | */ |
||
67 | public function __construct() |
||
75 | |||
76 | |||
77 | /** |
||
78 | * Set Class Variables |
||
79 | * |
||
80 | * @return null |
||
81 | */ |
||
82 | public function init() |
||
95 | |||
96 | /** |
||
97 | * Set env to Dev |
||
98 | * |
||
99 | * @param bool $bln |
||
100 | * @return $this |
||
101 | */ |
||
102 | public function setDev($bln = true) |
||
108 | |||
109 | /** |
||
110 | * Set Cache bust file |
||
111 | * |
||
112 | * @param string $strFile |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function setCacheBustFile($strFile = 'autominifier-cache-bust.txt') |
||
120 | |||
121 | /** |
||
122 | * Set public folder |
||
123 | * |
||
124 | * @param string $strFolder |
||
125 | * @return $this |
||
126 | */ |
||
127 | public function setPublicFolder($strFolder = '/../../../../public') |
||
133 | |||
134 | /** |
||
135 | * Set test folder |
||
136 | * |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function setTest() |
||
149 | |||
150 | /** |
||
151 | * Get Public folder |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | public function getPublicFolder() |
||
159 | |||
160 | /** |
||
161 | * Build minified file |
||
162 | * |
||
163 | * @var $strFolder string |
||
164 | * @var $strFile string |
||
165 | * @return string |
||
166 | */ |
||
167 | public function js($strFolder = '/js', $strFile = 'app.min.js') |
||
171 | |||
172 | /** |
||
173 | * Build CSS minified file |
||
174 | * |
||
175 | * @var $strFolder string |
||
176 | * @var $strFile string |
||
177 | * @return bool|null|string |
||
178 | */ |
||
179 | public function css($strFolder = '/css', $strFile = 'app.min.css') |
||
183 | |||
184 | /** |
||
185 | * Generate minified file |
||
186 | * |
||
187 | * @param string $strType |
||
188 | * @param string $strFolder |
||
189 | * @param string $strFile |
||
190 | * @return string |
||
191 | */ |
||
192 | public function getMinifiedFile($strType = 'css', $strFolder = '/css', $strFile = 'app.min.css') |
||
200 | |||
201 | /** |
||
202 | * Process Built |
||
203 | * |
||
204 | * @return bool|null|string |
||
205 | */ |
||
206 | public function process() |
||
222 | |||
223 | /** |
||
224 | * Set destination folder |
||
225 | * |
||
226 | * @param $strFolder |
||
227 | * @return $this |
||
228 | */ |
||
229 | public function setDestinationFolder($strFolder) |
||
234 | |||
235 | /** |
||
236 | * Set destination file |
||
237 | * |
||
238 | * @param $strFile |
||
239 | * @return $this |
||
240 | */ |
||
241 | public function setDestinationFile($strFile) |
||
246 | |||
247 | /** |
||
248 | * Get destination folder |
||
249 | * |
||
250 | * @return mixed |
||
251 | */ |
||
252 | public function getDestinationFolder() |
||
256 | |||
257 | /** |
||
258 | * Set destination file |
||
259 | * |
||
260 | * @return mixed |
||
261 | */ |
||
262 | public function getDestinationFile() |
||
266 | |||
267 | /** |
||
268 | * Save Cache Bust |
||
269 | * |
||
270 | * @var string $strApplicationFileContents |
||
271 | * @return null |
||
272 | */ |
||
273 | public function saveCacheBust($strApplicationFileContents = '') |
||
292 | |||
293 | /** |
||
294 | * Get Cache Bust |
||
295 | * |
||
296 | * @return bool|string |
||
297 | */ |
||
298 | public function getCacheBust() |
||
308 | |||
309 | /** |
||
310 | * Create minified and concatenated file |
||
311 | * |
||
312 | * @param $strApplicationFileContents |
||
313 | * @return string |
||
314 | */ |
||
315 | public function createApplicationFile($strApplicationFileContents) |
||
320 | |||
321 | /** |
||
322 | * Get application file name |
||
323 | * |
||
324 | * @return string |
||
325 | */ |
||
326 | public function getAppFileName() |
||
330 | |||
331 | /** |
||
332 | * Set destination file extension |
||
333 | * |
||
334 | * @param $strDestinationExtension |
||
335 | */ |
||
336 | public function setDestinationExtensionType($strDestinationExtension) |
||
340 | |||
341 | /** |
||
342 | * Get destination file type extension |
||
343 | * |
||
344 | * @return mixed |
||
345 | */ |
||
346 | public function getDestinationExtension() |
||
350 | |||
351 | /** |
||
352 | * Build file |
||
353 | * |
||
354 | * @param $arrOriginExtensions |
||
355 | * @return string |
||
356 | */ |
||
357 | public function build($arrOriginExtensions) |
||
396 | |||
397 | /** |
||
398 | * Get minified Content |
||
399 | * |
||
400 | * @param $strFile |
||
401 | * @return bool|string |
||
402 | */ |
||
403 | public function getMinifiedContent($strFile) |
||
413 | |||
414 | /** |
||
415 | * Minify content |
||
416 | * |
||
417 | * @param $strFile |
||
418 | * @return bool|string |
||
419 | */ |
||
420 | public function minifyContent($strFile) |
||
432 | |||
433 | /** |
||
434 | * Minify JS |
||
435 | * |
||
436 | * @param $strFile |
||
437 | * @return bool|string |
||
438 | */ |
||
439 | public function minifyJs($strFile) |
||
443 | |||
444 | /** |
||
445 | * Minify CSS |
||
446 | * |
||
447 | * @param $strFile |
||
448 | * @return bool|string |
||
449 | */ |
||
450 | public function minifyCss($strFile) |
||
454 | } |
||
455 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: