ObjectAccessor   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 35
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 10 2
A setValue() 0 6 1
A unsetValue() 0 4 1
A hasValue() 0 4 1
A covers() 0 4 1
1
<?php
2
3
namespace gamringer\JSONPointer\Access;
4
5
use gamringer\JSONPointer\VoidValue;
6
7
class ObjectAccessor implements Accesses
8
{
9
    public function &getValue(&$target, $token)
10
    {
11
        $pointedValue = new VoidValue($target, $token);
12
13
        if ($this->hasValue($target, $token)) {
14
            $pointedValue = &$target->{$token};
15
        }
16
        
17
        return $pointedValue;
18
    }
19
    
20
    public function &setValue(&$target, $token, &$value)
21
    {
22
        $target->{$token} = &$value;
23
        
24
        return $this->getValue($target, $token);
25
    }
26
27
    public function unsetValue(&$target, $token)
28
    {
29
        unset($target->{$token});
30
    }
31
    
32
    public function hasValue(&$target, $token)
33
    {
34
        return property_exists($target, $token);
35
    }
36
37
    public function covers(&$target)
38
    {
39
        return is_object($target);
40
    }
41
}
42