| @@ 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 |
|
| @@ 45-72 (lines=28) @@ | ||
| 42 | /** |
|
| 43 | * @param \DOMNode|SimpleXmlDomInterface|string $element HTML code or SimpleXmlDomInterface, \DOMNode |
|
| 44 | */ |
|
| 45 | public function __construct($element = null) |
|
| 46 | { |
|
| 47 | $this->document = new \DOMDocument('1.0', $this->getEncoding()); |
|
| 48 | ||
| 49 | // DOMDocument settings |
|
| 50 | $this->document->preserveWhiteSpace = true; |
|
| 51 | $this->document->formatOutput = true; |
|
| 52 | ||
| 53 | if ($element instanceof SimpleXmlDomInterface) { |
|
| 54 | $element = $element->getNode(); |
|
| 55 | } |
|
| 56 | ||
| 57 | if ($element instanceof \DOMNode) { |
|
| 58 | $domNode = $this->document->importNode($element, true); |
|
| 59 | ||
| 60 | if ($domNode instanceof \DOMNode) { |
|
| 61 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 62 | $this->document->appendChild($domNode); |
|
| 63 | } |
|
| 64 | ||
| 65 | return; |
|
| 66 | } |
|
| 67 | ||
| 68 | if ($element !== null) { |
|
| 69 | $this->loadXml($element); |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @param string $name |
|
| 75 | * @param array $arguments |
|