Use exception instead of early return
[MAILPOET-4047]
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace MailPoet\Cron\Workers\KeyCheck;
|
namespace MailPoet\Cron\Workers\KeyCheck;
|
||||||
|
|
||||||
use MailPoet\Cron\CronWorkerScheduler;
|
use MailPoet\Cron\CronWorkerScheduler;
|
||||||
|
use MailPoet\InvalidStateException;
|
||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
|
|
||||||
@@ -26,7 +27,9 @@ class PremiumKeyCheck extends KeyCheckWorker {
|
|||||||
|
|
||||||
public function checkKey() {
|
public function checkKey() {
|
||||||
// for phpstan because we set bridge property in the init function
|
// 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);
|
$premiumKey = $this->settings->get(Bridge::PREMIUM_KEY_SETTING_NAME);
|
||||||
$result = $this->bridge->checkPremiumKey($premiumKey);
|
$result = $this->bridge->checkPremiumKey($premiumKey);
|
||||||
|
@@ -4,6 +4,7 @@ namespace MailPoet\Cron\Workers\KeyCheck;
|
|||||||
|
|
||||||
use MailPoet\Config\ServicesChecker;
|
use MailPoet\Config\ServicesChecker;
|
||||||
use MailPoet\Cron\CronWorkerScheduler;
|
use MailPoet\Cron\CronWorkerScheduler;
|
||||||
|
use MailPoet\InvalidStateException;
|
||||||
use MailPoet\Mailer\Mailer;
|
use MailPoet\Mailer\Mailer;
|
||||||
use MailPoet\Mailer\MailerLog;
|
use MailPoet\Mailer\MailerLog;
|
||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
@@ -47,7 +48,9 @@ class SendingServiceKeyCheck extends KeyCheckWorker {
|
|||||||
|
|
||||||
public function checkKey() {
|
public function checkKey() {
|
||||||
// for phpstan because we set bridge property in the init function
|
// 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();
|
$wasPendingApproval = $this->servicesChecker->isMailPoetAPIKeyPendingApproval();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user