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

Cwebp::getCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
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 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