Passed
Push — master ( 9e9b54...8c04f5 )
by
unknown
38s
created

MapByIterator::key()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 4
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
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 MapByIterator
14
 *
15
 * @package Zicht\Itertools\lib
16
 */
17 View Code Duplication
class MapByIterator extends \IteratorIterator implements FiniteIterableInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
18
{
19
    use FiniteIterableTrait;
20
21
    /**
22
     * @var callable
23
     */
24
    private $func;
25
26
    /**
27
     * MapByIterator constructor.
28
     *
29
     * @param \Closure $func
30
     * @param \Iterator $iterable
31
     */
32 22
    public function __construct(\Closure $func, \Iterator $iterable)
33
    {
34 22
        parent::__construct($iterable);
35 22
        $this->func = $func;
36 22
    }
37
38
    /**
39
     * @{inheritDoc}
40
     */
41 20
    public function key()
42
    {
43 20
        return call_user_func($this->func, $this->current(), parent::key());
44
    }
45
}
46