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 ( 0c8b13...b1ee3a )
by Thomas
02:04
created

IndexIterator::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Gielfeldt\Iterators;
4
5
class IndexIterator extends TraversableIterator implements \Countable
6
{
7
    private $indexingIterator;
8
    private $valid;
9
    private $count;
0 ignored issues
show
Unused Code introduced by
The property $count is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10 3
11
    public function __construct(\Traversable $iterator, iterable $indexes)
12 3
    {
13 3
        if ($indexes instanceof \Traversable) {
14 3
            $indexes = iterator_to_array(new \IteratorIterator($indexes), false);
15
        }
16 3
        sort($indexes);
17
        $this->indexingIterator = new \ArrayIterator($indexes);
18 3
19 3
        $iterator = $iterator instanceof \Countable ? $iterator : new CountableIterator($iterator, CountableIterator::CACHE_COUNT);
20 3
        parent::__construct($iterator);
21 3
    }
22
23 3
    public function count()
24
    {
25 3
        return min(count($this->getInnerIterator()), count($this->indexingIterator));
26 3
    }
27 3
28 3
    public function rewind()
29
    {
30 3
        parent::rewind();
31 3
        $this->indexingIterator->rewind();
32
        $this->next();
33 3
    }
34
35 3
    public function next()
36
    {
37
        $this->valid = $this->indexingIterator->valid();
38
        $index = $this->indexingIterator->current();
39
        while (parent::valid() && $this->getIndex() < $index) {
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (valid() instead of next()). Are you sure this is correct? If so, you might want to change this to $this->valid().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
40
            parent::next();
41
        }
42
        $this->indexingIterator->next();
43
    }
44
45
    public function valid()
46
    {
47
        return $this->valid && parent::valid();
48
    }
49
}
50