1 | <?php |
||
23 | class DocumentFragment |
||
24 | extends \DOMDocumentFragment |
||
25 | implements |
||
26 | \Countable, |
||
27 | \IteratorAggregate, |
||
28 | Node, |
||
29 | Node\ParentNode { |
||
30 | |||
31 | use |
||
32 | /** @noinspection TraitsPropertiesConflictsInspection */ |
||
33 | Node\ParentNode\Properties, |
||
34 | Node\QuerySelector\Implementation, |
||
35 | /** @noinspection TraitsPropertiesConflictsInspection */ |
||
36 | Node\Xpath; |
||
37 | |||
38 | /** |
||
39 | * @var Namespaces |
||
40 | */ |
||
41 | private $_namespaces; |
||
42 | |||
43 | /** |
||
44 | * Casting the fragment to string will return the text content of all nodes |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | 1 | public function __toString(): string { |
|
55 | |||
56 | /** |
||
57 | * @return int |
||
58 | */ |
||
59 | 1 | public function count(): int { |
|
62 | |||
63 | /** |
||
64 | * @return \Iterator |
||
65 | */ |
||
66 | 1 | public function getIterator(): \Iterator { |
|
69 | |||
70 | /** |
||
71 | * Get/Set the namespace definition used for the fragment strings. |
||
72 | * |
||
73 | * You can use an [prefix => $namespaceURI, ...] or an element node |
||
74 | * to set the namespaces. If the list is empty, the namespaces from |
||
75 | * the document object will be used. |
||
76 | * |
||
77 | * @param NULL|array|\Traversable|\DOMElement $namespaces |
||
78 | * @return Namespaces |
||
79 | * @throws \InvalidArgumentException |
||
80 | */ |
||
81 | 18 | public function namespaces($namespaces = NULL): Namespaces { |
|
112 | |||
113 | /** |
||
114 | * Register a namespace prefix to use it in appendXml() |
||
115 | * |
||
116 | * @param string $prefix |
||
117 | * @param string $namespaceURI |
||
118 | * @throws \InvalidArgumentException |
||
119 | */ |
||
120 | 6 | public function registerNamespace(string $prefix, string $namespaceURI) { |
|
123 | |||
124 | /** |
||
125 | * Append an xml to the fragment, it can use namespace prefixes defined on the fragment object. |
||
126 | * |
||
127 | * @param string $data |
||
128 | * @param NULL|array|\Traversable|\DOMElement $namespaces |
||
129 | * @return bool |
||
130 | * @throws \InvalidArgumentException |
||
131 | */ |
||
132 | 18 | public function appendXml($data, $namespaces = NULL): bool { |
|
153 | |||
154 | /** |
||
155 | * Append an child element |
||
156 | * |
||
157 | * @param string $name |
||
158 | * @param string $content |
||
159 | * @param array $attributes |
||
160 | * @return Element |
||
161 | * @throws \LogicException |
||
162 | */ |
||
163 | 1 | public function appendElement(string $name, $content = '', array $attributes = NULL): Element { |
|
169 | |||
170 | |||
171 | /** |
||
172 | * Save as XML string |
||
173 | * |
||
174 | * @return string |
||
175 | */ |
||
176 | 3 | public function saveXmlFragment(): string { |
|
179 | } |
||
180 | } |
||
182 |