Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions app/Models/Configs.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,27 @@ public function sanity(?string $candidate_value, ?string $message_template = nul
}
break;
case ConfigType::CURRENCY->value:
$bundle = \ResourceBundle::create('en', 'ICUDATA-curr');
$currencies = $bundle->get('Currencies');
$found = false;
foreach ($currencies as $code => $data) {
$found = ($code === $candidate_value);
if ($found) {
break; // we found it, stop searching
try {
$bundle = \ResourceBundle::create('en', 'ICUDATA-curr');
$currencies = $bundle->get('Currencies');
$found = false;
foreach ($currencies as $code => $data) {
$found = ($code === $candidate_value);
if ($found) {
break; // we found it, stop searching
}
}
if (!$found) {
$message = sprintf($message_template, 'a valid ISO 4217 currency code');
break;
}
}
if (!$found) {
$message = sprintf($message_template, 'a valid ISO 4217 currency code');
break;
} catch (\Throwable) {
// @codeCoverageIgnoreStart
$message = 'php-intl extension is missing. Cannot validate currency code.';
break;
// @codeCoverageIgnoreEnd
}
break;
case ConfigType::MAP_PROVIDER->value:
if (MapProviders::tryFrom($candidate_value) === null) {
$message = sprintf($message_template, 'a valid map provider');
Expand Down