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

ZipIterator   B

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 18

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 2
Metric Value
c 4
b 0
f 2
dl 0
loc 54
ccs 18
cts 18
cp 1
rs 7.3333
wmc 6
lcom 1
cbo 18

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rewind() 0 5 1
A key() 0 4 1
A next() 0 5 1
A __construct() 0 11 3
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