1
0
Fork 0
mirror of https://github.com/archtechx/money.git synced 2025-12-12 11:24:03 +00:00

Remove trailing zeros from formatted price

This commit is contained in:
David 2022-05-06 10:56:28 +02:00
parent 545610efb0
commit b7093f4f05
No known key found for this signature in database
GPG key ID: EC68B85E411F4753

View file

@ -23,6 +23,12 @@ class PriceFormatter
$currency->thousandsSeparator(),
);
// Remove trailing zeros from price
$decimal = rtrim($decimal, '0');
// If there is no more decimal values, remove the trailing decimal separator as well
$decimal = rtrim($decimal, $currency->decimalSeparator());
return $currency->prefix() . $decimal . $currency->suffix();
}