Failed Conditions
Pull Request — master (#32)
by Moesjarraf
10:13
created

Equal::applyToNode()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
eloc 5
nc 2
nop 1
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
    public function applyToNode(Node $node)
21
    {
22
        $instruction = $node->getInstruction($this);
23
        
24
        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
        $node->setResult($instruction[0] == $instruction[1]);
30
    }
31
}
32