1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace ICanBoogie;
13
14 15 16 17 18 19
20 class OffsetError extends \RuntimeException
21 {
22
23 }
24
25 26 27 28 29
30 class OffsetNotDefined extends OffsetError
31 {
32 public function __construct($message, $code=500, \Exception $previous=null)
33 {
34 if (is_array($message))
35 {
36 list($offset, $container) = $message + array(1 => null);
37
38 if (is_object($container))
39 {
40 $message = format
41 (
42 'Undefined offset %offset for object of class %class.', array
43 (
44 '%offset' => $offset,
45 '%class' => get_class($container)
46 )
47 );
48 }
49 else if (is_array($container))
50 {
51 $message = format
52 (
53 'Undefined offset %offset for the array: !array', array
54 (
55 '%offset' => $offset,
56 '!array' => $container
57 )
58 );
59 }
60 else
61 {
62 $message = format
63 (
64 'Undefined offset %offset.', array
65 (
66 '%offset' => $offset
67 )
68 );
69 }
70 }
71
72 parent::__construct($message, $code, $previous);
73 }
74 }
75
76 77 78
79 class OffsetNotReadable extends OffsetError
80 {
81 public function __construct($message, $code=500, \Exception $previous=null)
82 {
83 if (is_array($message))
84 {
85 list($offset, $container) = $message + array(1 => null);
86
87 if (is_object($container))
88 {
89 $message = format
90 (
91 'The offset %offset for object of class %class is not readable.', array
92 (
93 'offset' => $offset,
94 'class' => get_class($container)
95 )
96 );
97 }
98 else if (is_array($container))
99 {
100 $message = format
101 (
102 'The offset %offset is not readable for the array: !array', array
103 (
104 'offset' => $offset,
105 'array' => $container
106 )
107 );
108 }
109 else
110 {
111 $message = format
112 (
113 'The offset %offset is not readable.', array
114 (
115 'offset' => $offset
116 )
117 );
118 }
119 }
120
121 parent::__construct($message, $code, $previous);
122 }
123 }
124
125 126 127
128 class OffsetNotWritable extends OffsetError
129 {
130 public function __construct($message, $code=500, \Exception $previous=null)
131 {
132 if (is_array($message))
133 {
134 list($offset, $container) = $message + array(1 => null);
135
136 if (is_object($container))
137 {
138 $message = format
139 (
140 'The offset %offset for object of class %class is not writable.', array
141 (
142 'offset' => $offset,
143 'class' => get_class($container)
144 )
145 );
146 }
147 else if (is_array($container))
148 {
149 $message = format
150 (
151 'The offset %offset is not writable for the array: !array', array
152 (
153 'offset' => $offset,
154 'array' => $container
155 )
156 );
157 }
158 else
159 {
160 $message = format
161 (
162 'The offset %offset is not writable.', array
163 (
164 'offset' => $offset
165 )
166 );
167 }
168 }
169
170 parent::__construct($message, $code, $previous);
171 }
172 }
173
174 175 176 177 178 179 180
181 class PropertyError extends \RuntimeException
182 {
183
184 }
185
186 187 188 189 190
191 class PropertyNotDefined extends PropertyError
192 {
193 public function __construct($message, $code=500, \Exception $previous=null)
194 {
195 if (is_array($message))
196 {
197 list($property, $container) = $message + array(1 => null);
198
199 if (is_object($container))
200 {
201 $message = format
202 (
203 'Undefined property %property for object of class %class.', array
204 (
205 '%property' => $property,
206 '%class' => get_class($container)
207 )
208 );
209 }
210 else
211 {
212 $message = format
213 (
214 'Undefined property %property.', array
215 (
216 '%property' => $property
217 )
218 );
219 }
220 }
221
222 parent::__construct($message, $code, $previous);
223 }
224 }
225
226 227 228 229 230
231 class PropertyNotReadable extends PropertyError
232 {
233 public function __construct($message, $code=500, \Exception $previous=null)
234 {
235 if (is_array($message))
236 {
237 list($property, $container) = $message + array(1 => null);
238
239 if (is_object($container))
240 {
241 $message = format
242 (
243 'The property %property for object of class %class is not readable.', array
244 (
245 '%property' => $property,
246 '%class' => get_class($container)
247 )
248 );
249 }
250 else
251 {
252 $message = format
253 (
254 'The property %property is not readable.', array
255 (
256 '%property' => $property
257 )
258 );
259 }
260 }
261
262 parent::__construct($message, $code, $previous);
263 }
264 }
265
266 267 268 269 270
271 class PropertyNotWritable extends PropertyError
272 {
273 public function __construct($message, $code=500, \Exception $previous=null)
274 {
275 if (is_array($message))
276 {
277 list($property, $container) = $message + array(1 => null);
278
279 if (is_object($container))
280 {
281 $message = format
282 (
283 'The property %property for object of class %class is not writable.', array
284 (
285 '%property' => $property,
286 '%class' => get_class($container)
287 )
288 );
289 }
290 else
291 {
292 $message = format
293 (
294 'The property %property is not writable.', array
295 (
296 '%property' => $property
297 )
298 );
299 }
300 }
301
302 parent::__construct($message, $code, $previous);
303 }
304 }
305
306 307 308 309 310
311 class PropertyIsReserved extends PropertyError
312 {
313 private $property;
314
315 public function __construct($property, $code=500, \Exception $previous=null)
316 {
317 $this->property = $property;
318
319 parent::__construct(format('Property %property is reserved.', array('%property' => $property)), $code, $previous);
320 }
321
322 public function __get($property)
323 {
324 if ($property === 'property')
325 {
326 return $this->property;
327 }
328
329 throw new PropertyNotDefined(array($property, $this));
330 }
331 }