SilentNestedAccessor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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