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.

RepeatIterator   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 54
rs 10
c 0
b 0
f 0
ccs 25
cts 25
cp 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A count() 0 7 2
A getIterationCount() 0 4 1
A getCurrentIteration() 0 4 1
A rewind() 0 5 1
A next() 0 8 2
A valid() 0 4 2
1
<?php
2
3
namespace Gielfeldt\Iterators;
4
5
class RepeatIterator extends TraversableIterator implements \Countable
6
{
7
    protected $count;
8
    protected $currentIteration = 0;
9
    protected $innerCount;
10
11 7
    public function __construct(\Traversable $iterator, int $count)
12
    {
13 7
        if ($count < 0) {
14 1
            throw new \InvalidArgumentException('Count cannot be less than 0.');
15
        }
16
17 6
        $this->count = $count;
18 6
        parent::__construct($iterator);
19 6
    }
20
21 2
    public function count()
22
    {
23 2
        if (!isset($this->innerCount)) {
24 2
            $this->innerCount = count(new CountableIterator($this->getInnerIterator()));
25
        }
26 2
        return $this->innerCount * $this->count;
27
    }
28
29 1
    public function getIterationCount()
30
    {
31 1
        return $this->count;
32
    }
33
34 1
    public function getCurrentIteration()
35
    {
36 1
        return $this->currentIteration;
37
    }
38
39 5
    public function rewind()
40
    {
41 5
        $this->currentIteration = 0;
42 5
        return parent::rewind();
43
    }
44
45 3
    public function next()
46
    {
47 3
        parent::next();
48 3
        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 1
            $this->currentIteration++;
50 1
            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 3
    }
53
54 3
    public function valid()
55
    {
56 3
        return $this->currentIteration < $this->count && parent::valid();
57
    }
58
}
59