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 ( 0706c3...88199a )
by Freek
11:26 queued 06:58
created

ManipulationSets   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 59
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addManipulation() 0 14 2
A merge() 0 4 1
A startNewSet() 0 6 1
A toArray() 0 4 1
A getSets() 0 4 1
A getIterator() 0 4 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 getIterator(): ArrayIterator
63
    {
64
        return new ArrayIterator($this->manipulationSets);
65
    }
66
}