Passed
Push — master ( 40c774...9e9b54 )
by
unknown
37s
created

DifferenceTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A difference() 0 8 1
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\DifferenceIterator;
11
12
trait DifferenceTrait
13
{
14
    /**
15
     * Returns a DifferenceIterator containing elements in $this but not in $iterable
16
     *
17
     * @param array|string|\Iterator $iterable
18
     * @param null|string|\Closure $strategy Optional, when not specified !empty will be used
19
     * @return DifferenceIterator
20
     */
21 7
    public function difference($iterable, $strategy = null)
22
    {
23 7
        return new DifferenceIterator(
24
            conversions\mixed_to_iterator($this),
25
            conversions\mixed_to_iterator($iterable),
26
            conversions\mixed_to_value_getter($strategy)
27
        );
28
    }
29
}
30