Completed
Pull Request — master (#5)
by Moesjarraf
09:47
created

Merge   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A applyToNode() 0 7 1
A merge() 0 12 3
1
<?php
2
3
namespace LegalThings\DataEnricher\Processor;
4
5
use LegalThings\DataEnricher\Node;
6
use LegalThings\DataEnricher\Processor;
7
8
/**
9
 * Merge multiple object into one
10
 */
11
class Merge 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)
21
    {
22
        $list = $node->getInstruction($this);
23
        
24
        $result = $this->merge($list);
25
        $node->setResult($result);
26
    }
27
    
28
    /**
29
     * Merge properties of an object
30
     * 
31
     * @param array $merge
32
     */
33
    protected function merge($merge)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
34
    {
35
        $value = (object)[];
36
        
37
        foreach ($merge as $object) { 
38
            foreach ($object as $key => $value) {
39
               $value->$key = $value;
1 ignored issue
show
Coding Style introduced by
It seems like the identation of this line is off (expected at least 16 spaces, but found 15).
Loading history...
40
            }
41
        }
42
        
43
        return $value;
44
    }
45
}
46