Passed
Push — master ( 8c04f5...80d259 )
by
unknown
04:51 queued 32s
created

IntersectionTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A intersection() 12 12 2

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
 * @author Boudewijn Schoon <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Itertools\lib\Traits;
8
9
use Zicht\Itertools\conversions;
10
use Zicht\Itertools\lib\IntersectionIterator;
11
12 View Code Duplication
trait IntersectionTrait
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...
13
{
14
    /**
15
     * Returns an IntersectionIterator containing elements in $this that are also in $iterable
16
     *
17
     * @param array|string|\Iterator $iterable
18
     * @param null|string|\Closure $strategy Optional
19
     * @return null|IntersectionIterator
20
     */
21 10
    public function intersection($iterable, $strategy = null)
22
    {
23 10
        if ($this instanceof \Iterator) {
24 9
            return new IntersectionIterator(
25
                $this,
26
                conversions\mixed_to_iterator($iterable),
27
                conversions\mixed_to_value_getter($strategy)
28
            );
29
        }
30
31 1
        return null;
32
    }
33
}
34