1 | <?php |
||
9 | class ODDDocument implements \Iterator { |
||
10 | /** |
||
11 | * ODD Version |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | private $ODDSupportedVersion = "1.0"; |
||
16 | |||
17 | /** |
||
18 | * Elements of the document. |
||
19 | */ |
||
20 | private $elements; |
||
21 | |||
22 | /** |
||
23 | * Optional wrapper factory. |
||
24 | */ |
||
25 | private $wrapperfactory; |
||
26 | |||
27 | /** |
||
28 | * Create a new ODD Document. |
||
29 | * |
||
30 | * @param array $elements Elements to add |
||
31 | * |
||
32 | * @return void |
||
|
|||
33 | */ |
||
34 | public function __construct(array $elements = null) { |
||
45 | |||
46 | /** |
||
47 | * Return the version of ODD being used. |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | public function getVersion() { |
||
54 | |||
55 | /** |
||
56 | * Returns the number of elements |
||
57 | * |
||
58 | * @return int |
||
59 | */ |
||
60 | public function getNumElements() { |
||
63 | |||
64 | /** |
||
65 | * Add an element |
||
66 | * |
||
67 | * @param ODD $element An ODD element |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | public function addElement(ODD $element) { |
||
77 | |||
78 | /** |
||
79 | * Add multiple elements at once |
||
80 | * |
||
81 | * @param array $elements Array of ODD elements |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | public function addElements(array $elements) { |
||
90 | |||
91 | /** |
||
92 | * Return all elements |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | public function getElements() { |
||
99 | |||
100 | /** |
||
101 | * Set an optional wrapper factory to optionally embed the ODD document in another format. |
||
102 | * |
||
103 | * @param \ODDWrapperFactory $factory The factory |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | public function setWrapperFactory(\ODDWrapperFactory $factory) { |
||
110 | |||
111 | /** |
||
112 | * Magic function to generate valid ODD XML for this item. |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function __toString() { |
||
140 | |||
141 | // ITERATOR INTERFACE ////////////////////////////////////////////////////////////// |
||
142 | /* |
||
143 | * This lets an entity's attributes be displayed using foreach as a normal array. |
||
144 | * Example: http://www.sitepoint.com/print/php5-standard-library |
||
145 | */ |
||
146 | |||
147 | private $valid = false; |
||
148 | |||
149 | /** |
||
150 | * Iterator interface |
||
151 | * |
||
152 | * @see Iterator::rewind() |
||
153 | * |
||
154 | * @return void |
||
155 | */ |
||
156 | function rewind() { |
||
159 | |||
160 | /** |
||
161 | * Iterator interface |
||
162 | * |
||
163 | * @see Iterator::current() |
||
164 | * |
||
165 | * @return void |
||
166 | */ |
||
167 | function current() { |
||
170 | |||
171 | /** |
||
172 | * Iterator interface |
||
173 | * |
||
174 | * @see Iterator::key() |
||
175 | * |
||
176 | * @return void |
||
177 | */ |
||
178 | function key() { |
||
181 | |||
182 | /** |
||
183 | * Iterator interface |
||
184 | * |
||
185 | * @see Iterator::next() |
||
186 | * |
||
187 | * @return void |
||
188 | */ |
||
189 | function next() { |
||
192 | |||
193 | /** |
||
194 | * Iterator interface |
||
195 | * |
||
196 | * @see Iterator::valid() |
||
197 | * |
||
198 | * @return void |
||
199 | */ |
||
200 | function valid() { |
||
203 | } |
||
204 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.