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.

DiffIterator::diffCurrent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Gielfeldt\Iterators;
4
5
class DiffIterator extends \FilterIterator
6
{
7
    protected $iterators;
8
    protected $callback;
9
10 6
    public function __construct(\Traversable ...$iterators)
11
    {
12 6
        $innerIterator = array_shift($iterators);
13 6
        parent::__construct($innerIterator);
14 6
        foreach ($iterators as $iterator) {
15 6
            $this->iterators[] = new CachingIterator($iterator);
16
        }
17 6
        $this->callback = \Closure::fromCallable([static::class, 'diffCurrent']);
18 6
    }
19
20 4
    public function setDiff(callable $callback)
21
    {
22 4
        $this->callback = \Closure::fromCallable($callback);
23 4
    }
24
25 3
    public function accept()
26
    {
27 3 View Code Duplication
        foreach ($this->iterators as $iterator) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28 3
            foreach ($iterator as $key => $value) {
29 3
                if (($this->callback)($this->getInnerIterator(), $key, $value)) {
30 3
                    return false;
31
                }
32
            }
33
        }
34 3
        return true;
35
    }
36
37 2
    public static function diffCurrent($iterator, $key, $value)
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39 2
        return $iterator->current() == $value;
40
    }
41
42 2
    public static function diffKey($iterator, $key, $value)
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    {
44 2
        return $iterator->key() == $key;
45
    }
46
}
47