| 1 |
<?php |
| 2 |
// @codingStandardsIgnoreFile |
| 3 |
|
| 4 |
class AWeberEntryDataArray implements ArrayAccess, Countable, Iterator { |
| 5 |
private $counter = 0; |
| 6 |
|
| 7 |
protected $data; |
| 8 |
protected $keys; |
| 9 |
protected $name; |
| 10 |
protected $parent; |
| 11 |
|
| 12 |
public function __construct($data, $name, $parent) { |
| 13 |
$this->data = $data; |
| 14 |
$this->keys = array_keys($data); |
| 15 |
$this->name = $name; |
| 16 |
$this->parent = $parent; |
| 17 |
} |
| 18 |
|
| 19 |
public function count() { |
| 20 |
return sizeOf($this->data); |
| 21 |
} |
| 22 |
|
| 23 |
public function offsetExists($offset) { |
| 24 |
return (isset($this->data[$offset])); |
| 25 |
} |
| 26 |
|
| 27 |
public function offsetGet($offset) { |
| 28 |
return $this->data[$offset]; |
| 29 |
} |
| 30 |
|
| 31 |
public function offsetSet($offset, $value) { |
| 32 |
$this->data[$offset] = $value; |
| 33 |
$this->parent->{$this->name} = $this->data; |
| 34 |
return $value; |
| 35 |
} |
| 36 |
|
| 37 |
public function offsetUnset($offset) { |
| 38 |
unset($this->data[$offset]); |
| 39 |
} |
| 40 |
|
| 41 |
public function rewind() { |
| 42 |
$this->counter = 0; |
| 43 |
} |
| 44 |
|
| 45 |
public function current() { |
| 46 |
return $this->data[$this->key()]; |
| 47 |
} |
| 48 |
|
| 49 |
public function key() { |
| 50 |
return $this->keys[$this->counter]; |
| 51 |
} |
| 52 |
|
| 53 |
public function next() { |
| 54 |
$this->counter++; |
| 55 |
} |
| 56 |
|
| 57 |
public function valid() { |
| 58 |
if ($this->counter >= sizeOf($this->data)) { |
| 59 |
return false; |
| 60 |
} |
| 61 |
return true; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
} |
| 66 |
|