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.

TraversableBackedCollection::getIterator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace UCD\Unicode\Collection;
4
5
use UCD\Unicode\Codepoint;
6
use UCD\Unicode\Collection;
7
8
abstract class TraversableBackedCollection implements SnapshotCapableCollection
9
{
10
    /**
11
     * @var \Traversable
12
     */
13
    private $items;
14
15
    /**
16
     * @param \Traversable $items
17
     */
18
    public function __construct(\Traversable $items)
19
    {
20
        $this->items = $items;
21
    }
22
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function filterWith(callable $filter)
27
    {
28
        return new static(
29
            $this->applyFilter($filter)
30
        );
31
    }
32
33
    /**
34
     * @param callable $filter
35
     * @return \Generator
36
     */
37
    private function applyFilter(callable $filter)
38
    {
39
        foreach ($this as $item) {
40
            if (call_user_func($filter, $item) === true) {
41
                yield $item;
42
            }
43
        }
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function traverseWith(callable $callback)
50
    {
51
        foreach ($this as $character) {
52
            call_user_func($callback, $character);
53
        }
54
55
        return $this;
56
    }
57
58
    /**
59
     * {@inheritDoc}
60
     */
61
    public function takeSnapshot()
62
    {
63
        return new static(
64
            new \ArrayIterator($this->toArray())
65
        );
66
    }
67
68
    /**
69
     * {@inheritDoc}
70
     */
71
    public function getIterator()
72
    {
73
        return $this->items;
74
    }
75
76
    /**
77
     * {@inheritDoc}
78
     */
79
    public function count()
80
    {
81
        return iterator_count($this->items);
82
    }
83
84
    /**
85
     * @return array
86
     */
87
    public function toArray()
88
    {
89
        return iterator_to_array($this->items);
90
    }
91
92
    /**
93
     * @param array $items
94
     * @return static
95
     */
96
    public static function fromArray(array $items)
97
    {
98
        return new static(
99
            new \ArrayIterator($items)
100
        );
101
    }
102
}