sets a default formatter that will be applied by default to all monetary objects.
use PostScripton\Money\Enums\CurrencyDisplay;
use PostScripton\Money\Formatters\DefaultMoneyFormatter;
use PostScripton\Money\Money;
$newFormatter = (new DefaultMoneyFormatter())
->useCurrency()
->displayCurrencyAs(CurrencyDisplay::Code)
->spaceBetweenCurrencyAndAmount()
->thousandsSeparator('')
->decimalSeparator('.')
->decimals(2)
->endsWithZero();
Money::setFormatter($newFormatter);
$money = money_parse('$ 1234.5');
$money->toString(); // "USD 1234.50"
👀 See here for full details.
📌 Back to the contents.