LazyZipIterator::key()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Collections\Iterator;
4
5
use Collections\Pair;
6
7
class LazyZipIterator implements \Iterator
8
{
9
    /**
10
     * @var \Iterator
11
     */
12
    private $it1;
13
14
    /**
15
     * @var \Iterator
16
     */
17
    private $it2;
18
19
    public function __construct($it1, $it2)
20
    {
21
        $this->it1 = $it1;
22
        $this->it2 = $it2;
23
    }
24
25
    public function __clone()
26
    {
27
        $this->it1 = clone $this->it1;
28
        $this->it2 = clone $this->it2;
29
    }
30
31
    public function rewind()
32
    {
33
        $this->it1->rewind();
34
        $this->it2->rewind();
35
    }
36
37
    public function valid()
38
    {
39
        return ($this->it1->valid() && $this->it2->valid());
40
    }
41
42
    public function next()
43
    {
44
        $this->it1->next();
45
        $this->it2->next();
46
    }
47
48
    public function key()
49
    {
50
        return $this->it1->key();
51
    }
52
53
    public function current()
54
    {
55
        return new Pair($this->it1->current(), $this->it2->current());
56
    }
57
}
58