IBAN

author

Esser Jan

license

MIT

package

Default

Methods

International Back Account Number constructor.

__construct(string $countryCode, integer $check, string $bban) 

Arguments

$countryCode

string

country code using ISO 3166-1 alpha-2 - two letters

$check

integer

check digits - two digits

$bban

string

Basic Bank Account Number (BBAN) - up to 30 alphanumeric characters that are country-specific. No special characters like - or space allowed here, use the {@see createFromString} or {@see sanitize} instead if that's what you may have

__toString

__toString() 

createFromString

createFromString( $accountNumber) 
static

Arguments

$accountNumber

getIBANLengths

getIBANLengths() 

removes common used white spacing and hyphenation from the account number

sanitize(string $accountNumber) : string
static

Arguments

$accountNumber

string

Response

string

a 'CountryCode' => length pair assoc array, country codes must be UPPER case setting these will override the defaults

setIBANLengths(array $IBANLengths) 
static

Arguments

$IBANLengths

array

toFormattedString

toFormattedString(string $separator = ' ', integer $size = 4, boolean $prefix = false) : string

Arguments

$separator

string

supported separators are white spaces (regex \s) and hyphen (-) all other separators will not be able to be converted back into objects, a combination may be used.

$size

integer

the separator group size to use, this will chunk

$prefix

boolean

when true IBAN will be prefixed

Response

string

Generating IBAN check digits According to the ECBS "generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account".[8] The ECBS document replicates part of the ISO/IEC 7064:2003 standard as a method for generating check digits in the range 02 to 98. Check digits in the ranges 00 to 96, 01 to 97, and 03 to 99 will also provide validation of an IBAN, but the standard is silent as to whether or not these ranges may be used.

validateSelf() 

The preferred algorithm is:

  1. Check that the total IBAN length is correct as per the country. If not, the IBAN is invalid
  2. Replace the two check digits by 00 (e.g. GB00 for the UK)
  3. Move the four initial characters to the end of the string
  4. Replace the letters in the string with digits, expanding the string as necessary, such that A or a = 10, B or b = 11, and Z or z = 35. Each alphabetic character is therefore replaced by 2 digits
  5. Convert the string to an integer (i.e. ignore leading zeroes)
  6. Calculate mod-97 of the new number, which results in the remainder
  7. Subtract the remainder from 98, and use the result for the two check digits. If the result is a single digit number, pad it with a leading 0 to make a two-digit number

Properties

countryCode

countryCode : 

Type(s)

check

check : 

Type(s)

bban

bban : 

Type(s)

assoc list of `country code => length` pairs that indicate how long tot total IBAN may be

IBANLengths : array
static
var

Type(s)

array