Code Duplication    Length = 25-25 lines in 2 locations

src/voku/helper/AbstractDomParser.php 1 location

@@ 352-376 (lines=25) @@
349
     *
350
     * @return string
351
     */
352
    public function xml(
353
        bool $multiDecodeNewHtmlEntity = false,
354
        bool $htmlToXml = true,
355
        bool $removeXmlHeader = true,
356
        int $options = \LIBXML_NOEMPTYTAG
357
    ): string {
358
        $xml = $this->document->saveXML(null, $options);
359
        if ($xml === false) {
360
            return '';
361
        }
362
363
        if ($removeXmlHeader) {
364
            $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml));
365
        }
366
367
        if ($htmlToXml) {
368
            $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity);
369
        } else {
370
            $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity);
371
372
            $return = self::putReplacedBackToPreserveHtmlEntities($xml);
373
        }
374
375
        return $return;
376
    }
377
378
    /**
379
     * Get the encoding to use.

src/voku/helper/HtmlDomParser.php 1 location

@@ 846-870 (lines=25) @@
843
     *
844
     * @return string
845
     */
846
    public function xml(
847
        bool $multiDecodeNewHtmlEntity = false,
848
        bool $htmlToXml = true,
849
        bool $removeXmlHeader = true,
850
        int $options = \LIBXML_NOEMPTYTAG
851
    ): string {
852
        $xml = $this->document->saveXML(null, $options);
853
        if ($xml === false) {
854
            return '';
855
        }
856
857
        if ($removeXmlHeader) {
858
            $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml));
859
        }
860
861
        if ($htmlToXml) {
862
            $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity);
863
        } else {
864
            $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity);
865
866
            $return = self::putReplacedBackToPreserveHtmlEntities($xml);
867
        }
868
869
        return $return;
870
    }
871
872
    /**
873
     * @param string $selector