src/CfdiUtils/Certificado/NodeCertificado.php
public function extract(): string
    {
        $version = $this->getVersion();
        if ('3.2' === $version) {
            $attr = 'certificado';
        } elseif ('3.3' === $version) {
            $attr = 'Certificado';
        } else {
            throw new \RuntimeException('Unsupported or unknown version');
        }
        $certificateBase64 = $this->comprobante->searchAttribute($attr);
        if ('' === $certificateBase64) {
            return '';
        }

        $certificateBin = (string) base64_decode($certificateBase64, true);
        if ('' === $certificateBin) {
            throw new \RuntimeException('The certificado attribute is not a valid base64 encoded string');
        }

        return $certificateBin;
    }
public function extract(): string
    {
        $version = $this->getVersion();
        if ('3.2' === $version) {
            $attr = 'certificado';
        } elseif ('3.3' === $version) {
            $attr = 'Certificado';
        } else {
            throw new \RuntimeException('Unsupported or unknown version');
        }
        $certificateBase64 = $this->comprobante->searchAttribute($attr);
        if ('' === $certificateBase64) {
            return '';
        }

        $certificateBin = (string) base64_decode($certificateBase64, true);
        if ('' === $certificateBin) {
            throw new \RuntimeException('The certificado attribute is not a valid base64 encoded string');
        }

        return $certificateBin;
    }
public function extract ( ) : string { $ version = $ this -> getVersion ( ) ; if ( '3.2' === $ version ) { $ attr = 'certificado' ; } elseif ( '3.3' === $ version ) { $ attr = 'Certificado' ; } else { throw new \ RuntimeException ( 'Unsupported or unknown version' ) ; } $ certificateBase64 = $ this -> comprobante -> searchAttribute ( $ attr ) ; if ( '' === $ certificateBase64 ) { return '' ; } $ certificateBin = ( string ) base64_decode ( $ certificateBase64 , true ) ; if ( '' === $ certificateBin ) { throw new \ RuntimeException ( 'The certificado attribute is not a valid base64 encoded string' ) ; } return $ certificateBin ; }
Extract the certificate from Comprobante->certificado
If the node does not exists return an empty string
The returned string is no longer base64 encoded

@return string

@throws \RuntimeException if the certificado attribute is not a valid base64 encoded string
Extract the certificate from Comprobante - > certificado If the node does not exists return an empty string The returned string is no longer base64 encoded