Total Complexity | 10 |
Total Lines | 80 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
4 | class GenericResource implements \ArrayAccess |
||
5 | { |
||
6 | |||
7 | /** |
||
8 | * @var array |
||
9 | */ |
||
10 | private $data = array(); |
||
11 | |||
12 | /** |
||
13 | * @param array $data |
||
14 | */ |
||
15 | public function hydrate(array $data) |
||
16 | { |
||
17 | $this->data = $data; |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * @param string $offset |
||
22 | * @param mixed $value |
||
23 | */ |
||
24 | public function offsetSet($offset, $value) |
||
25 | { |
||
26 | $this->data[$offset] = $value; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $offset |
||
31 | * @return mixed |
||
32 | */ |
||
33 | public function offsetGet($offset) |
||
34 | { |
||
35 | return $this->data[$offset]; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param string $offset |
||
40 | * @return bool |
||
41 | */ |
||
42 | public function offsetExists($offset) |
||
43 | { |
||
44 | return array_key_exists($offset, $this->data); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param string $offset |
||
49 | */ |
||
50 | public function offsetUnset($offset) |
||
51 | { |
||
52 | if ($this->offsetExists($offset)) { |
||
53 | unset($this->data[$offset]); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return array |
||
59 | */ |
||
60 | public function toArray() |
||
61 | { |
||
62 | return $this->data; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param string $param |
||
67 | * @param mixed $default |
||
68 | * @return mixed |
||
69 | */ |
||
70 | public function get($param, $default = null) |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @param array $data |
||
77 | * @return GenericResource |
||
78 | */ |
||
79 | public static function create(array $data = array()) |
||
84 | } |
||
85 | } |
||
86 |