ObjectAccessor::hasValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 2
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