From dab91f78e18beb27eb5a81eca8c33821ec4bf163 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 19 Feb 2021 16:39:40 +0100 Subject: [PATCH] [Intl] Add `Currencies::getCashFractionDigits()` and `Currencies::getCashRoundingIncrement()` --- src/Symfony/Component/Intl/CHANGELOG.md | 5 +++++ src/Symfony/Component/Intl/Currencies.php | 25 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Intl/CHANGELOG.md b/src/Symfony/Component/Intl/CHANGELOG.md index b7fb561e7c080..012a894c50179 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 c155c8f09f425..60dbfcd6f1d36 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 */ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy