MapIterator::rewind()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Finalizer\Iterator;
4
5
final class MapIterator implements \Iterator
6
{
7
    /**
8
     * @var \Iterator
9
     */
10
    private $wrappedIterator;
11
12
    /**
13
     * @var callable
14
     */
15
    private $map;
16
17
    /**
18
     * @param \Iterator $wrappedIterator
19
     * @param callable  $map
20
     */
21 5
    public function __construct(\Iterator $wrappedIterator, callable $map)
22
    {
23 5
        $this->wrappedIterator = $wrappedIterator;
24 5
        $this->map             = $map;
25 5
    }
26
27
    /**
28
     * {@inheritDoc}
29
     */
30 1
    public function current()
31
    {
32 1
        $map = $this->map;
33
34 1
        return $map($this->wrappedIterator->current());
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 1
    public function next()
41
    {
42 1
        $this->wrappedIterator->next();
43 1
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 1
    public function key()
49
    {
50 1
        return $this->wrappedIterator->key();
51
    }
52
53
    /**
54
     * {@inheritDoc}
55
     */
56 1
    public function valid()
57
    {
58 1
        return $this->wrappedIterator->valid();
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64 1
    public function rewind()
65
    {
66 1
        $this->wrappedIterator->rewind();
67 1
    }
68
}
69