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

InfiniteIterator   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A getCurrentIteration() 0 4 1
A rewind() 0 5 1
A next() 0 5 1
A valid() 0 9 3
1
<?php
2
3
namespace Gielfeldt\Iterators;
4
5
class InfiniteIterator extends IteratorIterator
6
{
7
    public function __construct(\Traversable $iterator, callable $endCondition = null)
8
    {
9
        $this->endCondition = $endCondition ? \Closure::fromCallable($endCondition) : null;
0 ignored issues
show
Bug introduced by
The property endCondition does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
10
        parent::__construct($iterator);
11
    }
12
13
    public function getCurrentIteration()
14
    {
15
        return $this->currentIteration;
0 ignored issues
show
Bug introduced by
The property currentIteration does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
    }
17
18
    public function rewind()
19
    {
20
        $this->currentIteration = 0;
21
        parent::rewind();
22
    }
23
24
    public function next()
25
    {
26
        parent::next();
27
        #if (!parent::valid())
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
    }
29
30
    public function valid()
31
    {
32
        if (!parent::valid()) {
33
            parent::rewind();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (rewind() instead of valid()). 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...
34
            $this->currentIteration++;
35
        }
36
37
        return $this->endCondition ? !($this->endCondition)($this) : parent::valid();
38
    }
39
40
}
41