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 ( fc5653...e1c659 )
by Thomas
23:54
created

RepeatIterator::valid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace Gielfeldt\Iterators;
4
5
class RepeatIterator extends IteratorIterator implements \Countable
6
{
7
    protected $count;
8
    protected $currentIteration = 0;
9
    protected $innerCount;
10
11
    public function __construct(\Traversable $iterator, int $count)
12
    {
13
        if ($count < 0) {
14
            throw new \InvalidArgumentException('Count cannot be less than 0.');
15
        }
16
17
        $this->count = $count;
18
        parent::__construct($iterator);
19
    }
20
21
    public function count()
22
    {
23
        if (!isset($this->innerCount)) {
24
            $this->innerCount = count(new CountableIterator($this->getInnerIterator()));
25
        }
26
        return $this->innerCount * $this->count;
27
    }
28
29
    public function getIterationCount()
30
    {
31
        return $this->count;
32
    }
33
34
    public function getCurrentIteration()
35
    {
36
        return $this->currentIteration;
37
    }
38
39
    public function rewind()
40
    {
41
        $this->currentIteration = 0;
42
        return parent::rewind();
43
    }
44
45
    public function next()
46
    {
47
        parent::next();
48
        if (!parent::valid()) {
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...
49
            $this->currentIteration++;
50
            parent::rewind();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (rewind() instead of next()). Are you sure this is correct? If so, you might want to change this to $this->rewind().

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...
51
        }
52
    }
53
54
    public function valid()
55
    {
56
        return $this->currentIteration < $this->count && parent::valid();
57
    }
58
}
59