Total Complexity | 7 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 88.24% |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
22 | class Html extends AbstractOptimize |
||
23 | { |
||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 1 | public function getName(): string |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | 1 | public function init(array $options): void |
|
36 | { |
||
37 | 1 | $this->type = 'html'; |
|
38 | // https://github.com/voku/HtmlMin/issues/93 |
||
39 | 1 | if (version_compare(PHP_VERSION, '8.3.0', '>=')) { |
|
40 | $this->builder->getLogger()->debug("{$this->getName()} is disabled for PHP 8.3"); |
||
41 | |||
42 | return; |
||
43 | } |
||
44 | 1 | parent::init($options); |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | 1 | public function setProcessor(): void |
|
51 | { |
||
52 | 1 | $this->processor = new HtmlMin(); |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | 1 | public function processFile(\Symfony\Component\Finder\SplFileInfo $file): string |
|
59 | { |
||
60 | 1 | $html = Util\File::fileGetContents($file->getPathname()); |
|
61 | |||
62 | 1 | return $this->processor->minify($html); |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | 1 | public function encode(string $content = null): ?string |
|
69 | { |
||
70 | 1 | return json_encode($content); |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 1 | public function decode(string $content = null): ?string |
|
79 | } |
||
80 | } |
||
81 |