FilterByPredicate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 28
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A apply() 0 8 1
1
<?php
2
/**
3
 * File was created 06.05.2015 16:25
4
 *
5
 * @author Karsten J. Gerber <[email protected]>
6
 */
7
8
namespace PeekAndPoke\Component\Psi\Operation\Intermediate\Predicate;
9
10
use PeekAndPoke\Component\Psi\BinaryFunction;
11
use PeekAndPoke\Component\Psi\Solver\IntermediateContext;
12
use PeekAndPoke\Component\Psi\UnaryFunction;
13
14
/**
15
 * @author Karsten J. Gerber <[email protected]>
16
 */
17
class FilterByPredicate extends AbstractPredicateOperation
18
{
19
    /** @var callable|\Closure|BinaryFunction|UnaryFunction */
20
    private $mapper;
21
22
    /**
23
     * FilterByPredicate constructor.
24
     *
25
     * @param callable|\Closure|BinaryFunction|UnaryFunction $mapper
26
     * @param callable|\Closure|BinaryFunction|UnaryFunction $condition
27
     */
28 2
    public function __construct($mapper, $condition)
29
    {
30 2
        parent::__construct($condition);
31 2
        $this->mapper = $mapper;
32 2
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function apply($input, $index, IntermediateContext $context)
38
    {
39 2
        $mapper = $this->mapper;
40
41 2
        $context->outUseItem     = $this->test($mapper($input), $index);
42 2
        $context->outCanContinue = true;
43
44 2
        return $input;
45
    }
46
}
47