| Total Complexity | 6 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | trait ArrayAccessData |
||
| 12 | { |
||
| 13 | protected array $data = []; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Magic method to handle key_exists/isset checks of an array value on the object. |
||
| 17 | * |
||
| 18 | * @param string|int $offset |
||
| 19 | * |
||
| 20 | * @return boolean |
||
| 21 | */ |
||
| 22 | public function offsetExists($offset): bool |
||
| 23 | { |
||
| 24 | return key_exists($offset, $this->data); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Magic method to handle retrieval of an array value on the object. |
||
| 29 | * |
||
| 30 | * @param string|int $offset |
||
| 31 | * |
||
| 32 | * @return mixed |
||
| 33 | */ |
||
| 34 | public function offsetGet($offset) |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Magic method to handle modification of an array value on the object. |
||
| 41 | * |
||
| 42 | * @param string|int $offset |
||
| 43 | * @param mixed $value |
||
| 44 | * |
||
| 45 | * @return void |
||
| 46 | * |
||
| 47 | * @throws \FigTree\Config\Exceptions\ReadOnlyException |
||
| 48 | */ |
||
| 49 | public function offsetSet($offset, $value): void |
||
|
|
|||
| 50 | { |
||
| 51 | throw new ReadOnlyException($offset); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Magic method to handle removal of an array value on the object. |
||
| 56 | * |
||
| 57 | * @param string|int $offset |
||
| 58 | * |
||
| 59 | * @return void |
||
| 60 | * |
||
| 61 | * @throws \FigTree\Config\Exceptions\ReadOnlyException |
||
| 62 | */ |
||
| 63 | public function offsetUnset($offset): void |
||
| 64 | { |
||
| 65 | throw new ReadOnlyException($offset); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Convert the object into an array. |
||
| 70 | * |
||
| 71 | * @return array |
||
| 72 | */ |
||
| 73 | public function toArray(): array |
||
| 74 | { |
||
| 75 | return $this->data; |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Retrieve an external iterator. |
||
| 80 | * |
||
| 81 | * @return \Traversable |
||
| 82 | */ |
||
| 83 | public function getIterator(): Traversable |
||
| 86 | } |
||
| 87 | } |
||
| 88 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.