Closed kunicmarko20 closed 5 years ago
Another option is exposing the whole array and I can do that in my code, but getCurrencies
is private and getIterator
doesn't give numeric codes
I'm not 100% sure about the exact place, but I believe that you can loop using an iterator with the foreach ($iterator as $key => $value) {...}
syntax. However, I'm wondering what your use-case is and whether the numeric index shouldn't be treated as implementation detail/artifact.
Iterator only returns the letter code:
I am using moneyphp internaly, for money and currencies and I am getting numeric code from a external service, to be able to use currency I need to convert numeric code to letter code as this library checkes only the letter code:
Note that numeric code is used only for ISO currencies and does not exist for all currencies or in the interface.
Yep, what would work for me is having a method that would convert numeric to letter or just exposing the whole array of values. Does one of those 2 sound like a good idea?
I think this outside Money scope. You will have to care of this tourself. You might want to use https://github.com/moneyphp/currencies and create your own map with numeric code as array key.
Can you please elaborate why is it out of scope? Numeric code is also part of ISO 4217.
We don’t want to move towards a currency repository library. This library solves problems with money calculations. If you need to convert currency numeric <-> letter codes, this should happen in your own code.
I agree on the conversion part but a "Currencies" class that validates both letter and number code should probably be a part of the lib.
Something like this https://github.com/alcohol/iso4217/blob/master/ISO4217.php#L26-L35
Don't want to bother you anymore, thank you for replying.
You are free to create a PR. Then we can discuss whether or not we want to merge it.
Hi, I can't find a way to test if the numeric currency code is valid or convert the numeric code.
I am able to provide a PR for this if you think there is a place for this in lib.