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