Passed
Push — fix/serve-timeout ( 697f77...233bc8 )
by Arnaud
04:27
created

Cwebp::canHandle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cecil\Assets\Image\Optimizers;
6
7
use Spatie\ImageOptimizer\Image;
8
use Spatie\ImageOptimizer\Optimizers\BaseOptimizer;
9
10
class Cwebp extends BaseOptimizer
11
{
12
    public $binaryName = 'cwebp';
13
14
    public function canHandle(Image $image): bool
15
    {
16
        return $image->mime() === 'image/webp';
17
    }
18
19
    public function getCommand(): string
20
    {
21
        $optionString = implode(' ', $this->options);
22
23
        return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}"
24
            .' '.escapeshellarg($this->imagePath)
25
            .' -o '.escapeshellarg($this->imagePath);
26
    }
27
}
28