IntersectionTrait   A
last analyzed

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 7
cts 7
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
 * @copyright Zicht Online <http://zicht.nl>
4
 */
5
6
namespace Zicht\Itertools\lib\Traits;
7
8
use Zicht\Itertools\conversions;
9
use Zicht\Itertools\lib\IntersectionIterator;
10
11 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...
12
{
13
    /**
14
     * Returns an IntersectionIterator containing elements in $this that are also in $iterable
15
     *
16
     * @param array|string|\Iterator $iterable
17
     * @param null|string|\Closure $strategy Optional
18
     * @return null|IntersectionIterator
19
     */
20 10
    public function intersection($iterable, $strategy = null)
21
    {
22 10
        if ($this instanceof \Iterator) {
23 9
            return new IntersectionIterator(
24 9
                $this,
25 9
                conversions\mixed_to_iterator($iterable),
0 ignored issues
show
Deprecated Code introduced by
The function Zicht\Itertools\conversions\mixed_to_iterator() has been deprecated with message: Use \Zicht\Itertools\util\Conversions::mixedToIterator, will be removed in version 3.0

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
26 9
                conversions\mixed_to_value_getter($strategy)
0 ignored issues
show
Deprecated Code introduced by
The function Zicht\Itertools\conversi...mixed_to_value_getter() has been deprecated with message: Use \Zicht\Itertools\util\Conversions::mixedToClosure, will be removed in version 3.0

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
27
            );
28
        }
29
30 1
        return null;
31
    }
32
}
33