| Total Complexity | 15 |
| Total Lines | 104 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class FlexibleData implements DataStructure, \ArrayAccess, \Iterator { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | private $data; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var int |
||
| 16 | */ |
||
| 17 | private $position = 0; |
||
| 18 | |||
| 19 | 8 | public function __construct(array $data = []) { |
|
| 20 | 8 | $this->data = $data; |
|
| 21 | 8 | } |
|
| 22 | |||
| 23 | /** |
||
| 24 | * @inheritdoc |
||
| 25 | */ |
||
| 26 | 2 | public function build() { |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string|int $key |
||
| 32 | * @return mixed |
||
| 33 | */ |
||
| 34 | 4 | public function get($key) { |
|
| 35 | 4 | if (!isset($this->data[$key])) { |
|
| 36 | 1 | return null; |
|
| 37 | } |
||
| 38 | |||
| 39 | 4 | if (\is_scalar($this->data[$key])) { |
|
| 40 | 2 | return $this->data[$key]; |
|
| 41 | } |
||
| 42 | |||
| 43 | 3 | if (\is_array($this->data[$key])) { |
|
| 44 | 3 | return new FlexibleData($this->data[$key]); |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | return $this->data[$key]; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @inheritdoc |
||
| 52 | */ |
||
| 53 | 1 | public function offsetExists($offset) { |
|
| 54 | 1 | return isset($this->data[$offset]); |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @inheritdoc |
||
| 59 | */ |
||
| 60 | 4 | public function &offsetGet($offset) { |
|
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @inheritdoc |
||
| 66 | */ |
||
| 67 | 2 | public function offsetSet($offset, $value) { |
|
| 68 | 2 | $this->data[$offset] = $value; |
|
| 69 | 2 | } |
|
| 70 | |||
| 71 | /** |
||
| 72 | * @inheritdoc |
||
| 73 | */ |
||
| 74 | 1 | public function offsetUnset($offset) { |
|
| 76 | 1 | } |
|
| 77 | |||
| 78 | /** |
||
| 79 | * @inheritdoc |
||
| 80 | */ |
||
| 81 | 2 | public function current() { |
|
| 82 | 2 | return new FlexibleData($this->data[$this->position]); |
|
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @inheritdoc |
||
| 87 | */ |
||
| 88 | 2 | public function next() { |
|
| 89 | 2 | ++$this->position; |
|
| 90 | 2 | } |
|
| 91 | |||
| 92 | /** |
||
| 93 | * @inheritdoc |
||
| 94 | */ |
||
| 95 | 1 | public function key() { |
|
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @inheritdoc |
||
| 101 | */ |
||
| 102 | 2 | public function valid() { |
|
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @inheritdoc |
||
| 108 | */ |
||
| 109 | 2 | public function rewind() { |
|
| 111 | 2 | } |
|
| 112 | } |
||
| 113 |