Improve discernable type safety in MDMailerHelper

This commit is contained in:
Joshua Ramon Enslin 2020-11-16 19:38:03 +01:00
parent c75eb5eb03
commit 25473f17de
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -23,7 +23,7 @@ final class MDMailerHelper {
public static function pgp_encrypt(string $to, string $msg):string {
$gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_EXCEPTION);
$gpg->seterrormode(GNUPG_ERROR_EXCEPTION);
if (empty($recipients = $gpg->keyinfo($to))) {
throw new \Exception("Cannot retrieve public key of recipient for GPG encryption");
@ -42,7 +42,7 @@ final class MDMailerHelper {
throw new \Exception("Cannot set private key for GPG encryption");
}
if (($msg = $gpg->encrypt($msg)) === false) {
if (empty($msg = $gpg->encrypt($msg))) {
throw new \Exception("Failed to sign and encrypt the message");
}