Implementation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 47
ccs 7
cts 7
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
applyToNode() 0 1 ?
A __construct() 0 4 1
A withSourceAndTarget() 0 4 1
A getProperty() 0 4 1
1
<?php
2
3
namespace LegalThings\DataEnricher\Processor;
4
5
use LegalThings\DataEnricher\Node;
6
7
/**
8
 * Basic stuff for a processor implementation
9
 */
10
trait Implementation
11
{
12
    /**
13
     * Property key which should trigger the processor
14
     * @var string
15
     */
16
    protected $property;
17
    
18
    /**
19
     * Apply processing to a single node
20
     * 
21
     * @param Node $node
22
     * @return void
23
     */
24
    abstract public function applyToNode(Node $node);
25
    
26
    /**
27
     * Class constructor
28
     * 
29
     * @param string $property  Property key with the processing instruction
30
     */
31 5
    public function __construct($property)
32
    {
33 5
        $this->property = $property;
34 5
    }
35
    
36
    /**
37
     * Doesn't apply, simply return processor
38
     * 
39
     * @param object       $source  Data source
40
     * @param array|object $target  Target or dot key path
41
     */
42 2
    public function withSourceAndTarget($source, $target)
0 ignored issues
show
Unused Code introduced by
The parameter $source is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $target is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    {
44 2
        return $this;
45
    }
46
    
47
    /**
48
     * Get the property key that holds the processing instruction
49
     * 
50
     * @return string
51
     */
52 3
    public function getProperty()
53
    {
54 3
        return $this->property;
55
    }
56
}
57