Closed Legion112 closed 1 year ago
I found solution by using IntlFormatter:
$formatter = new \NumberFormatter('en-US', \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 8);
$formatter->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, 8);
$formatter->setAttribute(\NumberFormatter::ROUNDING_MODE, \NumberFormatter::ROUND_UP);
return new IntlMoneyFormatter($formatter, $formatter);
I have specific business requirements for the MoneyFormatting interface I am implementing.
It should round all Money objects to 8 digits after the decimal point and print it. How could I achieve this? What is the reason the Money::round function is private? Do I need to use some Round interface to round money class?