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

@@ 785-809 (lines=25) @@
782
     *
783
     * @return string
784
     */
785
    public function xml(
786
        bool $multiDecodeNewHtmlEntity = false,
787
        bool $htmlToXml = true,
788
        bool $removeXmlHeader = true,
789
        int $options = \LIBXML_NOEMPTYTAG
790
    ): string {
791
        $xml = $this->document->saveXML(null, $options);
792
        if ($xml === false) {
793
            return '';
794
        }
795
796
        if ($removeXmlHeader) {
797
            $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml));
798
        }
799
800
        if ($htmlToXml) {
801
            $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity);
802
        } else {
803
            $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity);
804
805
            $return = self::putReplacedBackToPreserveHtmlEntities($xml);
806
        }
807
808
        return $return;
809
    }
810
811
    /**
812
     * @param string $selector