Failed Conditions
Pull Request — master (#36)
by Sergey
07:22
created

Equal::applyToNode()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 9.9
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3.0416
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