Code Duplication    Length = 18-18 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 1 location

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

src/voku/helper/SimpleXmlDom.php 1 location

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