diff --git a/src/Symfony/Component/Intl/CHANGELOG.md b/src/Symfony/Component/Intl/CHANGELOG.md index b7fb561e7c08..012a894c5017 100644 --- a/src/Symfony/Component/Intl/CHANGELOG.md +++ b/src/Symfony/Component/Intl/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.3 +--- + + * Add `Currencies::getCashFractionDigits()` and `Currencies::getCashRoundingIncrement()` + 5.0.0 ----- diff --git a/src/Symfony/Component/Intl/Currencies.php b/src/Symfony/Component/Intl/Currencies.php index c155c8f09f42..60dbfcd6f1d3 100644 --- a/src/Symfony/Component/Intl/Currencies.php +++ b/src/Symfony/Component/Intl/Currencies.php @@ -25,6 +25,8 @@ final class Currencies extends ResourceBundle private const INDEX_NAME = 1; private const INDEX_FRACTION_DIGITS = 0; private const INDEX_ROUNDING_INCREMENT = 1; + private const INDEX_CASH_FRACTION_DIGITS = 2; + private const INDEX_CASH_ROUNDING_INCREMENT = 3; /** * @return string[] @@ -94,10 +96,7 @@ public static function getFractionDigits(string $currency): int } } - /** - * @return float|int - */ - public static function getRoundingIncrement(string $currency) + public static function getRoundingIncrement(string $currency): int { try { return self::readEntry(['Meta', $currency, self::INDEX_ROUNDING_INCREMENT], 'meta'); @@ -106,6 +105,24 @@ public static function getRoundingIncrement(string $currency) } } + public static function getCashFractionDigits(string $currency): int + { + try { + return self::readEntry(['Meta', $currency, self::INDEX_CASH_FRACTION_DIGITS], 'meta'); + } catch (MissingResourceException $e) { + return self::readEntry(['Meta', 'DEFAULT', self::INDEX_CASH_FRACTION_DIGITS], 'meta'); + } + } + + public static function getCashRoundingIncrement(string $currency): int + { + try { + return self::readEntry(['Meta', $currency, self::INDEX_CASH_ROUNDING_INCREMENT], 'meta'); + } catch (MissingResourceException $e) { + return self::readEntry(['Meta', 'DEFAULT', self::INDEX_CASH_ROUNDING_INCREMENT], 'meta'); + } + } + /** * @throws MissingResourceException if the currency code has no numeric code */