From c856dc298151e4098cc8aad5a7434891f72189a8 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 24 Sep 2024 17:42:47 +1200 Subject: [PATCH] ENH Use symfony/validation logic --- src/Tasks/ContentReviewEmails.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Tasks/ContentReviewEmails.php b/src/Tasks/ContentReviewEmails.php index 2131796..efb8f30 100644 --- a/src/Tasks/ContentReviewEmails.php +++ b/src/Tasks/ContentReviewEmails.php @@ -30,7 +30,7 @@ class ContentReviewEmails extends BuildTask */ public function run($request) { - if (!$this->isValidEmail($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) { + if (!Email::is_valid_address($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) { throw new RuntimeException( sprintf( 'Provided sender email address is invalid: "%s".', @@ -116,7 +116,7 @@ class ContentReviewEmails extends BuildTask $siteConfig = SiteConfig::current_site_config(); $owner = Member::get()->byID($ownerID); - if (!$this->isValidEmail($owner->Email)) { + if (!Email::is_valid_address($owner->Email)) { $this->invalid_emails[] = $owner->Name . ': ' . $owner->Email; return; @@ -188,12 +188,4 @@ class ContentReviewEmails extends BuildTask 'ToEmail' => $recipient->Email, ]; } - - /** - * Check validity of email - */ - protected function isValidEmail(?string $email): bool - { - return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); - } }