level, $xmlerror->code, trim( $xmlerror->message ) ); } libxml_clear_errors(); throw new XmlMarkupParseErrorException( $errors ); } return $xml; } protected static function logXmlParseError( $level, $code, $message ) { LoggerFactory::getInstance( 'PortableInfobox' )->info( 'PortableInfobox XML Parser problem', [ 'level' => $level, 'code' => $code, 'message' => $message ] ); } /** * @param string $xmlString * * @return mixed */ protected static function prepareXml( $xmlString ) { foreach ( self::$contentTags as $tag ) { // wrap content in CDATA for content tags $xmlString = preg_replace( '|(<' . $tag . '.*>)(.*)()|sU', '$1$3', $xmlString ); } $decoded = str_replace( '&', '&', html_entity_decode( $xmlString ) ); return $decoded; } } // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound class XmlMarkupParseErrorException extends Exception { private $errors; public function __construct( $errors ) { $this->errors = $errors; parent::__construct(); } public function getErrors() { return $this->errors; } }