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
            /** @noinspection UnusedFunctionResultInspection */
46
            $this->loadXml($element);
47
        }
48
    }
49
50
    /**
51
     * @param string $name

src/voku/helper/HtmlDomParser.php 1 location

@@ 125-152 (lines=28) @@
122
    /**
123
     * @param \DOMNode|SimpleHtmlDomInterface|string $element HTML code or SimpleHtmlDomInterface, \DOMNode
124
     */
125
    public function __construct($element = null)
126
    {
127
        $this->document = new \DOMDocument('1.0', $this->getEncoding());
128
129
        // DOMDocument settings
130
        $this->document->preserveWhiteSpace = true;
131
        $this->document->formatOutput = true;
132
133
        if ($element instanceof SimpleHtmlDomInterface) {
134
            $element = $element->getNode();
135
        }
136
137
        if ($element instanceof \DOMNode) {
138
            $domNode = $this->document->importNode($element, true);
139
140
            if ($domNode instanceof \DOMNode) {
141
                /** @noinspection UnusedFunctionResultInspection */
142
                $this->document->appendChild($domNode);
143
            }
144
145
            return;
146
        }
147
148
        if ($element !== null) {
149
            /** @noinspection UnusedFunctionResultInspection */
150
            $this->loadHtml($element);
151
        }
152
    }
153
154
    /**
155
     * @param string $name