Completed
Push — master ( 1358d6...984c1e )
by Karsten
01:40
created

AbstractPredicateOperation::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
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\Interfaces\BinaryFunction;
11
use PeekAndPoke\Component\Psi\Interfaces\IntermediateOperation;
12
use PeekAndPoke\Component\Psi\Interfaces\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 $binaryFunction
24
     */
25 25
    public function __construct($binaryFunction)
26
    {
27 25
        $this->function = $binaryFunction;
28 25
    }
29
30
    /**
31
     * @param $input1
32
     * @param $input2
33
     *
34
     * @return bool
35
     */
36 21
    protected function test($input1, $input2 = null)
37
    {
38 21
        $func = $this->function;
39
40 21
        return (bool) $func($input1, $input2);
41
    }
42
}
43