moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.63k stars 441 forks source link

Allow numeric code #537

Closed kunicmarko20 closed 5 years ago

kunicmarko20 commented 5 years ago

This is one way of doing it, an alternative would be providing new "Currencies" class that can handle both and deprecating this one, but since this is not a BC Break I don't think that is needed.

kunicmarko20 commented 5 years ago

If this gets accepted, the only other thing I would propose is adding alphabeticCodeFor since there is numericCodeFor

kunicmarko20 commented 5 years ago

@frederikbosch is there any chance to get some feedback on this and maybe include it into the next release?

frederikbosch commented 5 years ago

It might be included in the next release feature release (3.3.x), not in the proposed 3.2.1.

@sagikazarmark What do you think of this feature? Basically the wish is to use numeric codes as Currency, like below.

$currencies = new ISOCurrencies();
$money = new Money(100, new Currency(123));
$currencies->contains($money->getCurrency()); // also checks against numeric code

Right @kunicmarko20?

If we want to have this feature, should we change the code of ISOCurrencies or should there be a new NumericISOCurrencies class? My feeling is that the latter is a better solution.

kunicmarko20 commented 5 years ago

The ideal thing would be to support both numeric and alphanumeric and not separately. That is why I provided it this way, and left the initial comment as an alternative would be providing new "Currencies" class that can handle both since the numeric is also part of the ISO.