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.

BaseOptimizer::binaryName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\ImageOptimizer\Optimizers;
4
5
use Spatie\ImageOptimizer\Optimizer;
6
7
abstract class BaseOptimizer implements Optimizer
8
{
9
    public $options = [];
10
11
    public $imagePath = '';
12
13
    public $binaryPath = '';
14
15
    public function __construct($options = [])
16
    {
17
        $this->setOptions($options);
18
    }
19
20
    public function binaryName(): string
21
    {
22
        return $this->binaryName;
0 ignored issues
show
Bug introduced by
The property binaryName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23
    }
24
25
    public function setBinaryPath(string $binaryPath)
26
    {
27
        if (substr($binaryPath, -1) !== DIRECTORY_SEPARATOR) {
28
            $binaryPath = $binaryPath.DIRECTORY_SEPARATOR;
29
        }
30
31
        $this->binaryPath = $binaryPath;
32
33
        return $this;
34
    }
35
36
    public function setImagePath(string $imagePath)
37
    {
38
        $this->imagePath = $imagePath;
39
40
        return $this;
41
    }
42
43
    public function setOptions(array $options = [])
44
    {
45
        $this->options = $options;
46
47
        return $this;
48
    }
49
50
    public function getCommand(): string
51
    {
52
        $optionString = implode(' ', $this->options);
53
54
        return "\"{$this->binaryPath}{$this->binaryName}\" {$optionString} ".escapeshellarg($this->imagePath);
55
    }
56
}
57