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

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