Mercurial > hg > rc1
comparison plugins/libcalendaring/lib/Sabre/VObject/Node.php @ 4:888e774ee983
libcalendar plugin as distributed
author | Charlie Root |
---|---|
date | Sat, 13 Jan 2018 08:57:56 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:f6fe4b6ae66a | 4:888e774ee983 |
---|---|
1 <?php | |
2 | |
3 namespace Sabre\VObject; | |
4 | |
5 /** | |
6 * Base class for all nodes | |
7 * | |
8 * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/). | |
9 * @author Evert Pot (http://evertpot.com/) | |
10 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License | |
11 */ | |
12 abstract class Node implements \IteratorAggregate, \ArrayAccess, \Countable { | |
13 | |
14 /** | |
15 * The following constants are used by the validate() method. | |
16 */ | |
17 const REPAIR = 1; | |
18 | |
19 /** | |
20 * Turns the object back into a serialized blob. | |
21 * | |
22 * @return string | |
23 */ | |
24 abstract function serialize(); | |
25 | |
26 /** | |
27 * Iterator override | |
28 * | |
29 * @var ElementList | |
30 */ | |
31 protected $iterator = null; | |
32 | |
33 /** | |
34 * A link to the parent node | |
35 * | |
36 * @var Node | |
37 */ | |
38 public $parent = null; | |
39 | |
40 /** | |
41 * Validates the node for correctness. | |
42 * | |
43 * The following options are supported: | |
44 * - Node::REPAIR - If something is broken, and automatic repair may | |
45 * be attempted. | |
46 * | |
47 * An array is returned with warnings. | |
48 * | |
49 * Every item in the array has the following properties: | |
50 * * level - (number between 1 and 3 with severity information) | |
51 * * message - (human readable message) | |
52 * * node - (reference to the offending node) | |
53 * | |
54 * @param int $options | |
55 * @return array | |
56 */ | |
57 public function validate($options = 0) { | |
58 | |
59 return array(); | |
60 | |
61 } | |
62 | |
63 /* {{{ IteratorAggregator interface */ | |
64 | |
65 /** | |
66 * Returns the iterator for this object | |
67 * | |
68 * @return ElementList | |
69 */ | |
70 public function getIterator() { | |
71 | |
72 if (!is_null($this->iterator)) | |
73 return $this->iterator; | |
74 | |
75 return new ElementList(array($this)); | |
76 | |
77 } | |
78 | |
79 /** | |
80 * Sets the overridden iterator | |
81 * | |
82 * Note that this is not actually part of the iterator interface | |
83 * | |
84 * @param ElementList $iterator | |
85 * @return void | |
86 */ | |
87 public function setIterator(ElementList $iterator) { | |
88 | |
89 $this->iterator = $iterator; | |
90 | |
91 } | |
92 | |
93 /* }}} */ | |
94 | |
95 /* {{{ Countable interface */ | |
96 | |
97 /** | |
98 * Returns the number of elements | |
99 * | |
100 * @return int | |
101 */ | |
102 public function count() { | |
103 | |
104 $it = $this->getIterator(); | |
105 return $it->count(); | |
106 | |
107 } | |
108 | |
109 /* }}} */ | |
110 | |
111 /* {{{ ArrayAccess Interface */ | |
112 | |
113 | |
114 /** | |
115 * Checks if an item exists through ArrayAccess. | |
116 * | |
117 * This method just forwards the request to the inner iterator | |
118 * | |
119 * @param int $offset | |
120 * @return bool | |
121 */ | |
122 public function offsetExists($offset) { | |
123 | |
124 $iterator = $this->getIterator(); | |
125 return $iterator->offsetExists($offset); | |
126 | |
127 } | |
128 | |
129 /** | |
130 * Gets an item through ArrayAccess. | |
131 * | |
132 * This method just forwards the request to the inner iterator | |
133 * | |
134 * @param int $offset | |
135 * @return mixed | |
136 */ | |
137 public function offsetGet($offset) { | |
138 | |
139 $iterator = $this->getIterator(); | |
140 return $iterator->offsetGet($offset); | |
141 | |
142 } | |
143 | |
144 /** | |
145 * Sets an item through ArrayAccess. | |
146 * | |
147 * This method just forwards the request to the inner iterator | |
148 * | |
149 * @param int $offset | |
150 * @param mixed $value | |
151 * @return void | |
152 */ | |
153 public function offsetSet($offset,$value) { | |
154 | |
155 $iterator = $this->getIterator(); | |
156 $iterator->offsetSet($offset,$value); | |
157 | |
158 // @codeCoverageIgnoreStart | |
159 // | |
160 // This method always throws an exception, so we ignore the closing | |
161 // brace | |
162 } | |
163 // @codeCoverageIgnoreEnd | |
164 | |
165 /** | |
166 * Sets an item through ArrayAccess. | |
167 * | |
168 * This method just forwards the request to the inner iterator | |
169 * | |
170 * @param int $offset | |
171 * @return void | |
172 */ | |
173 public function offsetUnset($offset) { | |
174 | |
175 $iterator = $this->getIterator(); | |
176 $iterator->offsetUnset($offset); | |
177 | |
178 // @codeCoverageIgnoreStart | |
179 // | |
180 // This method always throws an exception, so we ignore the closing | |
181 // brace | |
182 } | |
183 // @codeCoverageIgnoreEnd | |
184 | |
185 /* }}} */ | |
186 | |
187 } |