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   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 4 1
A getCommand() 0 9 1
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