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.

Collection::rewind()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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