Passed
Push — fix/serve-timeout ( 697f77...233bc8 )
by Arnaud
04:27
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
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