Failed Conditions
Push — master ( 0bbe18...211e20 )
by Moesjarraf
03:53
created

Equal::applyToNode()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 5
cts 7
cp 0.7143
rs 9.4285
cc 3
eloc 5
nc 2
nop 1
crap 3.2098
1
<?php
2
3
namespace LegalThings\DataEnricher\Processor;
4
5
use LegalThings\DataEnricher\Node;
6
use LegalThings\DataEnricher\Processor;
7
8
/**
9
 * Equal processor
10
 */
11
class Equal implements Processor
12
{
13
    use Processor\Implementation;
14
    
15
    /**
16
     * Apply processing to a single node
17
     * 
18
     * @param Node $node
19
     */
20 7
    public function applyToNode(Node $node)
21
    {
22 7
        $instruction = $node->getInstruction($this);
23
        
24 7
        if (!is_array($instruction) || count($instruction) !== 2) {
25
            $node->setResult(false);
26
        }
27
        
28
        // might want to improve this check for different types using a library
29 7
        $node->setResult($instruction[0] == $instruction[1]);
30 7
    }
31
}
32