Passed
Push — feat/markdown-highlighter ( 1efac5...98434c )
by Arnaud
13:07 queued 08:45
created

Cwebp   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 16
ccs 7
cts 7
cp 1
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 1
    public function canHandle(Image $image): bool
15
    {
16 1
        return $image->mime() === 'image/webp';
17
    }
18
19 1
    public function getCommand(): string
20
    {
21 1
        $optionString = implode(' ', $this->options);
22
23 1
        return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString}"
24 1
            .' '.escapeshellarg($this->imagePath)
25 1
            .' -o '.escapeshellarg($this->imagePath);
26
    }
27
}
28