Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Currency #88

Open
soltmar opened this issue Jun 28, 2024 · 1 comment
Open

Default Currency #88

soltmar opened this issue Jun 28, 2024 · 1 comment

Comments

@soltmar
Copy link

soltmar commented Jun 28, 2024

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

@C3rb
Copy link

C3rb commented Oct 23, 2024

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);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants