@@ 161-188 (lines=28) @@ | ||
158 | /** |
|
159 | * @param \DOMNode|SimpleHtmlDomInterface|string $element HTML code or SimpleHtmlDomInterface, \DOMNode |
|
160 | */ |
|
161 | public function __construct($element = null) |
|
162 | { |
|
163 | $this->document = new \DOMDocument('1.0', $this->getEncoding()); |
|
164 | ||
165 | // DOMDocument settings |
|
166 | $this->document->preserveWhiteSpace = true; |
|
167 | $this->document->formatOutput = true; |
|
168 | ||
169 | if ($element instanceof SimpleHtmlDomInterface) { |
|
170 | $element = $element->getNode(); |
|
171 | } |
|
172 | ||
173 | if ($element instanceof \DOMNode) { |
|
174 | $domNode = $this->document->importNode($element, true); |
|
175 | ||
176 | if ($domNode instanceof \DOMNode) { |
|
177 | /** @noinspection UnusedFunctionResultInspection */ |
|
178 | $this->document->appendChild($domNode); |
|
179 | } |
|
180 | ||
181 | return; |
|
182 | } |
|
183 | ||
184 | if ($element !== null) { |
|
185 | /** @noinspection UnusedFunctionResultInspection */ |
|
186 | $this->loadHtml($element); |
|
187 | } |
|
188 | } |
|
189 | ||
190 | /** |
|
191 | * @param string $name |
@@ 57-84 (lines=28) @@ | ||
54 | /** |
|
55 | * @param \DOMNode|SimpleXmlDomInterface|string $element HTML code or SimpleXmlDomInterface, \DOMNode |
|
56 | */ |
|
57 | public function __construct($element = null) |
|
58 | { |
|
59 | $this->document = new \DOMDocument('1.0', $this->getEncoding()); |
|
60 | ||
61 | // DOMDocument settings |
|
62 | $this->document->preserveWhiteSpace = true; |
|
63 | $this->document->formatOutput = true; |
|
64 | ||
65 | if ($element instanceof SimpleXmlDomInterface) { |
|
66 | $element = $element->getNode(); |
|
67 | } |
|
68 | ||
69 | if ($element instanceof \DOMNode) { |
|
70 | $domNode = $this->document->importNode($element, true); |
|
71 | ||
72 | if ($domNode instanceof \DOMNode) { |
|
73 | /** @noinspection UnusedFunctionResultInspection */ |
|
74 | $this->document->appendChild($domNode); |
|
75 | } |
|
76 | ||
77 | return; |
|
78 | } |
|
79 | ||
80 | if ($element !== null) { |
|
81 | $this->loadXml($element); |
|
82 | } |
|
83 | } |
|
84 | ||
85 | /** |
|
86 | * @param string $name |
|
87 | * @param array $arguments |