GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#23)
by Maximilian
01:16
created

Mozjpeg::getCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Spatie\ImageOptimizer\Optimizers;
4
5
use Spatie\ImageOptimizer\Image;
6
7
class Mozjpeg extends BaseOptimizer
8
{
9
    public $binaryName = 'mozjpeg';
10
11
    public function canHandle(Image $image): bool
12
    {
13
        return $image->mime() === 'image/jpeg';
14
    }
15
16
    public function getCommand(): string
17
    {
18
        $optionString = implode(' ', $this->options);
19
        // Directly overwriting of file is not possible, so do a mv after compression
20
        return "{$this->binaryName} {$optionString}"
21
            .' -outfile '.escapeshellarg($this->imagePath.'optimized.jpg')
22
            .' '.escapeshellarg($this->imagePath).' && mv '.escapeshellarg($this->imagePath.'optimized.jpg')
23
            .' '.escapeshellarg($this->imagePath);
24
    }
25
}
26