Code Duplication    Length = 18-18 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 1 location

@@ 288-305 (lines=18) @@
285
     *
286
     * @return SimpleHtmlDomInterface
287
     */
288
    protected function replaceTextWithString($string): SimpleHtmlDomInterface
289
    {
290
        if (empty($string)) {
291
            $this->node->parentNode->removeChild($this->node);
292
293
            return $this;
294
        }
295
296
        $ownerDocument = $this->node->ownerDocument;
297
        if ($ownerDocument !== null) {
298
            $newElement = $ownerDocument->createTextNode($string);
299
            $newNode = $ownerDocument->importNode($newElement, true);
300
            $this->node->parentNode->replaceChild($newNode, $this->node);
301
            $this->node = $newNode;
302
        }
303
304
        return $this;
305
    }
306
307
    /**
308
     * Set attribute value.

src/voku/helper/SimpleXmlDom.php 1 location

@@ 250-267 (lines=18) @@
247
     *
248
     * @return SimpleXmlDomInterface
249
     */
250
    protected function replaceTextWithString($string): SimpleXmlDomInterface
251
    {
252
        if (empty($string)) {
253
            $this->node->parentNode->removeChild($this->node);
254
255
            return $this;
256
        }
257
258
        $ownerDocument = $this->node->ownerDocument;
259
        if ($ownerDocument !== null) {
260
            $newElement = $ownerDocument->createTextNode($string);
261
            $newNode = $ownerDocument->importNode($newElement, true);
262
            $this->node->parentNode->replaceChild($newNode, $this->node);
263
            $this->node = $newNode;
264
        }
265
266
        return $this;
267
    }
268
269
    /**
270
     * Set attribute value.