Total Complexity | 7 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
21 | class Images extends AbstractOptimize |
||
22 | { |
||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | public function getName(): string |
||
27 | { |
||
28 | return 'Optimizing images'; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function init(array $options): void |
||
35 | { |
||
36 | $this->type = 'images'; |
||
37 | parent::init($options); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | public function setProcessor(): void |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function processFile(\Symfony\Component\Finder\SplFileInfo $file): string |
||
52 | { |
||
53 | try { |
||
54 | $this->processor->optimize($file->getPathname()); |
||
55 | } catch (\Exception $e) { |
||
56 | $this->builder->getLogger()->error(sprintf('Can\'t optimize image "%s": "%s"', $file->getPathname(), $e->getMessage())); |
||
57 | } |
||
58 | |||
59 | return $file->getContents(); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | public function encode(string $content = null): ?string |
||
66 | { |
||
67 | return base64_encode((string) $content); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function decode(string $content = null): ?string |
||
76 | } |
||
77 | } |
||
78 |