alcohol / iso3166

A PHP library providing ISO 3166-1 data.
https://iso3166.thephpleague.com
MIT License
640 stars 59 forks source link

BC Break: currency key should consistently be an array #15

Closed nyamsprod closed 7 years ago

nyamsprod commented 8 years ago

the currency key should be standardized to being an array. sometimes the country has 1 currency, but sometimes more. I believe it would be easier to standardize or add a currencies key where the data is in an array of ISO4217 code. This way when calling this index you don't have to make a check before using the data.

$country['currencies'] = !is_array($country['currency']) ? [$country['currency']] : $country['currency'];
/// now you have a normalized currency index to work with in you code.
alcohol commented 7 years ago

I was wondering, is this really a BC break though? Currently you can receive either a string or an array, implying you should be capable of handling both. If we change everything to array, you simply need to handle one scenario less.

nyamsprod commented 7 years ago

it depends if someone expect for instance the 'FR' entry to return a string an now it returns an array it's BC breaking. but if you normalized the return maybe it could be considered to be a fix.... it depends