1 | <?php |
||
8 | abstract class DOMDocument |
||
9 | { |
||
10 | /** |
||
11 | * Coverts the given array to a \DOMDocument. |
||
12 | * |
||
13 | * @param array $array The array to covert. |
||
14 | * |
||
15 | * @return \DOMDocument |
||
16 | */ |
||
17 | final public static function fromArray(array $array) |
||
26 | |||
27 | /** |
||
28 | * Converts the given \DOMDocument to an array. |
||
29 | * |
||
30 | * @param \DOMDocument $document The document to convert. |
||
31 | * |
||
32 | * @return array |
||
33 | */ |
||
34 | final public static function toArray(\DOMDocument $document) |
||
44 | |||
45 | /** |
||
46 | * Helper method to add a new \DOMNode to the given document with the given value. |
||
47 | * |
||
48 | * @param \DOMDocument $document The document to which the node will be added. |
||
49 | * @param string $xpath A valid xpath destination of the new node. |
||
50 | * @param mixed $value The value for the new node. |
||
51 | * |
||
52 | * @return void |
||
53 | * |
||
54 | * @throws \DOMException Thrown if the given $xpath is not valid. |
||
55 | */ |
||
56 | final public static function addXPath(\DOMDocument $document, $xpath, $value = null) |
||
76 | |||
77 | /** |
||
78 | * Helper method to create element(s) from the given tagName. |
||
79 | * |
||
80 | * @param \DOMXPath $domXPath The DOMXPath object built using the owner document. |
||
81 | * @param \DOMNode $context The node to which the new elements will be added. |
||
82 | * @param string $fragment The tag name of the element. |
||
83 | * |
||
84 | * @return \DOMElement|\DOMAttr The DOMNode that was created. |
||
85 | */ |
||
86 | final private static function parseFragment(\DOMXPath $domXPath, \DOMNode $context, $fragment) |
||
140 | |||
141 | /** |
||
142 | * Helper method to add multiple identical nodes to the given context node. |
||
143 | * |
||
144 | * @param \DOMDocument $document The parent document. |
||
145 | * @param \DOMNode $context The node to which the new elements will be added. |
||
146 | * @param string $tagName The tag name of the element. |
||
147 | * @param integer $limit The number of elements to create. |
||
148 | * |
||
149 | * @return void |
||
150 | */ |
||
151 | final private static function addMultiple(\DOMDocument $document, \DOMNode $context, $tagName, $limit) |
||
157 | |||
158 | /** |
||
159 | * Helper method to create all sub elements in the given array based on the given xpath. |
||
160 | * |
||
161 | * @param array $array The array to which the new elements will be added. |
||
162 | * @param string $path The xpath defining the new elements. |
||
163 | * @param mixed $value The value for the last child element. |
||
164 | * |
||
165 | * @return void |
||
166 | */ |
||
167 | final private static function pathToArray(array &$array, $path, $value = null) |
||
187 | |||
188 | /** |
||
189 | * Helper method to ensure the value at the given $key is an array. |
||
190 | * |
||
191 | * @param array $array The array for which element $key should be checked. |
||
192 | * @param string $key The key for which the value will be made into an array. |
||
193 | * |
||
194 | * @return void |
||
195 | */ |
||
196 | final private static function arrayize(array &$array, $key) |
||
209 | |||
210 | /** |
||
211 | * Helper method to flatten a multi-dimensional array into a single dimensional array whose keys are xpaths. |
||
212 | * |
||
213 | * @param array $array The array to flatten. |
||
214 | * @param string $prefix The prefix to recursively add to the flattened keys. |
||
215 | * |
||
216 | * @return array |
||
217 | */ |
||
218 | final private static function flatten(array $array, $prefix = '') |
||
238 | } |
||
239 |