Passed
Pull Request — master (#19)
by
unknown
03:59
created

ZipIterator::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace Zicht\Itertools\lib;
4
5
use Zicht\Itertools\lib\Traits\AllTrait;
6
use Zicht\Itertools\lib\Traits\AnyTrait;
7
use Zicht\Itertools\lib\Traits\ChainTrait;
8
use Zicht\Itertools\lib\Traits\CountableTrait;
9
use Zicht\Itertools\lib\Traits\CycleTrait;
10
use Zicht\Itertools\lib\Traits\DebugInfoTrait;
11
use Zicht\Itertools\lib\Traits\FilterTrait;
12
use Zicht\Itertools\lib\Traits\FirstTrait;
13
use Zicht\Itertools\lib\Traits\GroupByTrait;
14
use Zicht\Itertools\lib\Traits\LastTrait;
15
use Zicht\Itertools\lib\Traits\MapByTrait;
16
use Zicht\Itertools\lib\Traits\MapTrait;
17
use Zicht\Itertools\lib\Traits\ReduceTrait;
18
use Zicht\Itertools\lib\Traits\ReversedTrait;
19
use Zicht\Itertools\lib\Traits\SliceTrait;
20
use Zicht\Itertools\lib\Traits\SortedTrait;
21
use Zicht\Itertools\lib\Traits\UniqueTrait;
22
use Zicht\Itertools\lib\Traits\ZipTrait;
23
24
class ZipIterator extends \MultipleIterator implements \Countable
25
{
26
    use CountableTrait;
27
    use DebugInfoTrait;
28
29
    // Fluent interface traits
30
    use AllTrait;
31
    use AnyTrait;
32
    use ChainTrait;
33
    use CycleTrait;
34
    use FilterTrait;
35
    use FirstTrait;
36
    use GroupByTrait;
37
    use LastTrait;
38
    use MapByTrait;
39
    use MapTrait;
40
    use ReduceTrait;
41
    use ReversedTrait;
42
    use SliceTrait;
43
    use SortedTrait;
44
    use UniqueTrait;
45
    use ZipTrait;
46
47
    private $key;
48
49 12
    public function __construct(/* \Iterator $iterable1, \Iterator $iterable2, ... */)
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% 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...
50
    {
51 12
        parent::__construct(\MultipleIterator::MIT_NEED_ALL| \MultipleIterator::MIT_KEYS_NUMERIC);
52 12
        foreach (func_get_args() as $iterable) {
53 12
            if (!$iterable instanceof \Iterator) {
54 3
                throw new \InvalidArgumentException(sprintf('Not all arguments are iterators'));
55
            }
56 9
            $this->attachIterator($iterable);
57
        }
58 9
        $this->key = 0;
59 9
    }
60
61 8
    public function rewind()
62
    {
63 8
        parent::rewind();
64 8
        $this->key = 0;
65 8
    }
66
67 4
    public function key()
68
    {
69 4
        return $this->key;
70
    }
71
72 4
    public function next()
73
    {
74 4
        parent::next();
75 4
        $this->key += 1;
76 4
    }
77
}
78