1 <?php
2
3 namespace OpenCloud\Common;
4
5 class ArrayAccess implements \ArrayAccess
6 {
7 protected $elements;
8
9 public function __construct($data = array())
10 {
11 $this->elements = (array) $data;
12 }
13
14 15 16 17 18 19
20 public function offsetSet($offset, $value)
21 {
22 if ($offset === null) {
23 $this->elements[] = $value;
24 } else {
25 $this->elements[$offset] = $value;
26 }
27 }
28
29 30 31 32 33 34
35 public function offsetExists($offset)
36 {
37 return array_key_exists($offset, $this->elements);
38 }
39
40 41 42 43 44
45 public function offsetUnset($offset)
46 {
47 unset($this->elements[$offset]);
48 }
49
50 51 52 53 54 55
56 public function offsetGet($offset)
57 {
58 return $this->offsetExists($offset) ? $this->elements[$offset] : null;
59 }
60 }
61