From 8debcc57037c21e7e45d9f4c9439079e6b80a15d Mon Sep 17 00:00:00 2001 From: Propaganistas Date: Thu, 26 Jan 2023 14:02:08 +0100 Subject: [PATCH] Fix lowercase validation --- src/Traits/ParsesCountries.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Traits/ParsesCountries.php b/src/Traits/ParsesCountries.php index cbf4d09..cb1dd9b 100644 --- a/src/Traits/ParsesCountries.php +++ b/src/Traits/ParsesCountries.php @@ -15,7 +15,7 @@ trait ParsesCountries */ public static function isValidCountryCode($country) { - return in_array($country, PhoneNumberUtil::getInstance()->getSupportedRegions()); + return in_array(strtoupper($country), array_map('strtoupper', PhoneNumberUtil::getInstance()->getSupportedRegions())); } /** @@ -31,11 +31,10 @@ protected function parseCountries($countries) /** @phpstan-ignore-next-line */ return is_null($value); }) - ->map(function ($country) { - return strtoupper($country); - }) ->filter(function ($value) { return static::isValidCountryCode($value); + })->map(function ($value) { + return strtoupper($value); })->toArray(); } }