ondrakub/bank-php

Easy-to-use library for getting Czech code or name of bank.

v1.2 2015-08-21 10:53 UTC

README

Total Downloads Build Status Latest Stable Version License

Bank for PHP is a very small and easy-to-use library for works with bank account

Install

via composer

php composer.phar require ondrakub/bank-php

Usage

It is simple to use. Just call static methods Bank::getName($code) for getting name of bank and Bank::getCodes($name) for getting an array of codes of banks

try {

    echo Bank::getName(3030);

} catch (BankException $e) {
    echo 'Error: '. $e->getMessage();
}


try {

    $codes = Bank::getCodes('bank');

    foreach ($codes as $key => $value) {
        echo $key . ' - '. $value . '<br>';
    }

} catch (BankException $e) {
    echo 'Error: '. $e->getMessage();
}

Or you can work with account number

try {

    //accept xx-xx/xxxx, xx/xxxx, 00-xx/xxxx
    $bank = new Bank('1135595026/3030');

    echo 'account number: ' . $bank->getAccount() . '<br>';
    echo 'full account number: ' . $bank->getAccount(Bank::ZERO) . '<br>';
    echo 'prefix: ' . $bank->getPrefix() . '<br>';
    echo 'prefix with zero: ' . $bank->getPrefix(Bank::ZERO) . '<br>';
    echo 'number: ' . $bank->getNumber() . '<br>';
    echo 'number with zero: ' . $bank->getNumber(Bank::ZERO) . '<br>';
    echo 'code: ' . $bank->getCode() . '<br>';
    echo 'valid account: ' . $bank->isValid() . '<br>';
    echo 'IBAN: ' . $bank->getIban() . '<br>';
    echo 'formatted IBAN: ' . $bank->getIban(Bank::FORMATTED) . '<br>';
    echo 'BIC code (SWIFT): ' . $bank->getBic();

} catch (BankException $e) {
    echo 'Error: '. $e->getMessage();
}