<?php

namespace Daniv04\HaciendaPackage\Traits;

trait XmlBase64DecoderTrait
{
    /**
     * Decode base64 encoded XML from Hacienda response
     *
     * @param string $base64EncodedXml
     * @return string|false Returns decoded XML string or false on failure
     */
    public function decodeBase64Xml(string $base64EncodedXml): string|false
    {
        try {
            $decodedBytes = base64_decode($base64EncodedXml, strict: true);
            
            if ($decodedBytes === false) {
                return false;
            }
            return $decodedBytes;
        } catch (\Exception $e) {
            return false;
        }
    }

   
}
