Code Duplication    Length = 28-28 lines in 2 locations

src/voku/helper/XmlDomParser.php 1 location

@@ 21-48 (lines=28) @@
18
    /**
19
     * @param \DOMNode|SimpleXmlDomInterface|string $element HTML code or SimpleXmlDomInterface, \DOMNode
20
     */
21
    public function __construct($element = null)
22
    {
23
        $this->document = new \DOMDocument('1.0', $this->getEncoding());
24
25
        // DOMDocument settings
26
        $this->document->preserveWhiteSpace = true;
27
        $this->document->formatOutput = true;
28
29
        if ($element instanceof SimpleXmlDomInterface) {
30
            $element = $element->getNode();
31
        }
32
33
        if ($element instanceof \DOMNode) {
34
            $domNode = $this->document->importNode($element, true);
35
36
            if ($domNode instanceof \DOMNode) {
37
                /** @noinspection UnusedFunctionResultInspection */
38
                $this->document->appendChild($domNode);
39
            }
40
41
            return;
42
        }
43
44
        if ($element !== null) {
45
            $this->loadXml($element);
46
        }
47
    }
48
49
    /**
50
     * @param string $name
51
     * @param array  $arguments

src/voku/helper/HtmlDomParser.php 1 location

@@ 147-174 (lines=28) @@
144
    /**
145
     * @param \DOMNode|SimpleHtmlDomInterface|string $element HTML code or SimpleHtmlDomInterface, \DOMNode
146
     */
147
    public function __construct($element = null)
148
    {
149
        $this->document = new \DOMDocument('1.0', $this->getEncoding());
150
151
        // DOMDocument settings
152
        $this->document->preserveWhiteSpace = true;
153
        $this->document->formatOutput = true;
154
155
        if ($element instanceof SimpleHtmlDomInterface) {
156
            $element = $element->getNode();
157
        }
158
159
        if ($element instanceof \DOMNode) {
160
            $domNode = $this->document->importNode($element, true);
161
162
            if ($domNode instanceof \DOMNode) {
163
                /** @noinspection UnusedFunctionResultInspection */
164
                $this->document->appendChild($domNode);
165
            }
166
167
            return;
168
        }
169
170
        if ($element !== null) {
171
            /** @noinspection UnusedFunctionResultInspection */
172
            $this->loadHtml($element);
173
        }
174
    }
175
176
    /**
177
     * @param string $name