Skip to content

Commit

Permalink
Merge pull request #114 from julianpollmann/feature/check-country-eu-…
Browse files Browse the repository at this point in the history
…membership

Feature/check country EU membership.
  • Loading branch information
globalcitizen authored Jul 1, 2021
2 parents e847758 + 41bb3b0 commit 2700a77
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 120 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,18 @@ $central_bank_url = iban_country_get_central_bank_url($iban_country);
# (Note: Returns '' if there is no central bank. Also, note that
# sometimes multiple countries share one central bank)
$central_bank_name = iban_country_get_central_bank_name($iban_country);

# Get the membership type of the country
# There are four types of memberships:
# * EU-Member States (eu_member)
# * EFTA-Member States (efta_member)
# * Other Memberships, which have monetary agreements with the EU (other_member)
# * Non-Members, which don't belong to the EU or have agreements (non_member)
$country_membership = iban_country_get_membership($iban_country);

# Get if the country is a eu member state
# (Note: Returns true, if member state; false otherwise)
$country_membership = iban_country_get_is_eu_member($iban_country);
```


Expand Down
7 changes: 7 additions & 0 deletions oophp-iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ public function CentralBankName() {
return iban_country_get_central_bank_name($this->code);
}

public function Membership() {
return iban_country_get_membership($this->code);
}

public function IsEuMember() {
return iban_country_get_is_eu_member($this->code);
}
}

?>
26 changes: 23 additions & 3 deletions php-iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,25 @@ function iban_countries() {
return array_keys($_iban_registry);
}

# Get the membership of an IBAN country
# (Note: Possible Values eu_member, efta_member, other_member, non_member)
function iban_country_get_membership($iban_country) {
return _iban_country_get_info($iban_country,'membership');
}

# Get the membership of an IBAN country
# (Note: Possible Values eu_member, efta_member, other_member, non_member)
function iban_country_get_is_eu_member($iban_country) {
$membership = _iban_country_get_info($iban_country,'membership');
if ($membership === 'eu_member') {
$result = true;
} else {
$result = false;
}

return $result;
}

# Given an incorrect IBAN, return an array of zero or more checksum-valid
# suggestions for what the user might have meant, based upon common
# mistranscriptions.
Expand Down Expand Up @@ -516,7 +535,7 @@ function _iban_load_registry() {
$old_error_reporting_value = ini_get('error_reporting');
ini_set('error_reporting',false);
}
list($country,$country_name,$domestic_example,$bban_example,$bban_format_swift,$bban_format_regex,$bban_length,$iban_example,$iban_format_swift,$iban_format_regex,$iban_length,$bban_bankid_start_offset,$bban_bankid_stop_offset,$bban_branchid_start_offset,$bban_branchid_stop_offset,$registry_edition,$country_sepa,$country_swift_official,$bban_checksum_start_offset,$bban_checksum_stop_offset,$country_iana,$country_iso3166,$parent_registrar,$currency_iso4217,$central_bank_url,$central_bank_name) = explode('|',$line);
list($country,$country_name,$domestic_example,$bban_example,$bban_format_swift,$bban_format_regex,$bban_length,$iban_example,$iban_format_swift,$iban_format_regex,$iban_length,$bban_bankid_start_offset,$bban_bankid_stop_offset,$bban_branchid_start_offset,$bban_branchid_stop_offset,$registry_edition,$country_sepa,$country_swift_official,$bban_checksum_start_offset,$bban_checksum_stop_offset,$country_iana,$country_iso3166,$parent_registrar,$currency_iso4217,$central_bank_url,$central_bank_name,$membership) = explode('|',$line);
# avoid spewing tonnes of PHP warnings under bad PHP configs - see issue #69
if(function_exists('ini_set')) {
ini_set('display_errors',$old_display_errors_value);
Expand All @@ -541,15 +560,16 @@ function _iban_load_registry() {
'bban_branchid_start_offset' => $bban_branchid_start_offset,
'bban_branchid_stop_offset' => $bban_branchid_stop_offset,
'registry_edition' => $registry_edition,
'country_swift_official' => $country_swift_official,
'country_swift_official' => $country_swift_official,
'bban_checksum_start_offset' => $bban_checksum_start_offset,
'bban_checksum_stop_offset' => $bban_checksum_stop_offset,
'country_iana' => $country_iana,
'country_iso3166' => $country_iso3166,
'parent_registrar' => $parent_registrar,
'currency_iso4217' => $currency_iso4217,
'central_bank_url' => $central_bank_url,
'central_bank_name' => $central_bank_name
'central_bank_name' => $central_bank_name,
'membership' => $membership
);
}
}
Expand Down
Loading

0 comments on commit 2700a77

Please sign in to comment.