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

Commit

Permalink
feat(CurrencyFormatter): change currencyFormatter to use fraction dig…
Browse files Browse the repository at this point in the history
…its from intl extension
  • Loading branch information
Jens Schulze committed Nov 4, 2015
1 parent 23c2de5 commit e8d058b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Helper/CurrencyFormatter.php
Original file line number Diff line number Diff line change
@@ -25,11 +25,12 @@ public function __construct(Context $context)
*/
protected function defaultFormatCallback($centAmount, $currency)
{
$amount = $centAmount / 100;
$currency = mb_strtoupper($currency);
$locale = $this->context->getLocale();

$formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
$fractionUnits = pow(10, $formatter->getAttribute(\NumberFormatter::FRACTION_DIGITS));
$amount = $centAmount / $fractionUnits;
$currency = strtoupper($currency);

return $formatter->formatCurrency($amount, $currency);
}

0 comments on commit e8d058b

Please # to comment.