Skip to content

Commit 2c55be1

Browse files
committed
Fix custom list in currencies
1 parent 457d64c commit 2c55be1

File tree

2 files changed

+9
-137
lines changed

2 files changed

+9
-137
lines changed

src/Currency.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class Currency
2626
public const LIST_CUSTOM = 'custom';
2727
public const LIST_CONFIG = 'config';
2828

29+
public const LISTS = [
30+
self::LIST_ALL,
31+
self::LIST_POPULAR,
32+
self::LIST_CUSTOM,
33+
self::LIST_CONFIG,
34+
];
35+
2936
private const CONFIG_LIST = 'money.currency_list';
3037
private const CONFIG_CUSTOM = 'money.custom_currencies';
3138

@@ -192,21 +199,13 @@ public static function getCurrencies(): array
192199

193200
public static function isIncorrectList(string $list): bool
194201
{
195-
return !in_array(
196-
$list,
197-
[
198-
self::LIST_ALL,
199-
self::LIST_POPULAR,
200-
self::LIST_CONFIG,
201-
self::LIST_CONFIG,
202-
]
203-
);
202+
return !in_array($list, self::LISTS);
204203
}
205204

206205
public static function setCurrencyList(string $list = self::LIST_POPULAR): void
207206
{
208207
if (self::isIncorrectList($list)) {
209-
$list = self::LIST_POPULAR;
208+
throw new CurrencyListConfigException($list);
210209
}
211210
self::$list = $list;
212211

tests/Feature/CurrencyListsTest.php

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)