diff --git a/mailpoet/lib/Cron/Workers/KeyCheck/PremiumKeyCheck.php b/mailpoet/lib/Cron/Workers/KeyCheck/PremiumKeyCheck.php index a983508867..71accea43e 100644 --- a/mailpoet/lib/Cron/Workers/KeyCheck/PremiumKeyCheck.php +++ b/mailpoet/lib/Cron/Workers/KeyCheck/PremiumKeyCheck.php @@ -3,6 +3,7 @@ namespace MailPoet\Cron\Workers\KeyCheck; use MailPoet\Cron\CronWorkerScheduler; +use MailPoet\InvalidStateException; use MailPoet\Services\Bridge; use MailPoet\Settings\SettingsController; @@ -26,7 +27,9 @@ class PremiumKeyCheck 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.'); + }; $premiumKey = $this->settings->get(Bridge::PREMIUM_KEY_SETTING_NAME); $result = $this->bridge->checkPremiumKey($premiumKey); diff --git a/mailpoet/lib/Cron/Workers/KeyCheck/SendingServiceKeyCheck.php b/mailpoet/lib/Cron/Workers/KeyCheck/SendingServiceKeyCheck.php index ceb4874ca2..d397e2bd12 100644 --- a/mailpoet/lib/Cron/Workers/KeyCheck/SendingServiceKeyCheck.php +++ b/mailpoet/lib/Cron/Workers/KeyCheck/SendingServiceKeyCheck.php @@ -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();