| Total Complexity | 3 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 13 | class NestedStorage implements NestedAccessorInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array<scalar, mixed> storage |
||
| 17 | */ |
||
| 18 | protected array $storage; |
||
| 19 | /** |
||
| 20 | * @var NestedAccessorInterface nested accessor |
||
| 21 | */ |
||
| 22 | protected NestedAccessorInterface $nestedAccessor; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param array<scalar, mixed>|null $storage |
||
| 26 | * @param NestedAccessorFactory|null $factory |
||
| 27 | */ |
||
| 28 | public function __construct(?array $storage = null, ?NestedAccessorFactory $factory = null) |
||
| 29 | { |
||
| 30 | $this->storage = $storage ?? []; |
||
| 31 | $this->nestedAccessor = ($factory ?? new NestedAccessorFactory())->create($this->storage); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @inheritDoc |
||
| 36 | * @throws NestedAccessorException |
||
| 37 | */ |
||
| 38 | public function get($path, bool $strict = true) |
||
| 39 | { |
||
| 40 | return $this->nestedAccessor->get($path, $strict); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @inheritDoc |
||
| 45 | * @throws NestedAccessorException |
||
| 46 | */ |
||
| 47 | public function set($path, $value, bool $strict = true): self |
||
| 51 | } |
||
| 52 | } |