-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Conversation
Great work! But I'm worried about the duplication of formatters ( |
That's why iban wasn't public in the first place. It's not a formatter, because not all countries use it. Many other formatters are bound to specific locale. |
True, but it would lead to After looking at the example above again, I have another idea. I could make |
yep, I like your latest suggestion. |
|
{ | ||
$countryCode = strtoupper($countryCode); | ||
$countryCode = is_null($countryCode) ? array_rand(self::$ibanFormats) : strtoupper($countryCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't array_rand
be called on $ibanFormats
keys, instead of values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array_rand
returns the key.
http://php.net/manual/en/function.array-rand.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I've missed that. BTW, maybe self::randomKey() should be used here? @fzaninotto often comments that mt_rand
gives better randomness than lots of built-in shuffling PHP functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, array_rand()
is verboten: it doesn't use the Mersenne Twister randomizer.
Alright, I've switched it to self::randomKey |
Thanks a lot! |
This PR fixes a blocking error:
Could we have a new patch tag for this? |
Here I've:
bankAccountNumber
to all existing, supported localesiban()
function publicnull
as the$countryCode
(where it chooses a random, supported country)This allows the explicit use of
iban()
for any locale and allows for the generation of IBANs from random countries.The unit tests also warn (skip tests) about locales where bankAccountNumber is not implemented, even though an IBAN format is available. This currently warns about the "fake" locales at_AT and be_BE, which are deprecated in #594.
The one point I'm not sure on is the default value of iban($countryCode). I've set it to the current locale for IBAN countries and null (random) on the base class. For example, it would currently work like this: