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 ( 067042...4cd6ce )
by Brent
01:11
created

DataTransferObjectCollection::items()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spatie\DataTransferObject;
6
7
use Iterator;
8
use Countable;
9
use ArrayAccess;
10
11
abstract class DataTransferObjectCollection implements
12
    ArrayAccess,
13
    Iterator,
14
    Countable
15
{
16
    /** @var array */
17
    protected $collection;
18
19
    /** @var int */
20
    protected $position = 0;
21
22
    public function __construct(array $collection = [])
23
    {
24
        $this->collection = $collection;
25
    }
26
27
    public function current()
28
    {
29
        return $this->collection[$this->position];
30
    }
31
32
    public function offsetGet($offset)
33
    {
34
        return $this->collection[$offset] ?? null;
35
    }
36
37
    public function offsetSet($offset, $value)
38
    {
39
        if (is_null($offset)) {
40
            $this->collection[] = $value;
41
        } else {
42
            $this->collection[$offset] = $value;
43
        }
44
    }
45
46
    public function offsetExists($offset): bool
47
    {
48
        return array_key_exists($offset, $this->collection);
49
    }
50
51
    public function offsetUnset($offset)
52
    {
53
        unset($this->collection[$offset]);
54
    }
55
56
    public function next()
57
    {
58
        $this->position++;
59
    }
60
61
    public function key(): int
62
    {
63
        return $this->position;
64
    }
65
66
    public function valid(): bool
67
    {
68
        return array_key_exists($this->position, $this->collection);
69
    }
70
71
    public function rewind()
72
    {
73
        $this->position = 0;
74
    }
75
76
    public function toArray(): array
77
    {
78
        $collection = $this->collection;
79
80
        foreach ($collection as $key => $item) {
81
            if (
82
                ! $item instanceof DataTransferObject
83
                && ! $item instanceof DataTransferObjectCollection
84
            ) {
85
                continue;
86
            }
87
88
            $collection[$key] = $item->toArray();
89
        }
90
91
        return $collection;
92
    }
93
94
    public function items(): array
95
    {
96
        return $this->collection;
97
    }
98
99
    public function count(): int
100
    {
101
        return count($this->collection);
102
    }
103
}
104