AbstractPredicateOperation::test()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * File was created 07.05.2015 12:05
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\IntermediateOperation;
12
use PeekAndPoke\Component\Psi\UnaryFunction;
13
14
/**
15
 * @author Karsten J. Gerber <[email protected]>
16
 */
17
abstract class AbstractPredicateOperation implements IntermediateOperation
18
{
19
    /** @var callable|\Closure|UnaryFunction|BinaryFunction */
20
    protected $function;
21
22
    /**
23
     * @param callable|\Closure|UnaryFunction|BinaryFunction $condition
24
     */
25 48
    public function __construct($condition)
26
    {
27 48
        $this->function = $condition;
28 48
    }
29
30
    /**
31
     * @param $input1
32
     * @param $input2
33
     *
34
     * @return bool
35
     */
36 41
    protected function test($input1, $input2 = null)
37
    {
38 41
        $func = $this->function;
39
40 41
        return (bool) $func($input1, $input2);
41
    }
42
}
43