Completed
Push — feat/optimize-webp ( b9a7aa...68b340 )
by Arnaud
09:41 queued 09:41
created

Cwebp   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 3 1
A getCommand() 0 7 1
1
<?php
2
3
namespace Cecil\Assets\Image\Optimizers;
4
5
use Spatie\ImageOptimizer\Image;
6
use Spatie\ImageOptimizer\Optimizers\BaseOptimizer;
7
8
class Cwebp extends BaseOptimizer
9
{
10
    public $binaryName = 'cwebp';
11
12
    public function canHandle(Image $image): bool
13
    {
14
        return $image->mime() === 'image/webp';
15
    }
16
17
    public function getCommand(): string
18
    {
19
        $optionString = implode(' ', $this->options);
20
21
        return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}"
22
            .' '.escapeshellarg($this->imagePath)
23
            .' -o '.escapeshellarg($this->imagePath);
24
    }
25
}
26