MapIterator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 64
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

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