money
money copied to clipboard
Default Currency
Hi,
First of all, apologise for creating an issue as this is rather a question.
Is there a way to predefine / set default currency ?
I'm dealing only with a single currency and having to call Money::of() with currency parameter isn't needed in my situation.
Since class is final, I cannot obviously extend from it and I don't see any other option than set currency every time.
I believe that Money being currency agnostic might also be helpful for some people.
Any advice would be greatly appreciated.
Thanks
What about a custom "static decoration"? Something like this:
final class DefaultMoney
{
public static function of(
BigNumber|int|float|string $amount,
?Context $context = null,
RoundingMode $roundingMode = RoundingMode::UNNECESSARY,
): Money {
return BrickMoney::of($amount, 'GBP', $context, $roundingMode);
}
}