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

Join::applyToNode()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 6.027

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
ccs 10
cts 11
cp 0.9091
rs 8.8571
cc 6
eloc 9
nc 6
nop 1
crap 6.027
1
<?php
2
3
namespace LegalThings\DataEnricher\Processor;
4
5
use LegalThings\DataEnricher\Node;
6
use LegalThings\DataEnricher\Processor;
7
8
/**
9
 * Join processor
10
 */
11
class Join implements Processor
12
{
13
    use Processor\Implementation;
14
    
15
    /**
16
     * Apply processing to a single node
17
     * 
18
     * @param Node $node
19
     */
20 2
    public function applyToNode(Node $node)
21
    {
22 2
        $instruction = $node->getInstruction($this);
23
        
24 2
        if (is_array($instruction) || is_object($instruction)) {
25 2
            $instruction = (object)$instruction;
26 2
        }
27
        
28 2
        if (!isset($instruction) || !isset($instruction->input)) {
29
            return;
30
        }
31
        
32 2
        $glue = isset($instruction->glue) ? $instruction->glue : '';
33 2
        $result = join($glue, $instruction->input);
34 2
        $node->setResult($result);
35 2
    }
36
}
37