1 | <?php |
||
5 | abstract class Base implements \ArrayAccess, DataWrapperInterface |
||
6 | { |
||
7 | /** |
||
8 | * Base constructor - you may use an array to initialize the dataWrapper |
||
9 | * |
||
10 | * @param array $data |
||
11 | */ |
||
12 | 12 | public function __construct(array $data = array()) |
|
31 | |||
32 | /** |
||
33 | * Getter and Setters |
||
34 | * |
||
35 | * @param string $name |
||
36 | * @param array $args |
||
37 | * @throws \InvalidArgumentException |
||
38 | * @return mixed |
||
39 | */ |
||
40 | 6 | public function __call($name, array $args) |
|
73 | |||
74 | /** |
||
75 | * Export dataWrapper values as an array |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | 6 | public function toArray() |
|
100 | |||
101 | /** |
||
102 | * ToArray with unset null fields |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | 1 | public function toCleanArray() |
|
119 | |||
120 | /** |
||
121 | * Extract dataWrapper $property value from $data |
||
122 | * |
||
123 | * @param array $data |
||
124 | * @param string $property |
||
125 | * @throws \OutOfBoundsException |
||
126 | * @return mixed |
||
127 | */ |
||
128 | 7 | private function getValue(array $data, $property) |
|
141 | |||
142 | /** |
||
143 | * Convert from underscore to camel case |
||
144 | * |
||
145 | * @param string $name |
||
146 | * @return string |
||
147 | */ |
||
148 | 9 | private function toCamelCase($name) |
|
154 | |||
155 | /** |
||
156 | * Convert from undescore to studly caps |
||
157 | * |
||
158 | * @param string $name |
||
159 | * @return string |
||
160 | */ |
||
161 | 9 | private function toStudlyCaps($name) |
|
165 | |||
166 | /** |
||
167 | * @param string $offset |
||
168 | * @return mixed |
||
169 | */ |
||
170 | 1 | public function offsetGet($offset) |
|
175 | |||
176 | /** |
||
177 | * @param string $offset |
||
178 | * @param mixed $value |
||
179 | * @return mixed |
||
180 | */ |
||
181 | 1 | public function offsetSet($offset, $value) |
|
186 | |||
187 | /** |
||
188 | * @param string $offset |
||
189 | * @return boolean |
||
190 | */ |
||
191 | 1 | public function offsetExists($offset) |
|
196 | |||
197 | /** |
||
198 | * @param string $offset |
||
199 | * @return void |
||
200 | */ |
||
201 | 1 | public function offsetUnset($offset) |
|
205 | |||
206 | /** |
||
207 | * @param \ReflectionProperty $property |
||
208 | * @return bool |
||
209 | */ |
||
210 | 9 | public function isDataWrapper(\ReflectionProperty $property) |
|
224 | |||
225 | /** |
||
226 | * @param mixed $value |
||
227 | * @param \ReflectionProperty $property |
||
228 | * @return BaseCollection |
||
229 | */ |
||
230 | 2 | public function toDataWrapper($value, \ReflectionProperty $property) |
|
235 | |||
236 | /** |
||
237 | * @param \ReflectionProperty $property |
||
238 | * @return string |
||
239 | */ |
||
240 | 9 | private function findType(\ReflectionProperty $property) |
|
256 | } |
||
257 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: