src/PrivateKey.php
/**
     * @param Closure $function
     * @return mixed
     * @throws RuntimeException when cannot open the public key from certificate
     */
@param Closure $function
@return mixed
@throws RuntimeException when cannot open the public key from certificate
@param Closure $function @return mixed @throws RuntimeException when cannot open the public key from certificate
public function callOnPrivateKey(Closure $function)
    {
        $privateKey = openssl_get_privatekey($this->pem(), $this->passPhrase());
        if (false === $privateKey) {
            throw new RuntimeException('Cannot open private key: ' . openssl_error_string());
        }
        try {
            return call_user_func($function, $privateKey);
        } finally {
            if (PHP_VERSION_ID < 80000) {
                openssl_free_key($privateKey);
            }
        }
    }
public function callOnPrivateKey ( Closure $ function ) { $ privateKey = openssl_get_privatekey ( $ this -> pem ( ) , $ this -> passPhrase ( ) ) ; if ( false === $ privateKey ) { throw new RuntimeException ( 'Cannot open private key: ' . openssl_error_string ( ) ) ; } try { return call_user_func ( $ function , $ privateKey ) ; } finally { if ( PHP_VERSION_ID < 80000 ) { openssl_free_key ( $ privateKey ) ; } } }
@param Closure $function
 @return mixed
 @throws RuntimeException when cannot open the public key from certificate
@param Closure $function @return mixed @throws RuntimeException when cannot open the public key from certificate
// phpcs:disable Generic.PHP.DeprecatedFunctions.Deprecated // phpcs:enable