Use exception instead of early return

[MAILPOET-4047]
This commit is contained in:
Jan Lysý
2022-02-28 19:22:56 +01:00
committed by Veljko V
parent c6dd519a4b
commit 15877215d1
2 changed files with 8 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ namespace MailPoet\Cron\Workers\KeyCheck;
use MailPoet\Config\ServicesChecker;
use MailPoet\Cron\CronWorkerScheduler;
use MailPoet\InvalidStateException;
use MailPoet\Mailer\Mailer;
use MailPoet\Mailer\MailerLog;
use MailPoet\Services\Bridge;
@@ -47,7 +48,9 @@ class SendingServiceKeyCheck extends KeyCheckWorker {
public function checkKey() {
// for phpstan because we set bridge property in the init function
if (!$this->bridge) return;
if (!$this->bridge) {
throw new InvalidStateException('The class was not initialized properly. Please call the Init method before.');
};
$wasPendingApproval = $this->servicesChecker->isMailPoetAPIKeyPendingApproval();