LazyZipKeyedIterator::__clone()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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