Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3.3332 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | 2 | public function onImageSave(AssetEvent $event) : bool |
|
40 | { |
||
41 | 2 | if (!in_array($event->getAsset()->getMimetype(), $this->mimeTypes)) { |
|
42 | 1 | return false; |
|
43 | } |
||
44 | |||
45 | try { |
||
46 | 1 | (new TinyPngService())->minimize($event->getAsset()); |
|
47 | 1 | } catch (\Exception $e) { |
|
48 | 1 | (ApplicationLogger::getInstance())->error($e->getMessage(), [ |
|
49 | 'relatedObject' => $event->getAsset(), |
||
50 | 'component' => 'TinyPNG' |
||
51 | ]); |
||
52 | } |
||
53 | |||
54 | return true; |
||
55 | } |
||
57 |