Passed
Push — master ( 72f38a...596bea )
by Smoren
02:21
created

SilentNestedAccessor   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 67
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A exist() 0 3 1
A set() 0 4 1
A __construct() 0 3 1
A get() 0 3 1
A delete() 0 4 1
A append() 0 4 1
A isset() 0 3 1
1
<?php
2
3
namespace Smoren\NestedAccessor\Components;
4
5
use Smoren\NestedAccessor\Exceptions\NestedAccessorException;
6
use Smoren\NestedAccessor\Interfaces\SilentNestedAccessorInterface;
7
8
class SilentNestedAccessor implements SilentNestedAccessorInterface
9
{
10
    /**
11
     * @var NestedAccessor
12
     */
13
    protected NestedAccessor $nestedAccessor;
14
15
    /**
16
     * ArrayNestedAccessor constructor.
17
     * @param array<scalar, mixed>|object $source
18
     * @param non-empty-string $pathDelimiter
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
19
     * @throws NestedAccessorException
20
     */
21
    public function __construct(&$source, string $pathDelimiter = '.')
22
    {
23
        $this->nestedAccessor = new NestedAccessor($source, $pathDelimiter);
24
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function get($path = null)
30
    {
31
        return $this->nestedAccessor->get($path, false);
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    public function set($path, $value): self
38
    {
39
        $this->nestedAccessor->set($path, $value, false);
40
        return $this;
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function append($path, $value): self
47
    {
48
        $this->nestedAccessor->append($path, $value, false);
49
        return $this;
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function delete($path): self
56
    {
57
        $this->nestedAccessor->delete($path, false);
58
        return $this;
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64
    public function exist($path): bool
65
    {
66
        return $this->nestedAccessor->exist($path);
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72
    public function isset($path): bool
73
    {
74
        return $this->nestedAccessor->isset($path);
75
    }
76
}
77