AbstractPredicateOperation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 24
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A test() 0 5 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