Total Complexity | 6 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | final class SafeArrayIterator implements ArrayAccess, Countable |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * Ctor. |
||
21 | * |
||
22 | * @phpstan-param array<TKey, TValue> $stored |
||
23 | * @param array<mixed, mixed> $stored array for stored values. |
||
24 | */ |
||
25 | public function __construct( |
||
26 | /** |
||
27 | * Array for stored values. |
||
28 | * |
||
29 | * @phpstan-var array<TKey, TValue> |
||
30 | * @var array |
||
31 | */ |
||
32 | private array $stored = [] |
||
33 | ) { |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritDoc} |
||
38 | * @phpstan-param TKey $offset |
||
39 | * @phpstan-param TValue $value |
||
40 | */ |
||
41 | public function offsetSet(mixed $offset, mixed $value): void |
||
42 | { |
||
43 | $this->stored[$offset] = $value; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * {@inheritDoc} |
||
48 | * @phpstan-param TKey $offset |
||
49 | */ |
||
50 | public function offsetGet(mixed $offset): mixed |
||
51 | { |
||
52 | return $this->stored[$offset]; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | * @phpstan-param TKey $offset |
||
58 | */ |
||
59 | public function offsetExists(mixed $offset): bool |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | * @phpstan-param TKey $offset |
||
67 | */ |
||
68 | public function offsetUnset(mixed $offset): void |
||
69 | { |
||
70 | unset($this->stored); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * {@inheritDoc} |
||
75 | */ |
||
76 | public function count(): int |
||
79 | } |
||
80 | } |
||
81 |