Skip to content

Commit b1d0321

Browse files
[Intl] Add Currencies::getCashFractionDigits() and Currencies::getCashRoundingIncrement()
1 parent 798b9f4 commit b1d0321

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.3
5+
---
6+
7+
* Add `Currencies::getCashFractionDigits()` and `Currencies::getCashRoundingIncrement()`
8+
49
5.0.0
510
-----
611

Currencies.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ final class Currencies extends ResourceBundle
2525
private const INDEX_NAME = 1;
2626
private const INDEX_FRACTION_DIGITS = 0;
2727
private const INDEX_ROUNDING_INCREMENT = 1;
28+
private const INDEX_CASH_FRACTION_DIGITS = 2;
29+
private const INDEX_CASH_ROUNDING_INCREMENT = 3;
2830

2931
/**
3032
* @return string[]
@@ -94,10 +96,7 @@ public static function getFractionDigits(string $currency): int
9496
}
9597
}
9698

97-
/**
98-
* @return float|int
99-
*/
100-
public static function getRoundingIncrement(string $currency)
99+
public static function getRoundingIncrement(string $currency): int
101100
{
102101
try {
103102
return self::readEntry(['Meta', $currency, self::INDEX_ROUNDING_INCREMENT], 'meta');
@@ -106,6 +105,24 @@ public static function getRoundingIncrement(string $currency)
106105
}
107106
}
108107

108+
public static function getCashFractionDigits(string $currency): int
109+
{
110+
try {
111+
return self::readEntry(['Meta', $currency, self::INDEX_CASH_FRACTION_DIGITS], 'meta');
112+
} catch (MissingResourceException $e) {
113+
return self::readEntry(['Meta', 'DEFAULT', self::INDEX_CASH_FRACTION_DIGITS], 'meta');
114+
}
115+
}
116+
117+
public static function getCashRoundingIncrement(string $currency): int
118+
{
119+
try {
120+
return self::readEntry(['Meta', $currency, self::INDEX_CASH_ROUNDING_INCREMENT], 'meta');
121+
} catch (MissingResourceException $e) {
122+
return self::readEntry(['Meta', 'DEFAULT', self::INDEX_CASH_ROUNDING_INCREMENT], 'meta');
123+
}
124+
}
125+
109126
/**
110127
* @throws MissingResourceException if the currency code has no numeric code
111128
*/

0 commit comments

Comments
 (0)