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   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 0
dl 0
loc 57
ccs 30
cts 30
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A appendIterator() 0 4 2
A rewind() 0 7 2
A valid() 0 11 3
A key() 0 4 1
A current() 0 4 1
A next() 0 7 2
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