Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit e8d058b

Browse files
author
Jens Schulze
committed
feat(CurrencyFormatter): change currencyFormatter to use fraction digits from intl extension
1 parent 23c2de5 commit e8d058b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Helper/CurrencyFormatter.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public function __construct(Context $context)
2525
*/
2626
protected function defaultFormatCallback($centAmount, $currency)
2727
{
28-
$amount = $centAmount / 100;
29-
$currency = mb_strtoupper($currency);
3028
$locale = $this->context->getLocale();
31-
3229
$formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
30+
$fractionUnits = pow(10, $formatter->getAttribute(\NumberFormatter::FRACTION_DIGITS));
31+
$amount = $centAmount / $fractionUnits;
32+
$currency = strtoupper($currency);
33+
3334
return $formatter->formatCurrency($amount, $currency);
3435
}
3536

0 commit comments

Comments
 (0)