1 | <?php |
||
6 | abstract class AbstractData implements \ArrayAccess, \IteratorAggregate |
||
7 | { |
||
8 | /** |
||
9 | * @var array|object |
||
10 | */ |
||
11 | protected $data = []; |
||
12 | |||
13 | /** |
||
14 | * @var callable|Escape |
||
15 | */ |
||
16 | protected $escape; |
||
17 | |||
18 | /** |
||
19 | * @ param Message $message |
||
20 | * |
||
21 | * @param array|object $data |
||
22 | * @param null|callable $escape |
||
23 | */ |
||
24 | public function __construct($data = [], $escape = null) |
||
29 | |||
30 | /** |
||
31 | * @param array|object $data |
||
32 | * @param null|callable $escape |
||
33 | * @return static |
||
34 | */ |
||
35 | public static function forge($data = [], $escape = null) |
||
39 | |||
40 | /** |
||
41 | * accessing data as property. returns escaped value. |
||
42 | * |
||
43 | * @param string $key |
||
44 | * @return mixed |
||
45 | */ |
||
46 | public function __get($key) |
||
50 | |||
51 | /** |
||
52 | * get an escaped value. |
||
53 | * |
||
54 | * @param string $key |
||
55 | * @param null|mixed $default |
||
56 | * @return mixed |
||
57 | */ |
||
58 | public function get($key, $default = null) |
||
64 | |||
65 | /** |
||
66 | * @param string $name |
||
67 | * @param string|null $value |
||
68 | * @param string $string |
||
69 | * @return string |
||
70 | */ |
||
71 | public function ifExists($name, $value, $string) |
||
78 | |||
79 | /** |
||
80 | * @param string $name |
||
81 | * @param string $value |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function exists($name, $value = null) |
||
98 | |||
99 | /** |
||
100 | * get a raw value. |
||
101 | * |
||
102 | * @param string $key |
||
103 | * @param null|mixed $default |
||
104 | * @return mixed |
||
105 | */ |
||
106 | public function raw($key, $default = null) |
||
117 | |||
118 | /** |
||
119 | * get a raw value for form element array name (with []). |
||
120 | * |
||
121 | * @param string $key |
||
122 | * @return null|mixed |
||
123 | */ |
||
124 | private function parseRaw($key) |
||
134 | |||
135 | /** |
||
136 | * gets a value from $input array. |
||
137 | * |
||
138 | * returns null if not found. or |
||
139 | * returns an empty space if key is set but has not real value. |
||
140 | * |
||
141 | * @param array $levels |
||
142 | * @param mixed $inputs |
||
143 | * @return mixed |
||
144 | */ |
||
145 | private function recurseGet($levels, $inputs) |
||
161 | |||
162 | /** |
||
163 | * returns new Data object populated with its data[$key]. |
||
164 | * |
||
165 | * @param string $key |
||
166 | * @return static |
||
167 | */ |
||
168 | public function extractKey($key) |
||
174 | |||
175 | /** |
||
176 | * Retrieve an external iterator |
||
177 | * |
||
178 | * @return Traversable |
||
179 | */ |
||
180 | public function getIterator() |
||
188 | |||
189 | /** |
||
190 | * @param mixed $offset |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function offsetExists($offset) |
||
197 | |||
198 | /** |
||
199 | * @param mixed |
||
200 | * @return mixed |
||
201 | */ |
||
202 | public function offsetGet($offset) |
||
206 | |||
207 | /** |
||
208 | * @param mixed $offset |
||
209 | * @param mixed $value |
||
210 | * @return void |
||
211 | */ |
||
212 | public function offsetSet($offset, $value) |
||
216 | |||
217 | /** |
||
218 | * @param mixed $offset |
||
219 | * @return void |
||
220 | */ |
||
221 | public function offsetUnset($offset) |
||
227 | |||
228 | } |
||
229 |