| Total Complexity | 11 |
| Total Lines | 114 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 6 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 7 | class Iterator implements \Countable, \Iterator, \Serializable, \ArrayAccess, \JsonSerializable |
||
| 8 | { |
||
| 9 | |||
| 10 | use Traits\Countable; |
||
| 11 | use Traits\Iterator; |
||
| 12 | use Traits\Serializable; |
||
| 13 | use Traits\ArrayAccess; |
||
| 14 | use Traits\JsonSerializable; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $data; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Iterator constructor. |
||
| 23 | * |
||
| 24 | * @param array $data |
||
| 25 | */ |
||
| 26 | 9 | public function __construct(array $data = []) |
|
| 27 | { |
||
| 28 | 9 | $this->data = $data; |
|
| 29 | 9 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @return array |
||
| 33 | */ |
||
| 34 | 2 | public function asArray() |
|
| 35 | { |
||
| 36 | 2 | return $this->jsonSerialize(); |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $offset |
||
| 41 | * @param mixed $default |
||
| 42 | * |
||
| 43 | * @return mixed |
||
| 44 | */ |
||
| 45 | 1 | public function atData($offset, $default = null) |
|
| 46 | { |
||
| 47 | 1 | return $this->data[$offset] ?? $default; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | 1 | public function export() |
|
| 54 | { |
||
| 55 | 1 | return var_export($this->data, true); |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param string $offset |
||
| 60 | * |
||
| 61 | * @return array|mixed |
||
| 62 | */ |
||
| 63 | 1 | public function __get($offset) |
|
| 64 | { |
||
| 65 | 1 | return $this->offsetGet($offset); |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param string $offset |
||
| 70 | * @param mixed $value |
||
| 71 | */ |
||
| 72 | 1 | public function __set($offset, $value) |
|
| 73 | { |
||
| 74 | 1 | $this->offsetSet($offset, $value); |
|
| 75 | 1 | } |
|
| 76 | |||
| 77 | /** |
||
| 78 | * @param string $offset |
||
| 79 | * |
||
| 80 | * @return bool |
||
| 81 | */ |
||
| 82 | 1 | public function __isset($offset) |
|
| 83 | { |
||
| 84 | 1 | return $this->offsetExists($offset); |
|
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @param string $offset |
||
| 89 | */ |
||
| 90 | 1 | public function __unset($offset) |
|
| 93 | 1 | } |
|
| 94 | |||
| 95 | /** |
||
| 96 | * @return array |
||
| 97 | * |
||
| 98 | * @codeCoverageIgnore |
||
| 99 | */ |
||
| 100 | public function __sleep() |
||
| 101 | { |
||
| 102 | return ['data']; |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @return string |
||
| 107 | */ |
||
| 108 | 1 | public function __toString() |
|
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @return array |
||
| 115 | * |
||
| 116 | * @codeCoverageIgnore |
||
| 117 | */ |
||
| 118 | public function __debugInfo() |
||
| 121 | } |
||
| 122 | |||
| 123 | } |
||
| 124 |