PHP code example of czechphp / czech-bank-account

1. Go to this page and download the library: Download czechphp/czech-bank-account library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

czechphp / czech-bank-account example snippets




use Czechphp\CzechBankAccount\Validator\BankAccountNumberValidator;

$validator = new BankAccountNumberValidator();
$violation = $validator->validate('19-19', [
    'type' => BankAccountNumberValidator::OPTION_TYPE_VARIABLE,
]);

if ($violation === BankAccountNumberValidator::ERROR_NONE) {
    // valid
}



use Czechphp\CzechBankAccount\Validator\BankCodeValidator;
use Czechphp\CzechBankAccount\Loader\BankCode\FilesystemLoader;

$validator = new BankCodeValidator(new FilesystemLoader());
$violation = $validator->validate('0100');

if ($violation === BankCodeValidator::ERROR_NONE) {
    // valid
}



use Czechphp\CzechBankAccount\Validator\VariableSymbolValidator;

$validator = new VariableSymbolValidator();
$violation = $validator->validate('123');

if ($violation === VariableSymbolValidator::ERROR_NONE) {
    // valid
}



use Czechphp\CzechBankAccount\Validator\SpecificSymbolValidator;

$validator = new SpecificSymbolValidator();
$violation = $validator->validate('123');

if ($violation === SpecificSymbolValidator::ERROR_NONE) {
    // valid
}



use Czechphp\CzechBankAccount\Validator\ConstantSymbolValidator;

$validator = new ConstantSymbolValidator();
$violation = $validator->validate('0006');

if ($violation === ConstantSymbolValidator::ERROR_NONE) {
    // valid
}



use Czechphp\CzechBankAccount\ConstantSymbol\Filter\ArrayCacheFilter;
use Czechphp\CzechBankAccount\ConstantSymbol\Filter\Filter;
use Czechphp\CzechBankAccount\ConstantSymbol\Loader\ArrayRequireLoader;
use Czechphp\CzechBankAccount\Validator\ConstantSymbolValidator;

$filter = new ArrayCacheFilter(new Filter(new ArrayRequireLoader()));
$validator = new ConstantSymbolValidator($filter);
$violation = $validator->validate('0006', [
    'filter' => ['



use Czechphp\CzechBankAccount\Loader\BankCode\FilesystemLoader;
use Czechphp\CzechBankAccount\Loader\BankCode\LoaderInterface;

$loader = new FilesystemLoader();

$data = $loader->load();

// first two rows of $data variable
[
    [
        LoaderInterface::CODE => '0100', // string
        LoaderInterface::NAME => 'Komerční banka, a.s.', // string
        LoaderInterface::BIC => 'KOMBCZPP', // string|null
        LoaderInterface::CERTIS => true, // bool
    ],
    [
        LoaderInterface::CODE => '0300',
        LoaderInterface::NAME => 'Československá obchodní banka, a. s.',
        LoaderInterface::BIC => 'CEKOCZPP',
        LoaderInterface::CERTIS => true,
    ],
];




use Czechphp\CzechBankAccount\Utils\BankAccountNumberFormatConverter;

BankAccountNumberFormatConverter::convertVariableToConstant('19-19'); // returns "0000190000000019"

BankAccountNumberFormatConverter::convertConstantToVariable('0000190000000019'); // returns "19-19"