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.

InterleaveIterator::key()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Gielfeldt\Iterators;
4
5
class InterleaveIterator implements \Iterator
6
{
7
    protected $realIterators;
8
    protected $iterators;
9
10 1
    public function __construct(\Traversable ...$iterators)
11
    {
12 1
        $this->realIterators = new \ArrayIterator($iterators);
13 1
        foreach ($iterators as $iterator) {
14 1
            $this->appendIterator($iterator);
15
        }
16 1
        $this->iterators = new \InfiniteIterator($this->realIterators);
17 1
    }
18
19 1
    public function appendIterator(\Traversable $iterator)
20
    {
21 1
        $this->realIterators->append($iterator instanceof \Iterator ? $iterator : new \IteratorIterator($iterator));
22 1
    }
23
24 1
    public function rewind()
25
    {
26 1
        foreach ($this->realIterators as $iterator) {
27 1
            $iterator->rewind();
28
        }
29 1
        $this->iterators->rewind();
30 1
    }
31
32 1
    public function valid()
33
    {
34 1
        $count = count($this->realIterators);
35 1
        while ($count-- >= 0) {
36 1
            if ($this->iterators->current()->valid()) {
37 1
                return true;
38
            }
39 1
            $this->next();
40
        }
41 1
        return false;
42
    }
43
44 1
    public function key()
45
    {
46 1
        return $this->iterators->current()->key();
47
    }
48
49 1
    public function current()
50
    {
51 1
        return $this->iterators->current()->current();
52
    }
53
54 1
    public function next()
55
    {
56 1
        if ($this->iterators->current()->valid()) {
57 1
            $this->iterators->current()->next();
58
        }
59 1
        $this->iterators->next();
60 1
    }
61
}
62