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 ( 9a7896...ad3765 )
by Freek
02:05
created

ManipulationSets::removeManipulation()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
namespace Spatie\Image;
4
5
use ArrayIterator;
6
use IteratorAggregate;
7
8
class ManipulationSets implements IteratorAggregate
9
{
10
    /** @var array */
11
    protected $manipulationSets = [];
12
13
    /** @var bool  */
14
    protected $openNewSet = true;
15
16
    /**
17
     * @param string $operation
18
     * @param string $argument
19
     *
20
     * @return static
21
     */
22
    public function addManipulation(string $operation, string $argument)
23
    {
24
        if ($this->openNewSet) {
25
            $this->manipulationSets[] = [];
26
        }
27
28
        $lastIndex = count($this->manipulationSets) - 1;
29
30
        $this->manipulationSets[$lastIndex][$operation] = $argument;
31
32
        $this->openNewSet = false;
33
34
        return $this;
35
    }
36
37
    public function merge(ManipulationSets $manipulationSets)
38
    {
39
        $this->manipulationSets = array_merge($manipulationSets->toArray());
40
    }
41
42
    /**
43
     * @return static
44
     */
45
    public function startNewSet()
46
    {
47
        $this->openNewSet = true;
48
49
        return $this;
50
    }
51
52
    public function toArray(): array
53
    {
54
        return $this->manipulationSets;
55
    }
56
57
    public function getSets(): array
58
    {
59
        return $this->manipulationSets;
60
    }
61
62
    public function removeManipulation(string $name)
63
    {
64
        foreach($this->manipulationSets as $manipulationSet) {
65
            if (array_key_exists($name, $manipulationSet)) {
66
                unset($manipulationSet[$name]);
67
            }
68
        }
69
70
        return $this;
71
    }
72
73
    public function getIterator(): ArrayIterator
74
    {
75
        return new ArrayIterator($this->manipulationSets);
76
    }
77
}