Completed
Pull Request — master (#5)
by Moesjarraf
08:07
created

Reference   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 4
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A applyToNode() 0 7 1
1
<?php
2
3
namespace LegalThings\DataEnricher\Processor;
4
5
use LegalThings\DataEnricher;
6
use LegalThings\DataEnricher\Processor;
7
use LegalThings\DataEnricher\Node;
8
use Jasny\DotKey;
9
10
/**
11
 * Symbolic link to a property of the source object
12
 */
13
class Reference implements Processor
14
{
15
    use Processor\Implementation;
16
    
17
    /**
18
     * @var DotKey
19
     */
20
    protected $source;
21
    
22
    /**
23
     * Class constructor
24
     * 
25
     * @param DataEnricher $invoker
26
     * @param string       $property  Property key which should trigger the processor
27
     */
28
    public function __construct(DataEnricher $invoker, $property)
29
    {
30
        $this->source = DotKey::on($invoker->getSource());
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
31
        $this->property = $property;
32
    }
33
    
34
    /**
35
     * Apply reference processing to a single node
36
     * 
37
     * @param Node $node
38
     */
39
    protected function applyToNode(Node $node)
40
    {
41
        $ref = $node->getInstruction($this);
42
        
43
        $result = $this->source->get($ref);
44
        $node->setResult($result);
45
    }
46
}
47