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
Push — master ( b8da23...bdd910 )
by Freek
01:44
created

Image::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Spatie\Image;
4
5
use Exception;
6
7
/** @mixin \Spatie\Image\Manipulations */
8
class Image
9
{
10
    /** @var string */
11
    protected $pathToImage;
12
13
    /** @var \Spatie\Image\Manipulations */
14
    protected $manipulations;
15
16
    /** @var */
17
    protected $imageDriver = 'gd';
18
19
    public static function load($pathToImage)
20
    {
21
        return new static($pathToImage);
22
    }
23
24
    public function __construct(string $pathToImage)
25
    {
26
        $this->pathToImage = $pathToImage;
27
28
        $this->manipulations = new Manipulations();
0 ignored issues
show
Bug introduced by
The call to Manipulations::__construct() misses a required argument $manipulations.

This check looks for function calls that miss required arguments.

Loading history...
29
    }
30
31
    public function useImageDriver($imageDriver)
32
    {
33
        $this->imageDriver = $imageDriver;
34
    }
35
36
    public function manipulate($manipulations)
37
    {
38
        if (is_callable($manipulations)) {
39
            $manipulations($this->manipulations);
40
        }
41
42
        if ($manipulations instanceof Manipulations) {
43
            $this->manipulations->mergeManipulations($manipulations);
44
        }
45
46
        return $this;
47
    }
48
49
    public function __call($name, $arguments)
50
    {
51
        if (! method_exists($this->manipulations, $name)) {
52
            throw new Exception("Manipulation `{$name}` does not exist");
53
        }
54
55
        $this->manipulations->$name(...$arguments);
56
57
        return $this;
58
    }
59
60
    public function save($outputPath = '')
61
    {
62
        if ($outputPath == '') {
63
            $outputPath = $this->pathToImage;
64
        }
65
66
        GlideManipulator::create($this->pathToImage)
67
            ->useImageDriver($this->imageDriver)
68
            ->performManipulations($this->manipulations)
69
            ->save($outputPath);
70
    }
71
}
72