Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | trait ArrayAccessTrait |
||
13 | { |
||
14 | /** |
||
15 | * Returns whether there is an element at the specified offset. |
||
16 | * |
||
17 | * This method is required by the SPL interface {@see ArrayAccess}. |
||
18 | * |
||
19 | * It is implicitly called when you use something like `isset($model[$offset])`. |
||
20 | * |
||
21 | * @return bool whether or not an offset exists. |
||
22 | */ |
||
23 | public function offsetExists(mixed $offset): bool |
||
24 | { |
||
25 | return isset($this->$offset); |
||
26 | } |
||
27 | |||
28 | public function offsetGet(mixed $offset): mixed |
||
29 | { |
||
30 | return $this->$offset; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Sets the element at the specified offset. |
||
35 | * |
||
36 | * This method is required by the SPL interface {@see ArrayAccess}. |
||
37 | * |
||
38 | * It is implicitly called when you use something like `$model[$offset] = $item;`. |
||
39 | */ |
||
40 | public function offsetSet(mixed $offset, mixed $value): void |
||
41 | { |
||
42 | $this->$offset = $value; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Sets the element value at the specified offset to null. |
||
47 | * |
||
48 | * This method is required by the SPL interface {@see ArrayAccess}. |
||
49 | * |
||
50 | * It is implicitly called when you use something like `unset($model[$offset])`. |
||
51 | */ |
||
52 | public function offsetUnset(mixed $offset): void |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 |