src/CfdiUtils/Certificado/NodeCertificado.php
public function save(string $filename)
    {
        if ('' === $filename) {
            throw new \UnexpectedValueException('The filename to store the certificate is empty');
        }
        $certificado = $this->extract();
        if ('' === $certificado) {
            throw new \RuntimeException('The certificado attribute is empty');
        }
        try {
            if (false === file_put_contents($filename, $certificado)) {
                throw new \RuntimeException('file_put_contents returns FALSE');
            }
        } catch (\Throwable $error) {
            throw new \RuntimeException("Unable to write the certificate contents into $filename", 0, $error);
        }
    }
public function save(string $filename)
    {
        if ('' === $filename) {
            throw new \UnexpectedValueException('The filename to store the certificate is empty');
        }
        $certificado = $this->extract();
        if ('' === $certificado) {
            throw new \RuntimeException('The certificado attribute is empty');
        }
        try {
            if (false === file_put_contents($filename, $certificado)) {
                throw new \RuntimeException('file_put_contents returns FALSE');
            }
        } catch (\Throwable $error) {
            throw new \RuntimeException("Unable to write the certificate contents into $filename", 0, $error);
        }
    }
public function save ( string $ filename ) { if ( '' === $ filename ) { throw new \ UnexpectedValueException ( 'The filename to store the certificate is empty' ) ; } $ certificado = $ this -> extract ( ) ; if ( '' === $ certificado ) { throw new \ RuntimeException ( 'The certificado attribute is empty' ) ; } try { if ( false === file_put_contents ( $ filename , $ certificado ) ) { throw new \ RuntimeException ( 'file_put_contents returns FALSE' ) ; } } catch ( \ Throwable $ error ) { throw new \ RuntimeException ( "Unable to write the certificate contents into $filename" , 0 , $ error ) ; } }
Extract and save the certificate into an specified location

@see extract

@param string $filename
@return void

@throws \UnexpectedValueException if the filename to store the certificate is empty
@throws \RuntimeException if the certificado attribute is empty
@throws \RuntimeException if cannot write the contents of the certificate
Extract and save the certificate into an specified location