Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5cfe73d

Browse filesBrowse files
feature #40257 [Intl] Add Currencies::getCashFractionDigits() and Currencies::getCashRoundingIncrement() (nicolas-grekas)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Intl] Add `Currencies::getCashFractionDigits()` and `Currencies::getCashRoundingIncrement()` | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #21247 | License | MIT | Doc PR | - Commits ------- dab91f7 [Intl] Add `Currencies::getCashFractionDigits()` and `Currencies::getCashRoundingIncrement()`
2 parents b8f5b7a + dab91f7 commit 5cfe73d
Copy full SHA for 5cfe73d

File tree

Expand file treeCollapse file tree

2 files changed

+26
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-4
lines changed

‎src/Symfony/Component/Intl/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/CHANGELOG.md
+5Lines 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

‎src/Symfony/Component/Intl/Currencies.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Currencies.php
+21-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.