From d2d495df52f8e7d9dfaa3e1b228d283ec526e0fe Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean <97607754+ddevsr@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:19:46 +0700 Subject: [PATCH 1/2] refactor: cleanup little bit in DNSCheckValidation --- src/Validation/DNSCheckValidation.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index 469e87d..fcfe7db 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -85,8 +85,9 @@ public function isValid(string $email, EmailLexer $emailLexer): bool // Get the domain parts $hostParts = explode('.', $host); - $isLocalDomain = count($hostParts) <= 1; - $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], self::RESERVED_DNS_TOP_LEVEL_NAMES, true); + $countHostParts = count($hostParts); + $isLocalDomain = $countHostParts <= 1; + $isReservedTopLevel = in_array($hostParts[($countHostParts - 1)], self::RESERVED_DNS_TOP_LEVEL_NAMES, true); // Exclude reserved top level DNS names if ($isLocalDomain || $isReservedTopLevel) { From 89e93400ef804bbb991e51c4f21f8e03b585e018 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean <97607754+ddevsr@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:23:16 +0700 Subject: [PATCH 2/2] refactor: remove unused variable --- src/EmailLexer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/EmailLexer.php b/src/EmailLexer.php index a7fdc2d..4e3383a 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -157,9 +157,7 @@ class EmailLexer extends AbstractLexer public function __construct() { - /** @var Token $nullToken */ - $nullToken = new Token('', self::S_EMPTY, 0); - $this->nullToken = $nullToken; + $this->nullToken = new Token('', self::S_EMPTY, 0); $this->current = $this->previous = $this->nullToken; $this->lookahead = null;