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