MapByIterator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A key() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @copyright Zicht Online <http://zicht.nl>
4
 */
5
6
namespace Zicht\Itertools\lib;
7
8
use Zicht\Itertools\lib\Interfaces\FiniteIterableInterface;
9
use Zicht\Itertools\lib\Traits\FiniteIterableTrait;
10
11 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...
12
{
13
    use FiniteIterableTrait;
14
15
    /**
16
     * @var callable
17
     */
18
    private $func;
19
20
    /**
21
     * @param \Closure $func
22
     * @param \Iterator $iterable
23
     */
24 22
    public function __construct(\Closure $func, \Iterator $iterable)
25
    {
26 22
        parent::__construct($iterable);
27 22
        $this->func = $func;
28 22
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33 20
    public function key()
34
    {
35 20
        return call_user_func($this->func, $this->current(), parent::key());
36
    }
37
}
38