Passed
Push — master ( 9e9b54...8c04f5 )
by
unknown
38s
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
 * @author Boudewijn Schoon <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Itertools\lib;
8
9
use Zicht\Itertools\lib\Interfaces\FiniteIterableInterface;
10
use Zicht\Itertools\lib\Traits\FiniteIterableTrait;
11
12
/**
13
 * Class ZipIterator
14
 *
15
 * @package Zicht\Itertools\lib
16
 */
17
class ZipIterator extends \MultipleIterator implements FiniteIterableInterface
18
{
19
    use FiniteIterableTrait;
20
21
    /** @var int */
22
    private $key;
23
24
    /**
25
     * ZipIterator constructor.
26
     */
27 12
    public function __construct()
28
    {
29 12
        parent::__construct(\MultipleIterator::MIT_NEED_ALL | \MultipleIterator::MIT_KEYS_NUMERIC);
30 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...
31 12
            if (!$iterable instanceof \Iterator) {
32 3
                throw new \InvalidArgumentException(sprintf('Not all arguments are iterators'));
33
            }
34 9
            $this->attachIterator($iterable);
35
        }
36 9
        $this->key = 0;
37 9
    }
38
39
    /**
40
     * @{inheritDoc}
41
     */
42 8
    public function rewind()
43
    {
44 8
        parent::rewind();
45 8
        $this->key = 0;
46 8
    }
47
48
    /**
49
     * @{inheritDoc}
50
     */
51 4
    public function key()
52
    {
53 4
        return $this->key;
54
    }
55
56
    /**
57
     * @{inheritDoc}
58
     */
59 4
    public function next()
60
    {
61 4
        parent::next();
62 4
        $this->key += 1;
63 4
    }
64
}
65