Passed
Pull Request — master (#19)
by
unknown
02:33
created

ZipIterator::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 6
Ratio 54.55 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 0
dl 6
loc 11
ccs 8
cts 8
cp 1
crap 3
rs 9.4285
c 0
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 View Code Duplication
        foreach (func_get_args() as $iterable) {
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...
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