ondrakub / bank-php
Easy-to-use library for getting Czech code or name of bank.
v1.3
2018-08-27 21:52 UTC
Requires
- php: >=5.6
Requires (Dev)
- nette/tester: ~1.5
This package is not auto-updated.
Last update: 2024-11-09 15:44:53 UTC
README
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(); }