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   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A useImageDriver() 0 4 1
A manipulate() 0 12 3
A __call() 0 10 2
A save() 0 11 2
A load() 0 4 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