From 1475ba9c252bc7902268f2a9551a47bd2af54f2b Mon Sep 17 00:00:00 2001 From: Abdelrahman Omran Date: Mon, 4 Oct 2021 02:38:00 +0400 Subject: [PATCH] Fix issues with currencies longlist retrieval (fix #167) --- src/CurrencyLoader.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/CurrencyLoader.php b/src/CurrencyLoader.php index e3b1778..2dcc4f1 100644 --- a/src/CurrencyLoader.php +++ b/src/CurrencyLoader.php @@ -27,20 +27,18 @@ public static function currencies($longlist = false): array foreach ($countries as $country) { if ($longlist) { foreach ($country['currency'] as $currency => $details) { - static::$currencies[$list][$currency] = $longlist ? $details : $currency; + ! $currency || static::$currencies[$list][$currency] = $longlist ? $details : $currency; } } else { - static::$currencies[$list][] = $country['currency']; + ! $country['currency'] || static::$currencies[$list][$country['currency']] = $country['currency']; } } } - $currencies = array_filter(array_unique(static::$currencies[$list]), function ($item) { - return is_string($item); - }); + $currencies = static::$currencies[$list]; - sort($currencies); + ksort($currencies); - return array_combine($currencies, $currencies); + return $currencies; } }