Code Duplication    Length = 18-18 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 1 location

@@ 265-282 (lines=18) @@
262
     *
263
     * @return SimpleHtmlDomInterface
264
     */
265
    protected function replaceTextWithString($string): SimpleHtmlDomInterface
266
    {
267
        if (empty($string)) {
268
            $this->node->parentNode->removeChild($this->node);
269
270
            return $this;
271
        }
272
273
        $ownerDocument = $this->node->ownerDocument;
274
        if ($ownerDocument !== null) {
275
            $newElement = $ownerDocument->createTextNode($string);
276
            $newNode = $ownerDocument->importNode($newElement, true);
277
            $this->node->parentNode->replaceChild($newNode, $this->node);
278
            $this->node = $newNode;
279
        }
280
281
        return $this;
282
    }
283
284
    /**
285
     * Set attribute value.

src/voku/helper/SimpleXmlDom.php 1 location

@@ 227-244 (lines=18) @@
224
     *
225
     * @return SimpleXmlDomInterface
226
     */
227
    protected function replaceTextWithString($string): SimpleXmlDomInterface
228
    {
229
        if (empty($string)) {
230
            $this->node->parentNode->removeChild($this->node);
231
232
            return $this;
233
        }
234
235
        $ownerDocument = $this->node->ownerDocument;
236
        if ($ownerDocument !== null) {
237
            $newElement = $ownerDocument->createTextNode($string);
238
            $newNode = $ownerDocument->importNode($newElement, true);
239
            $this->node->parentNode->replaceChild($newNode, $this->node);
240
            $this->node = $newNode;
241
        }
242
243
        return $this;
244
    }
245
246
    /**
247
     * Set attribute value.