Passed
Pull Request — master (#28)
by
unknown
02:45
created

DifferenceTrait::difference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 8
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
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\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