RejectMutator::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Underscore\Mutator;
4
5
use Underscore\Collection;
6
use Underscore\Mutator;
7
8
class RejectMutator extends Mutator
9
{
10
    /**
11
     * The opposite of filter(). This mutator returns the elements of a collection that the callback
12
     * does **not** return truey for.
13
     *
14
     * @param Collection $collection
15
     * @param callable   $iterator
16
     * @return Collection
17
     */
18 3
    public function __invoke($collection, $iterator)
19
    {
20 3
        $filter = new FilterMutator;
21
22 3
        return $filter($collection, function () use ($iterator) {
23 3
            return !call_user_func_array($iterator, func_get_args());
24 3
        });
25
    }
26
}
27