diff --git a/.gitignore b/.gitignore index 876d4e6f..fa001321 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ nbproject .settings .buildpath .project +.idea +vendor +docs/todo diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..d026ff25 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +language: php + +sudo: false + +php: + - 7.3 + - 7.2 + +services: + - mysql + +cache: + directories: + - $HOME/.composer/cache + +env: PDO_DSN="mysql:host=localhost;dbname=bav" PDO_USER=travis + +install: + - composer require squizlabs/php_codesniffer + +before_script: + - mysql -e 'SET @@GLOBAL.wait_timeout=1200' + - mysql -e 'create database bav;' + - php tests/bin/test-install.php + +script: + - vendor/bin/phpunit tests/unit/ + - vendor/bin/phpunit --exclude-group large tests/unit-large/ + - vendor/bin/phpcs --standard=PSR2 classes/ bin/ docs/example.php tests/classes/ tests/bin/ tests/bootstrap.php + diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..5c93f456 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README b/README deleted file mode 100644 index cc1341fd..00000000 --- a/README +++ /dev/null @@ -1,135 +0,0 @@ -License and authors -------------------- - - This project is free and under GPL (see gpl.txt). So do what ever you want. - But it would be nice to leave a note about the authors. - - The author of the original project which gave the idea to this project is - Björn Wilmsmann. Responsable for this project is - Markus Malkusch . - - -Requirements ------------- - - You may have: - - * CURL - BAV_DataBackend_File->update() makes usage of the curl_* methods. - BAV_DataBackend_File->update() is called to download the bank data from - the Bundesbank. This is also needed by BAV_DataBackend_PDO->update(). If - you provide data/banklist.txt without using - BAV_DataBackend_File->update() you don't need CURL. - - * mbstring or iconv - BAV works with unicode encoding. Your PHP must have support compiled - in to either the mb_* or the iconv_* functions. If these functions are - missing BAV works only with the ISO-8859-15 encoding. - - * PDO - If you intend to use a DBS you need to use BAV_DataBackend_PDO. - BAV_DataBackend_PDO needs a PDO support compiled in PHP. - - -Configuration -------------- - - There is nothing to configure at all. The configuration is done implicitly - by the parameters you use to create a BAV_DataBackend object. You may - specify another encoding than UTF-8 with BAV::setEncoding(). - - But before you can use any class of BAV you have to include - autoloader/autoloader.php. BAV uses the autoloader generated by - . - - -Installation and Update ------------------------ - - Visit and download the latest version. - - You have to decide which datastructure you'll use. BAV comes with two - structures: - BAV_DataBackend_File and BAV_DataBackend_PDO. BAV_DataBackend_File uses the - text file which is provided by the Bundesbank. BAV_DataBackend_PDO uses - PHP's PDO-mechanism to connect with a DBS. - - If you use BAV the first time you have to create a BAV_DataBackend object - (PDO or File) and call the method install(). In case of PDO it will create - the tables. install() does also call update() to snychronize the first time - with the Bundesbank. - - To keep your database synchronized you have to call update(). It will - download the file from the Bundesbank and update your datastructure. The - Bundesbank releases 4 times a year a new file: March, June, September, - December. - - -Usage ------ - - Define one BAV_DataBackend object (which has an installed data structure). - Use the BAV_DataBackend->getBank($bankID) to get a BAV_Bank object. This - might raise a BAV_DataBackendException_BankNotFound if the bank was not - found. If you only want to check if a bank exists you may use - BAV_DataBackend->bankExists($bankID). - - You can use the BAV_Bank object to get information about the bank. Every - bank has a main agency. You get this BAV_Agency object with - BAV_Bank->getMainAgency(). A bank might also have some more agencies. These - optional agencies can be fetched with BAV_Bank->getAgencies(). Note that the - main agency is not included in this array. So the array - BAV_Bank->getAgencies() might even be empty. - - A BAV_Agency object provides these informations: - - BAV_Agency->getPostcode() - BAV_Agency->getCity() - BAV_Agency->getName() - BAV_Agency->getShortTerm() - BAV_Agency->hasPAN() - BAV_Agency->getPAN() - BAV_Agency->hasBIC() - BAV_Agency->getBIC() - - The boolean method BAV_Bank->isValid($accountID) will tell you if the - account is valid (TRUE) or invalid (FALSE). - - If you use BAV_DataBackend_PDO you may use - BAV_DataBackend_PDO->getAgencies($sql) to search for BAV_Agency objects with - an arbitrary SQL statement. Your statement should at least return the id of - the agencies. You perform better if your statement returns all attributes of - the agency table. - - BAV uses UTF-8 as default enconding. So every string - (especialy BAV_Agency->get*()) in BAV is UTF-8 encoded. If you intend to - work with those strings you should use PHP's mb_* oder iconv_* methods. - - -Example -------- - - You find it in scripts/example.php - - -Helping BAV ------------ - - test/checkValidators.php can find broken classes. This is only usefull for - debugging purposes if you implement new validators or data backends. There - exists a file with account ids for testing the validators. It's located at - data/verify.ini. You may add some account ids, if you want them to be - checked by checkValidators.php. If you then find some validators which are - implemented incorrectly, you should send a bug report. Don't forget to - mention the validation alogrithm (BAV_Bank->getValidationType()), the - account id and the expected result. - - There exists also the script scripts/verifyImport.php. You can use this to - import your bank accounts to a data/verify.ini and check them with - test/checkValidators.php. See the comments in verifyImport.php for more - details on usage. If there are errors you can send your verify.ini to - . Even if there aren't errors you can send this file, so - we have a larger database of testing accounts for future implementations. - The verify.ini contains only bank accounts with the validation type. There - is no information about the bank id, so the verify.ini can't be abused. - diff --git a/README.md b/README.md new file mode 100644 index 00000000..288b6784 --- /dev/null +++ b/README.md @@ -0,0 +1,198 @@ +# About BAV + +BAV (bank account validator) is a validation library for German bank accounts. Its based among other things on https://www.bundesbank.de/Redaktion/DE/Downloads/Aufgaben/Unbarer_Zahlungsverkehr/pruefzifferberechnungsmethoden.pdf?__blob=publicationFile + + +# Installation + +Use [Composer](https://getcomposer.org/): + +```json +{ + "require": { + "malkusch/bav": "^1" + } +} +``` + +# Configuration + +You can use BAV out of the box. BAV comes with a ready to play default +configuration ([`DefaultConfiguration`](http://bav-php.github.io/bav/api/class-malkusch.bav.DefaultConfiguration.html)): + +* `UTF-8` encoding (if supported) + +* [`FileDataBackendContainer`](http://bav-php.github.io/bav/api/class-malkusch.bav.FileDataBackendContainer.html). +I.e. it uses binary search on the file from the Bundesbank. +Note that this data backend uses the directory `bav/data` for install and update +operations. You have to make sure that this directory is writable. + +* automatic installation. You don't have to call any installation +script. The container will download the Bundesbank file upon the first execution. + +* update plan which triggers an E_USER_NOTICE if the Bundesbank file +is outdated. + +You can define your own configuration by calling +[`ConfigurationRegistry::setConfiguration()`](http://bav-php.github.io/bav/api/class-malkusch.bav.ConfigurationRegistry.html#_setConfiguration) +or preferably creating the file `bav/configuration.php` which returns a +[`Configuration`](http://bav-php.github.io/bav/api/class-malkusch.bav.Configuration.html) object: + +```php +namespace malkusch\bav; + +$configuration = new DefaultConfiguration(); + +$pdo = new \PDO("mysql:host=localhost;dbname=test;charset=UTF8"); +$configuration->setDataBackendContainer(new PDODataBackendContainer($pdo)); + +$configuration->setUpdatePlan(new AutomaticUpdatePlan()); + +return $configuration; +``` + + +# Update + +The Bundesbank releases new files for March, June, September and December. +BAV needs those new files. You have several possiblities to update bav: + +## Script + +Call `bin/bav-update.php`. + +## Programmatically + +```php +use malkusch\bav\BAV; + +$bav = new BAV(); +$bav->update(); +``` + +## Automatic + +Enable automatic updates with +[`AutomaticUpdatePlan`](http://bav-php.github.io/bav/api/class-malkusch.bav.AutomaticUpdatePlan.html) +in your `bav/configuration.php`: + +```php +namespace malkusch\bav; + +$configuration = new DefaultConfiguration(); +$configuration->setUpdatePlan(new AutomaticUpdatePlan()); + +return $configuration; +``` +This automatic update plan will perform long running update operations as a shutdown +hook. I.e. it won't bother users during normal operations. + + +# Usage + +You can use BAV with the api facade +[`BAV`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html): + +* [`BAV::isValidBank($bankID)`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html#_isValidBank): +Returns true for existing bank ids. + +* [`BAV::isValidBankAccount($bankID, $account)`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html#_isValidBankAccount): +Returns true for existing accounts of an existing bank. + +* [`BAV::isValidAccount($account)`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html#_isValidAccount): +This method validates an account against the bank of the last `isValidBank()` call. + +* [`BAV::getValidBankFilterCallback()`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html#_getValidBankFilterCallback): +Returns a callback for filter bank validation. + +* [`BAV::getValidAccountFilterCallback()`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html#_getValidAccountFilterCallback): +Returns a callback for filter account validation. The account filter needs +to be called after the bank filter. + +* [`BAV::getMainAgency()`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html#_getMainAgency): +Returns the main agency of a bank. + +* [`BAV::getAgencies()`](http://bav-php.github.io/bav/api/class-malkusch.bav.BAV.html#_getAgencies): +Returns further agencies. The main agency is not included in this list. +This list can be empty. + +An [`Agency`](http://bav-php.github.io/bav/api/class-malkusch.bav.Agency.html) +object has the fields: + +* [`Agency::getBIC()`](http://bav-php.github.io/bav/api/class-malkusch.bav.Agency.html#_getBIC) + +* [`Agency::getPostcode()`](http://bav-php.github.io/bav/api/class-malkusch.bav.Agency.html#_getPostcode) + +* [`Agency::getCity()`](http://bav-php.github.io/bav/api/class-malkusch.bav.Agency.html#_getCity) + +* [`Agency::getName()`](http://bav-php.github.io/bav/api/class-malkusch.bav.Agency.html#_getName) + +* [`Agency::getShortTerm()`](http://bav-php.github.io/bav/api/class-malkusch.bav.Agency.html#_getShortTerm) + +* [`Agency::getPAN()`](http://bav-php.github.io/bav/api/class-malkusch.bav.Agency.html#_getPAN) + +## Example + +```php +use malkusch\bav\BAV; + +$bav = new BAV(); +$bankID = "10000000"; +$account = "1234567890" + +// check for a bank +var_dump( + $bav->isValidBank($bankID) +); + +// check for a bank account +var_dump( + $bav->isValidBankAccount($bankID, $account) +); + +// filter validation +var_dump( + filter_var($bankID, FILTER_CALLBACK, $bav->getValidBankFilterCallback()), + filter_var($account, FILTER_CALLBACK, $bav->getValidAccountFilterCallback()) +); + +// Get informations about a bank +$agency = $bav->getMainAgency($bankID); +echo "{$agency->getName()} {$agency->getCity()}\n"; +``` +See also `bav/docs/example.php`. + + +# Optional Dependencies + +You may have: + +* **CURL**: If you provide `bav/data/banklist.txt` you don't need CURL. + +* **mbstring**: BAV works with unicode encoding. Your PHP must have support compiled +in the `mb_*` functions. If these functions are missing BAV works only with the ISO-8859-15 encoding. + +* **PDO**: If you intend to use a DBS you need to use +[`PDODataBackendContainer`](http://bav-php.github.io/bav/api/class-malkusch.bav.PDODataBackendContainer.html). +`PDODataBackendContainer` needs a `PDO` support compiled in PHP. + +* **doctrine/orm**: You can use +[`DoctrineBackendContainer`](http://bav-php.github.io/bav/api/class-malkusch.bav.DoctrineBackendContainer.html) +which uses doctrine +as data backend. + + +# License and authors + +This project is free and under the WTFPL. So do what ever you want. +But it would be nice to leave a note about the authors. + +The author of the original project which gave the idea to this project is +Björn Wilmsmann. Responsable for this project is Markus Malkusch . + +## Donations + +If you like BAV and feel generous donate a few Bitcoins here: +[1335STSwu9hST4vcMRppEPgENMHD2r1REK](bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK) + +[![Build Status](https://travis-ci.org/bmdevel/bav.svg?branch=master)](https://travis-ci.org/bmdevel/bav) diff --git a/autoloader/InstantAutoloader.php b/autoloader/InstantAutoloader.php index 692edcc1..2733cbd9 100644 --- a/autoloader/InstantAutoloader.php +++ b/autoloader/InstantAutoloader.php @@ -30,14 +30,7 @@ * @link http://php-autoloader.malkusch.de/en/ */ -/** - * There might be several InstantAutoloaders deployed in a project. - * One is enough. - */ -if (class_exists("InstantAutoloader")) { - return; - -} +namespace malkusch\bav\autoloader; /** * An instant autoloader for shipping with project builds @@ -62,22 +55,22 @@ */ class InstantAutoloader { - + const - /** - * The name of the class constructor is classConstructor(). - */ - CLASS_CONSTRUCTOR = 'classConstructor'; - + /** + * The name of the class constructor is classConstructor(). + */ + CLASS_CONSTRUCTOR = 'classConstructor'; + private - /** - * @var string - */ - $_basePath = "", - /** - * @var array - */ - $_index = array(); + /** + * @var string + */ + $_basePath = "", + /** + * @var array + */ + $_index = array(); /** * Loads the generated index array @@ -99,16 +92,15 @@ public function __construct($indexPath) public function register() { // spl_autoload_register() disables __autoload(). This might be unwanted. - if (function_exists("__autoload")) { - spl_autoload_register("__autoload"); - + if (\function_exists("__autoload")) { + \spl_autoload_register("__autoload"); } - spl_autoload_register(array($this, "__autoload")); + \spl_autoload_register([$this, "autoload"]); } /** * Includes all class paths - * + * * You can use this as an alternative to the autoload mechanism. This * simply includes all classes without any autoloader. * @@ -141,26 +133,34 @@ public function setBasePath($basePath) * * @return void */ - public function __autoload($class) + public function autoload($class) { - $this->_normalizeClass($class); - /* * spl_autoload_call() runs the complete stack, * even though the class is already defined by * a previously registered method. */ - if (class_exists($class, false) || interface_exists($class, false)) { + if ( + \class_exists($class, false) + || \interface_exists($class, false) + ) { + return; + + } + if ( + \version_compare(PHP_VERSION, "5.4", '>=') + && \trait_exists($class, false) + ) { return; } - if (! array_key_exists($class, $this->_index)) { + if (!\array_key_exists($class, $this->_index)) { return; } - + $this->_requirePath($this->_index[$class]); - + $this->_callClassConstructor($class, self::CLASS_CONSTRUCTOR); } @@ -173,7 +173,7 @@ public function __autoload($class) */ private function _requirePath($path) { - if (! empty($this->_basePath)) { + if (!empty($this->_basePath)) { $path = $this->_basePath . DIRECTORY_SEPARATOR . $path; } @@ -192,30 +192,39 @@ private function _requirePath($path) */ private function _normalizeClass(&$class) { - $class = strtolower($class); + $class = \strtolower($class); } - + /** * Calls the class constructor * * If the class $class has the method public static $constructor, it * will be called. * - * @param String $class A class which might have a class constructor + * @param String $class A class which might have a class constructor * @param String $constructorName the method name of the class constructor * * @return bool true if the class constructor was called */ - private function _callClassConstructor($class, $constructorName) + public static function _callClassConstructor($class, $constructorName) { - $reflectionClass = new ReflectionClass($class); - if (! $reflectionClass->hasMethod($constructorName)) { + if (!\class_exists($class)) { + return false; + } + + $reflectionClass = new \ReflectionClass($class); + if (!$reflectionClass->hasMethod($constructorName)) { return false; } $constructor = $reflectionClass->getMethod($constructorName); - if (! $constructor->isStatic()) { + if (!$constructor->isStatic()) { + return false; + + } + + if (\version_compare(PHP_VERSION, "5.4", '>=') && $reflectionClass->isTrait()) { return false; } @@ -229,4 +238,4 @@ private function _callClassConstructor($class, $constructorName) return true; } -} \ No newline at end of file +} diff --git a/autoloader/autoloader.php b/autoloader/autoloader.php index 395bde08..83c01be8 100644 --- a/autoloader/autoloader.php +++ b/autoloader/autoloader.php @@ -13,13 +13,11 @@ * @link http://php-autoloader.malkusch.de/en/ */ +namespace malkusch\bav\autoloader; + require_once __DIR__ . '/InstantAutoloader.php'; $_autoloader = new InstantAutoloader(__DIR__ . '/index/0.php'); $_autoloader->setBasePath(__DIR__); $_autoloader->register(); - -$_autoloader = new InstantAutoloader(__DIR__ . '/index/1.php'); -$_autoloader->setBasePath(__DIR__); -$_autoloader->register(); unset($_autoloader); \ No newline at end of file diff --git a/autoloader/index/0.php b/autoloader/index/0.php index 9f1e341b..a75f7466 100644 --- a/autoloader/index/0.php +++ b/autoloader/index/0.php @@ -15,213 +15,236 @@ */ return array( - 'bav' => '../classes/BAV.php', - 'bav_bank' => '../classes/bank/BAV_Bank.php', - 'bav_agency' => '../classes/bank/BAV_Agency.php', - 'bav_version' => '../classes/BAV_Version.php', - 'bav_testapi' => '../classes/verify/testAPI/BAV_TestAPI.php', - 'bav_encoding' => '../classes/encoding/BAV_Encoding.php', - 'bav_classfile' => '../classes/class/BAV_ClassFile.php', - 'bav_validator' => '../classes/validator/BAV_Validator.php', - 'bav_autoloader' => '../classes/autoloader/BAV_Autoloader.php', - 'bav_fileparser' => '../classes/dataBackend/fileParser/BAV_FileParser.php', - 'bav_databackend' => '../classes/dataBackend/BAV_DataBackend.php', - 'bav_encoding_mb' => '../classes/encoding/BAV_Encoding_MB.php', - 'bav_testapi_bav' => '../classes/verify/testAPI/BAV_TestAPI_BAV.php', - 'bav_validator_00' => '../classes/validator/validators/BAV_Validator_00.php', - 'bav_validator_01' => '../classes/validator/validators/BAV_Validator_01.php', - 'bav_validator_02' => '../classes/validator/validators/BAV_Validator_02.php', - 'bav_validator_03' => '../classes/validator/validators/BAV_Validator_03.php', - 'bav_validator_04' => '../classes/validator/validators/BAV_Validator_04.php', - 'bav_validator_05' => '../classes/validator/validators/BAV_Validator_05.php', - 'bav_validator_06' => '../classes/validator/validators/BAV_Validator_06.php', - 'bav_validator_07' => '../classes/validator/validators/BAV_Validator_07.php', - 'bav_validator_08' => '../classes/validator/validators/BAV_Validator_08.php', - 'bav_validator_09' => '../classes/validator/validators/BAV_Validator_09.php', - 'bav_validator_10' => '../classes/validator/validators/BAV_Validator_10.php', - 'bav_validator_11' => '../classes/validator/validators/BAV_Validator_11.php', - 'bav_validator_13' => '../classes/validator/validators/BAV_Validator_13.php', - 'bav_validator_14' => '../classes/validator/validators/BAV_Validator_14.php', - 'bav_validator_15' => '../classes/validator/validators/BAV_Validator_15.php', - 'bav_validator_16' => '../classes/validator/validators/BAV_Validator_16.php', - 'bav_validator_17' => '../classes/validator/validators/BAV_Validator_17.php', - 'bav_validator_18' => '../classes/validator/validators/BAV_Validator_18.php', - 'bav_validator_19' => '../classes/validator/validators/BAV_Validator_19.php', - 'bav_validator_20' => '../classes/validator/validators/BAV_Validator_20.php', - 'bav_validator_21' => '../classes/validator/validators/BAV_Validator_21.php', - 'bav_validator_22' => '../classes/validator/validators/BAV_Validator_22.php', - 'bav_validator_23' => '../classes/validator/validators/BAV_Validator_23.php', - 'bav_validator_24' => '../classes/validator/validators/BAV_Validator_24.php', - 'bav_validator_25' => '../classes/validator/validators/BAV_Validator_25.php', - 'bav_validator_26' => '../classes/validator/validators/BAV_Validator_26.php', - 'bav_validator_27' => '../classes/validator/validators/BAV_Validator_27.php', - 'bav_validator_28' => '../classes/validator/validators/BAV_Validator_28.php', - 'bav_validator_29' => '../classes/validator/validators/BAV_Validator_29.php', - 'bav_validator_30' => '../classes/validator/validators/BAV_Validator_30.php', - 'bav_validator_31' => '../classes/validator/validators/BAV_Validator_31.php', - 'bav_validator_32' => '../classes/validator/validators/BAV_Validator_32.php', - 'bav_validator_33' => '../classes/validator/validators/BAV_Validator_33.php', - 'bav_validator_34' => '../classes/validator/validators/BAV_Validator_34.php', - 'bav_validator_35' => '../classes/validator/validators/BAV_Validator_35.php', - 'bav_validator_36' => '../classes/validator/validators/BAV_Validator_36.php', - 'bav_validator_37' => '../classes/validator/validators/BAV_Validator_37.php', - 'bav_validator_38' => '../classes/validator/validators/BAV_Validator_38.php', - 'bav_validator_39' => '../classes/validator/validators/BAV_Validator_39.php', - 'bav_validator_40' => '../classes/validator/validators/BAV_Validator_40.php', - 'bav_validator_41' => '../classes/validator/validators/BAV_Validator_41.php', - 'bav_validator_42' => '../classes/validator/validators/BAV_Validator_42.php', - 'bav_validator_43' => '../classes/validator/validators/BAV_Validator_43.php', - 'bav_validator_44' => '../classes/validator/validators/BAV_Validator_44.php', - 'bav_validator_45' => '../classes/validator/validators/BAV_Validator_45.php', - 'bav_validator_46' => '../classes/validator/validators/BAV_Validator_46.php', - 'bav_validator_47' => '../classes/validator/validators/BAV_Validator_47.php', - 'bav_validator_48' => '../classes/validator/validators/BAV_Validator_48.php', - 'bav_validator_49' => '../classes/validator/validators/BAV_Validator_49.php', - 'bav_validator_50' => '../classes/validator/validators/BAV_Validator_50.php', - 'bav_validator_51' => '../classes/validator/validators/BAV_Validator_51.php', - 'bav_validator_52' => '../classes/validator/validators/BAV_Validator_52.php', - 'bav_validator_53' => '../classes/validator/validators/BAV_Validator_53.php', - 'bav_validator_54' => '../classes/validator/validators/BAV_Validator_54.php', - 'bav_validator_55' => '../classes/validator/validators/BAV_Validator_55.php', - 'bav_validator_56' => '../classes/validator/validators/BAV_Validator_56.php', - 'bav_validator_57' => '../classes/validator/validators/BAV_Validator_57.php', - 'bav_validator_58' => '../classes/validator/validators/BAV_Validator_58.php', - 'bav_validator_59' => '../classes/validator/validators/BAV_Validator_59.php', - 'bav_validator_60' => '../classes/validator/validators/BAV_Validator_60.php', - 'bav_validator_61' => '../classes/validator/validators/BAV_Validator_61.php', - 'bav_validator_62' => '../classes/validator/validators/BAV_Validator_62.php', - 'bav_validator_63' => '../classes/validator/validators/BAV_Validator_63.php', - 'bav_validator_64' => '../classes/validator/validators/BAV_Validator_64.php', - 'bav_validator_65' => '../classes/validator/validators/BAV_Validator_65.php', - 'bav_validator_66' => '../classes/validator/validators/BAV_Validator_66.php', - 'bav_validator_67' => '../classes/validator/validators/BAV_Validator_67.php', - 'bav_validator_68' => '../classes/validator/validators/BAV_Validator_68.php', - 'bav_validator_69' => '../classes/validator/validators/BAV_Validator_69.php', - 'bav_validator_70' => '../classes/validator/validators/BAV_Validator_70.php', - 'bav_validator_71' => '../classes/validator/validators/BAV_Validator_71.php', - 'bav_validator_72' => '../classes/validator/validators/BAV_Validator_72.php', - 'bav_validator_73' => '../classes/validator/validators/BAV_Validator_73.php', - 'bav_validator_74' => '../classes/validator/validators/BAV_Validator_74.php', - 'bav_validator_75' => '../classes/validator/validators/BAV_Validator_75.php', - 'bav_validator_76' => '../classes/validator/validators/BAV_Validator_76.php', - 'bav_validator_77' => '../classes/validator/validators/BAV_Validator_77.php', - 'bav_validator_78' => '../classes/validator/validators/BAV_Validator_78.php', - 'bav_validator_79' => '../classes/validator/validators/BAV_Validator_79.php', - 'bav_validator_80' => '../classes/validator/validators/BAV_Validator_80.php', - 'bav_validator_81' => '../classes/validator/validators/BAV_Validator_81.php', - 'bav_validator_82' => '../classes/validator/validators/BAV_Validator_82.php', - 'bav_validator_83' => '../classes/validator/validators/BAV_Validator_83.php', - 'bav_validator_84' => '../classes/validator/validators/BAV_Validator_84.php', - 'bav_validator_85' => '../classes/validator/validators/BAV_Validator_85.php', - 'bav_validator_86' => '../classes/validator/validators/BAV_Validator_86.php', - 'bav_validator_87' => '../classes/validator/validators/BAV_Validator_87.php', - 'bav_validator_88' => '../classes/validator/validators/BAV_Validator_88.php', - 'bav_validator_89' => '../classes/validator/validators/BAV_Validator_89.php', - 'bav_validator_90' => '../classes/validator/validators/BAV_Validator_90.php', - 'bav_validator_91' => '../classes/validator/validators/BAV_Validator_91.php', - 'bav_validator_92' => '../classes/validator/validators/BAV_Validator_92.php', - 'bav_validator_93' => '../classes/validator/validators/BAV_Validator_93.php', - 'bav_validator_94' => '../classes/validator/validators/BAV_Validator_94.php', - 'bav_validator_95' => '../classes/validator/validators/BAV_Validator_95.php', - 'bav_validator_96' => '../classes/validator/validators/BAV_Validator_96.php', - 'bav_validator_97' => '../classes/validator/validators/BAV_Validator_97.php', - 'bav_validator_98' => '../classes/validator/validators/BAV_Validator_98.php', - 'bav_validator_99' => '../classes/validator/validators/BAV_Validator_99.php', - 'bav_validator_a0' => '../classes/validator/validators/BAV_Validator_A0.php', - 'bav_validator_a1' => '../classes/validator/validators/BAV_Validator_A1.php', - 'bav_validator_a2' => '../classes/validator/validators/BAV_Validator_A2.php', - 'bav_validator_a3' => '../classes/validator/validators/BAV_Validator_A3.php', - 'bav_validator_a4' => '../classes/validator/validators/BAV_Validator_A4.php', - 'bav_validator_a5' => '../classes/validator/validators/BAV_Validator_A5.php', - 'bav_validator_a6' => '../classes/validator/validators/BAV_Validator_A6.php', - 'bav_validator_a7' => '../classes/validator/validators/BAV_Validator_A7.php', - 'bav_validator_a8' => '../classes/validator/validators/BAV_Validator_A8.php', - 'bav_validator_a9' => '../classes/validator/validators/BAV_Validator_A9.php', - 'bav_validator_b0' => '../classes/validator/validators/BAV_Validator_B0.php', - 'bav_validator_b1' => '../classes/validator/validators/BAV_Validator_B1.php', - 'bav_validator_b2' => '../classes/validator/validators/BAV_Validator_B2.php', - 'bav_validator_b3' => '../classes/validator/validators/BAV_Validator_B3.php', - 'bav_validator_b4' => '../classes/validator/validators/BAV_Validator_B4.php', - 'bav_validator_b5' => '../classes/validator/validators/BAV_Validator_B5.php', - 'bav_validator_b6' => '../classes/validator/validators/BAV_Validator_B6.php', - 'bav_validator_b7' => '../classes/validator/validators/BAV_Validator_B7.php', - 'bav_validator_b8' => '../classes/validator/validators/BAV_Validator_B8.php', - 'bav_validator_b9' => '../classes/validator/validators/BAV_Validator_B9.php', - 'bav_validator_c0' => '../classes/validator/validators/BAV_Validator_C0.php', - 'bav_validator_c1' => '../classes/validator/validators/BAV_Validator_C1.php', - 'bav_validator_c2' => '../classes/validator/validators/BAV_Validator_C2.php', - 'bav_validator_c3' => '../classes/validator/validators/BAV_Validator_C3.php', - 'bav_validator_c4' => '../classes/validator/validators/BAV_Validator_C4.php', - 'bav_validator_c5' => '../classes/validator/validators/BAV_Validator_C5.php', - 'bav_validator_c6' => '../classes/validator/validators/BAV_Validator_C6.php', - 'bav_validator_c7' => '../classes/validator/validators/BAV_Validator_C7.php', - 'bav_validator_c8' => '../classes/validator/validators/BAV_Validator_C8.php', - 'bav_validator_c9' => '../classes/validator/validators/BAV_Validator_C9.php', - 'bav_validator_d0' => '../classes/validator/validators/BAV_Validator_D0.php', - 'bav_validator_d1' => '../classes/validator/validators/BAV_Validator_D1.php', - 'bav_validator_d2' => '../classes/validator/validators/BAV_Validator_D2.php', - 'bav_validator_d3' => '../classes/validator/validators/BAV_Validator_D3.php', - 'bav_validator_d4' => '../classes/validator/validators/BAV_Validator_D4.php', - 'bav_validator_d5' => '../classes/validator/validators/BAV_Validator_D5.php', - 'bav_validator_d6' => '../classes/validator/validators/BAV_Validator_D6.php', - 'bav_validator_d7' => '../classes/validator/validators/BAV_Validator_D7.php', - 'bav_validator_d8' => '../classes/validator/validators/BAV_Validator_D8.php', - 'bav_validator_d9' => '../classes/validator/validators/BAV_Validator_D9.php', - 'bav_verifyimport' => '../classes/verify/BAV_VerifyImport.php', - 'bav_validator_51x' => '../classes/validator/validators/BAV_Validator_51x.php', - 'bav_validator_69b' => '../classes/validator/validators/BAV_Validator_69b.php', - 'bav_validator_77a' => '../classes/validator/validators/BAV_Validator_77a.php', - 'bav_validator_83x' => '../classes/validator/validators/BAV_Validator_83x.php', - 'bav_validator_84b' => '../classes/validator/validators/BAV_Validator_84b.php', - 'bav_validator_87a' => '../classes/validator/validators/BAV_Validator_87a.php', - 'bav_validator_87c' => '../classes/validator/validators/BAV_Validator_87c.php', - 'bav_validator_90c' => '../classes/validator/validators/BAV_Validator_90c.php', - 'bav_validator_90d' => '../classes/validator/validators/BAV_Validator_90d.php', - 'bav_validator_90e' => '../classes/validator/validators/BAV_Validator_90e.php', - 'bav_validator_a4b' => '../classes/validator/validators/BAV_Validator_A4b.php', - 'bav_validator_b9a' => '../classes/validator/validators/BAV_Validator_B9a.php', - 'bav_validator_b9b' => '../classes/validator/validators/BAV_Validator_B9b.php', - 'bav_validator_c1b' => '../classes/validator/validators/BAV_Validator_C1b.php', - 'bav_testapiresult' => '../classes/verify/testAPI/BAV_TestAPIResult.php', - 'bav_encoding_iconv' => '../classes/encoding/BAV_Encoding_Iconv.php', - 'bav_agencyexception' => '../classes/bank/exception/BAV_AgencyException.php', - 'bav_databackend_pdo' => '../classes/dataBackend/BAV_DataBackend_PDO.php', - 'bav_validator_chain' => '../classes/validator/BAV_Validator_Chain.php', - 'bav_verifyexception' => '../classes/verify/exception/BAV_VerifyException.php', - 'bav_databackend_file' => '../classes/dataBackend/BAV_DataBackend_File.php', - 'bav_encoding_iso8859' => '../classes/encoding/BAV_Encoding_ISO8859.php', - 'bav_testapiexception' => '../classes/verify/testAPI/exception/BAV_TestAPIException.php', - 'bav_fileparsercontext' => '../classes/dataBackend/fileParser/BAV_FileParserContext.php', - 'bav_encodingexception' => '../classes/encoding/exception/BAV_EncodingException.php', - 'bav_classfileexception' => '../classes/class/exception/BAV_ClassFileException.php', - 'bav_validatorexception' => '../classes/validator/exception/BAV_ValidatorException.php', - 'bav_verifyexception_io' => '../classes/verify/exception/BAV_VerifyException_IO.php', - 'bav_testapi_kontocheck' => '../classes/verify/testAPI/BAV_TestAPI_Kontocheck.php', - 'bav_fileparserexception' => '../classes/dataBackend/fileParser/exception/BAV_FileParserException.php', - 'bav_validator_iteration' => '../classes/validator/BAV_Validator_Iteration.php', - 'bav_testapiresult_error' => '../classes/verify/testAPI/BAV_TestAPIResult_Error.php', - 'bav_testapi_ktoblzcheck' => '../classes/verify/testAPI/BAV_TestAPI_Ktoblzcheck.php', - 'bav_databackendexception' => '../classes/dataBackend/exception/BAV_DataBackendException.php', - 'bav_classfileexception_io' => '../classes/class/exception/BAV_ClassFileException_IO.php', - 'bav_fileparserexception_io' => '../classes/dataBackend/fileParser/exception/BAV_FileParserException_IO.php', - 'bav_databackendexception_io' => '../classes/dataBackend/exception/BAV_DataBackendException_IO.php', - 'bav_validator_bankdependent' => '../classes/validator/BAV_Validator_BankDependent.php', - 'bav_validatorexception_eser' => '../classes/validator/exception/BAV_ValidatorException_ESER.php', - 'bav_fileparsercontextexception' => '../classes/dataBackend/fileParser/exception/BAV_FileParserContextException.php', - 'bav_testapiexception_validation' => '../classes/verify/testAPI/exception/BAV_TestAPIException_Validation.php', - 'bav_validator_iteration_weighted' => '../classes/validator/BAV_Validator_Iteration_Weighted.php', - 'bav_validatorexception_notexists' => '../classes/validator/exception/BAV_ValidatorException_NotExists.php', - 'bav_encodingexception_unsupported' => '../classes/encoding/exception/BAV_EncodingException_Unsupported.php', - 'bav_fileparserexception_parseerror' => '../classes/dataBackend/fileParser/exception/BAV_FileParserException_ParseError.php', - 'bav_validatorexception_outofbounds' => '../classes/validator/exception/BAV_ValidatorException_OutOfBounds.php', - 'bav_classfileexception_missingclass' => '../classes/class/exception/BAV_ClassFileException_MissingClass.php', - 'bav_databackendexception_banknotfound' => '../classes/dataBackend/exception/BAV_DataBackendException_BankNotFound.php', - 'bav_databackendexception_nomainagency' => '../classes/dataBackend/exception/BAV_DataBackendException_NoMainAgency.php', - 'bav_fileparserexception_filenotexists' => '../classes/dataBackend/fileParser/exception/BAV_FileParserException_FileNotExists.php', - 'bav_agencyexception_undefinedattribute' => '../classes/bank/exception/BAV_AgencyException_UndefinedAttribute.php', - 'bav_validator_iteration_transformation' => '../classes/validator/BAV_Validator_Iteration_Transformation.php', - 'bav_fileparsercontextexception_undefined' => '../classes/dataBackend/fileParser/exception/BAV_FileParserContextException_Undefined.php', - 'bav_testapiexception_validation_banknotfound' => '../classes/verify/testAPI/exception/BAV_TestAPIException_Validation_BankNotFound.php', - 'bav_databackendexception_io_missingattributes' => '../classes/dataBackend/exception/BAV_DataBackendException_IO_MissingAttributes.php', - 'bav_testapiexception_validation_notinitialized' => '../classes/verify/testAPI/exception/BAV_TestAPIException_Validation_NotInitialized.php', + 'malkusch\bav\BAV' => '../classes/BAV.php', + 'malkusch\bav\Bank' => '../classes/bank/Bank.php', + 'malkusch\bav\Lock' => '../classes/util/Lock.php', + 'malkusch\bav\Agency' => '../classes/bank/Agency.php', + 'malkusch\bav\BICUtil' => '../classes/util/BICUtil.php', + 'malkusch\bav\MetaData' => '../classes/dataBackend/orm/MetaData.php', + 'malkusch\bav\Encoding' => '../classes/encoding/Encoding.php', + 'malkusch\bav\FileUtil' => '../classes/util/FileUtil.php', + 'malkusch\bav\URIPicker' => '../classes/dataBackend/file/download/uripicker/URIPicker.php', + 'malkusch\bav\Validator' => '../classes/validator/Validator.php', + 'malkusch\bav\Downloader' => '../classes/dataBackend/file/download/Downloader.php', + 'malkusch\bav\FileParser' => '../classes/dataBackend/file/fileParser/FileParser.php', + 'malkusch\bav\UpdatePlan' => '../classes/dataBackend/update/UpdatePlan.php', + 'malkusch\bav\MBEncoding' => '../classes/encoding/MBEncoding.php', + 'malkusch\bav\DataBackend' => '../classes/dataBackend/DataBackend.php', + 'malkusch\bav\Validator00' => '../classes/validator/validators/Validator00.php', + 'malkusch\bav\Validator01' => '../classes/validator/validators/Validator01.php', + 'malkusch\bav\Validator02' => '../classes/validator/validators/Validator02.php', + 'malkusch\bav\Validator03' => '../classes/validator/validators/Validator03.php', + 'malkusch\bav\Validator04' => '../classes/validator/validators/Validator04.php', + 'malkusch\bav\Validator05' => '../classes/validator/validators/Validator05.php', + 'malkusch\bav\Validator06' => '../classes/validator/validators/Validator06.php', + 'malkusch\bav\Validator07' => '../classes/validator/validators/Validator07.php', + 'malkusch\bav\Validator08' => '../classes/validator/validators/Validator08.php', + 'malkusch\bav\Validator09' => '../classes/validator/validators/Validator09.php', + 'malkusch\bav\Validator10' => '../classes/validator/validators/Validator10.php', + 'malkusch\bav\Validator11' => '../classes/validator/validators/Validator11.php', + 'malkusch\bav\Validator13' => '../classes/validator/validators/Validator13.php', + 'malkusch\bav\Validator14' => '../classes/validator/validators/Validator14.php', + 'malkusch\bav\Validator15' => '../classes/validator/validators/Validator15.php', + 'malkusch\bav\Validator16' => '../classes/validator/validators/Validator16.php', + 'malkusch\bav\Validator17' => '../classes/validator/validators/Validator17.php', + 'malkusch\bav\Validator18' => '../classes/validator/validators/Validator18.php', + 'malkusch\bav\Validator19' => '../classes/validator/validators/Validator19.php', + 'malkusch\bav\Validator20' => '../classes/validator/validators/Validator20.php', + 'malkusch\bav\Validator21' => '../classes/validator/validators/Validator21.php', + 'malkusch\bav\Validator22' => '../classes/validator/validators/Validator22.php', + 'malkusch\bav\Validator23' => '../classes/validator/validators/Validator23.php', + 'malkusch\bav\Validator24' => '../classes/validator/validators/Validator24.php', + 'malkusch\bav\Validator25' => '../classes/validator/validators/Validator25.php', + 'malkusch\bav\Validator26' => '../classes/validator/validators/Validator26.php', + 'malkusch\bav\Validator27' => '../classes/validator/validators/Validator27.php', + 'malkusch\bav\Validator28' => '../classes/validator/validators/Validator28.php', + 'malkusch\bav\Validator29' => '../classes/validator/validators/Validator29.php', + 'malkusch\bav\Validator30' => '../classes/validator/validators/Validator30.php', + 'malkusch\bav\Validator31' => '../classes/validator/validators/Validator31.php', + 'malkusch\bav\Validator32' => '../classes/validator/validators/Validator32.php', + 'malkusch\bav\Validator33' => '../classes/validator/validators/Validator33.php', + 'malkusch\bav\Validator34' => '../classes/validator/validators/Validator34.php', + 'malkusch\bav\Validator35' => '../classes/validator/validators/Validator35.php', + 'malkusch\bav\Validator36' => '../classes/validator/validators/Validator36.php', + 'malkusch\bav\Validator37' => '../classes/validator/validators/Validator37.php', + 'malkusch\bav\Validator38' => '../classes/validator/validators/Validator38.php', + 'malkusch\bav\Validator39' => '../classes/validator/validators/Validator39.php', + 'malkusch\bav\Validator40' => '../classes/validator/validators/Validator40.php', + 'malkusch\bav\Validator41' => '../classes/validator/validators/Validator41.php', + 'malkusch\bav\Validator42' => '../classes/validator/validators/Validator42.php', + 'malkusch\bav\Validator43' => '../classes/validator/validators/Validator43.php', + 'malkusch\bav\Validator44' => '../classes/validator/validators/Validator44.php', + 'malkusch\bav\Validator45' => '../classes/validator/validators/Validator45.php', + 'malkusch\bav\Validator46' => '../classes/validator/validators/Validator46.php', + 'malkusch\bav\Validator47' => '../classes/validator/validators/Validator47.php', + 'malkusch\bav\Validator48' => '../classes/validator/validators/Validator48.php', + 'malkusch\bav\Validator49' => '../classes/validator/validators/Validator49.php', + 'malkusch\bav\Validator50' => '../classes/validator/validators/Validator50.php', + 'malkusch\bav\Validator51' => '../classes/validator/validators/Validator51.php', + 'malkusch\bav\Validator52' => '../classes/validator/validators/Validator52.php', + 'malkusch\bav\Validator53' => '../classes/validator/validators/Validator53.php', + 'malkusch\bav\Validator54' => '../classes/validator/validators/Validator54.php', + 'malkusch\bav\Validator55' => '../classes/validator/validators/Validator55.php', + 'malkusch\bav\Validator56' => '../classes/validator/validators/Validator56.php', + 'malkusch\bav\Validator57' => '../classes/validator/validators/Validator57.php', + 'malkusch\bav\Validator58' => '../classes/validator/validators/Validator58.php', + 'malkusch\bav\Validator59' => '../classes/validator/validators/Validator59.php', + 'malkusch\bav\Validator60' => '../classes/validator/validators/Validator60.php', + 'malkusch\bav\Validator61' => '../classes/validator/validators/Validator61.php', + 'malkusch\bav\Validator62' => '../classes/validator/validators/Validator62.php', + 'malkusch\bav\Validator63' => '../classes/validator/validators/Validator63.php', + 'malkusch\bav\Validator64' => '../classes/validator/validators/Validator64.php', + 'malkusch\bav\Validator65' => '../classes/validator/validators/Validator65.php', + 'malkusch\bav\Validator66' => '../classes/validator/validators/Validator66.php', + 'malkusch\bav\Validator67' => '../classes/validator/validators/Validator67.php', + 'malkusch\bav\Validator68' => '../classes/validator/validators/Validator68.php', + 'malkusch\bav\Validator69' => '../classes/validator/validators/Validator69.php', + 'malkusch\bav\Validator70' => '../classes/validator/validators/Validator70.php', + 'malkusch\bav\Validator71' => '../classes/validator/validators/Validator71.php', + 'malkusch\bav\Validator72' => '../classes/validator/validators/Validator72.php', + 'malkusch\bav\Validator73' => '../classes/validator/validators/Validator73.php', + 'malkusch\bav\Validator74' => '../classes/validator/validators/Validator74.php', + 'malkusch\bav\Validator75' => '../classes/validator/validators/Validator75.php', + 'malkusch\bav\Validator76' => '../classes/validator/validators/Validator76.php', + 'malkusch\bav\Validator77' => '../classes/validator/validators/Validator77.php', + 'malkusch\bav\Validator78' => '../classes/validator/validators/Validator78.php', + 'malkusch\bav\Validator79' => '../classes/validator/validators/Validator79.php', + 'malkusch\bav\Validator80' => '../classes/validator/validators/Validator80.php', + 'malkusch\bav\Validator81' => '../classes/validator/validators/Validator81.php', + 'malkusch\bav\Validator82' => '../classes/validator/validators/Validator82.php', + 'malkusch\bav\Validator83' => '../classes/validator/validators/Validator83.php', + 'malkusch\bav\Validator84' => '../classes/validator/validators/Validator84.php', + 'malkusch\bav\Validator85' => '../classes/validator/validators/Validator85.php', + 'malkusch\bav\Validator86' => '../classes/validator/validators/Validator86.php', + 'malkusch\bav\Validator87' => '../classes/validator/validators/Validator87.php', + 'malkusch\bav\Validator88' => '../classes/validator/validators/Validator88.php', + 'malkusch\bav\Validator89' => '../classes/validator/validators/Validator89.php', + 'malkusch\bav\Validator90' => '../classes/validator/validators/Validator90.php', + 'malkusch\bav\Validator91' => '../classes/validator/validators/Validator91.php', + 'malkusch\bav\Validator92' => '../classes/validator/validators/Validator92.php', + 'malkusch\bav\Validator93' => '../classes/validator/validators/Validator93.php', + 'malkusch\bav\Validator94' => '../classes/validator/validators/Validator94.php', + 'malkusch\bav\Validator95' => '../classes/validator/validators/Validator95.php', + 'malkusch\bav\Validator96' => '../classes/validator/validators/Validator96.php', + 'malkusch\bav\Validator97' => '../classes/validator/validators/Validator97.php', + 'malkusch\bav\Validator98' => '../classes/validator/validators/Validator98.php', + 'malkusch\bav\Validator99' => '../classes/validator/validators/Validator99.php', + 'malkusch\bav\ValidatorA0' => '../classes/validator/validators/ValidatorA0.php', + 'malkusch\bav\ValidatorA1' => '../classes/validator/validators/ValidatorA1.php', + 'malkusch\bav\ValidatorA2' => '../classes/validator/validators/ValidatorA2.php', + 'malkusch\bav\ValidatorA3' => '../classes/validator/validators/ValidatorA3.php', + 'malkusch\bav\ValidatorA4' => '../classes/validator/validators/ValidatorA4.php', + 'malkusch\bav\ValidatorA5' => '../classes/validator/validators/ValidatorA5.php', + 'malkusch\bav\ValidatorA6' => '../classes/validator/validators/ValidatorA6.php', + 'malkusch\bav\ValidatorA7' => '../classes/validator/validators/ValidatorA7.php', + 'malkusch\bav\ValidatorA8' => '../classes/validator/validators/ValidatorA8.php', + 'malkusch\bav\ValidatorA9' => '../classes/validator/validators/ValidatorA9.php', + 'malkusch\bav\ValidatorB0' => '../classes/validator/validators/ValidatorB0.php', + 'malkusch\bav\ValidatorB1' => '../classes/validator/validators/ValidatorB1.php', + 'malkusch\bav\ValidatorB2' => '../classes/validator/validators/ValidatorB2.php', + 'malkusch\bav\ValidatorB3' => '../classes/validator/validators/ValidatorB3.php', + 'malkusch\bav\ValidatorB4' => '../classes/validator/validators/ValidatorB4.php', + 'malkusch\bav\ValidatorB5' => '../classes/validator/validators/ValidatorB5.php', + 'malkusch\bav\ValidatorB6' => '../classes/validator/validators/ValidatorB6.php', + 'malkusch\bav\ValidatorB7' => '../classes/validator/validators/ValidatorB7.php', + 'malkusch\bav\ValidatorB8' => '../classes/validator/validators/ValidatorB8.php', + 'malkusch\bav\ValidatorB9' => '../classes/validator/validators/ValidatorB9.php', + 'malkusch\bav\ValidatorC0' => '../classes/validator/validators/ValidatorC0.php', + 'malkusch\bav\ValidatorC1' => '../classes/validator/validators/ValidatorC1.php', + 'malkusch\bav\ValidatorC2' => '../classes/validator/validators/ValidatorC2.php', + 'malkusch\bav\ValidatorC3' => '../classes/validator/validators/ValidatorC3.php', + 'malkusch\bav\ValidatorC4' => '../classes/validator/validators/ValidatorC4.php', + 'malkusch\bav\ValidatorC5' => '../classes/validator/validators/ValidatorC5.php', + 'malkusch\bav\ValidatorC6' => '../classes/validator/validators/ValidatorC6.php', + 'malkusch\bav\ValidatorC7' => '../classes/validator/validators/ValidatorC7.php', + 'malkusch\bav\ValidatorC8' => '../classes/validator/validators/ValidatorC8.php', + 'malkusch\bav\ValidatorC9' => '../classes/validator/validators/ValidatorC9.php', + 'malkusch\bav\ValidatorD0' => '../classes/validator/validators/ValidatorD0.php', + 'malkusch\bav\ValidatorD1' => '../classes/validator/validators/ValidatorD1.php', + 'malkusch\bav\ValidatorD2' => '../classes/validator/validators/ValidatorD2.php', + 'malkusch\bav\ValidatorD3' => '../classes/validator/validators/ValidatorD3.php', + 'malkusch\bav\ValidatorD4' => '../classes/validator/validators/ValidatorD4.php', + 'malkusch\bav\ValidatorD5' => '../classes/validator/validators/ValidatorD5.php', + 'malkusch\bav\ValidatorD6' => '../classes/validator/validators/ValidatorD6.php', + 'malkusch\bav\ValidatorD7' => '../classes/validator/validators/ValidatorD7.php', + 'malkusch\bav\ValidatorD8' => '../classes/validator/validators/ValidatorD8.php', + 'malkusch\bav\ValidatorD9' => '../classes/validator/validators/ValidatorD9.php', + 'malkusch\bav\ValidatorE0' => '../classes/validator/validators/ValidatorE0.php', + 'malkusch\bav\ValidatorE1' => '../classes/validator/validators/ValidatorE1.php', + 'malkusch\bav\ValidatorE3' => '../classes/validator/validators/ValidatorE3.php', + 'malkusch\bav\ValidatorE4' => '../classes/validator/validators/ValidatorE4.php', + 'malkusch\bav\DOMURIPicker' => '../classes/dataBackend/file/download/uripicker/DOMURIPicker.php', + 'malkusch\bav\BAVException' => '../classes/exception/BAVException.php', + 'malkusch\bav\Validator51x' => '../classes/validator/validators/Validator51x.php', + 'malkusch\bav\Validator69b' => '../classes/validator/validators/Validator69b.php', + 'malkusch\bav\Validator77a' => '../classes/validator/validators/Validator77a.php', + 'malkusch\bav\Validator83x' => '../classes/validator/validators/Validator83x.php', + 'malkusch\bav\Validator84b' => '../classes/validator/validators/Validator84b.php', + 'malkusch\bav\Validator87a' => '../classes/validator/validators/Validator87a.php', + 'malkusch\bav\Validator87c' => '../classes/validator/validators/Validator87c.php', + 'malkusch\bav\Validator90c' => '../classes/validator/validators/Validator90c.php', + 'malkusch\bav\Validator90d' => '../classes/validator/validators/Validator90d.php', + 'malkusch\bav\Validator90e' => '../classes/validator/validators/Validator90e.php', + 'malkusch\bav\Validator90g' => '../classes/validator/validators/Validator90g.php', + 'malkusch\bav\ValidatorA4b' => '../classes/validator/validators/ValidatorA4b.php', + 'malkusch\bav\ValidatorB9a' => '../classes/validator/validators/ValidatorB9a.php', + 'malkusch\bav\ValidatorB9b' => '../classes/validator/validators/ValidatorB9b.php', + 'malkusch\bav\ValidatorC1b' => '../classes/validator/validators/ValidatorC1b.php', + 'malkusch\bav\Configuration' => '../classes/configuration/Configuration.php', + 'malkusch\bav\FileValidator' => '../classes/dataBackend/file/validator/FileValidator.php', + 'malkusch\bav\LogUpdatePlan' => '../classes/dataBackend/update/LogUpdatePlan.php', + 'malkusch\bav\IconvEncoding' => '../classes/encoding/IconvEncoding.php', + 'malkusch\bav\FileException' => '../classes/util/exception/FileException.php', + 'malkusch\bav\LockException' => '../classes/util/exception/LockException.php', + 'malkusch\bav\SQLDataBackend' => '../classes/dataBackend/SQLDataBackend.php', + 'malkusch\bav\FieldException' => '../classes/dataBackend/file/validator/exception/FieldException.php', + 'malkusch\bav\PDODataBackend' => '../classes/dataBackend/pdo/PDODataBackend.php', + 'malkusch\bav\ValidatorChain' => '../classes/validator/ValidatorChain.php', + 'malkusch\bav\AgencyException' => '../classes/bank/exception/AgencyException.php', + 'malkusch\bav\FileDataBackend' => '../classes/dataBackend/file/FileDataBackend.php', + 'malkusch\bav\RegExpURIPicker' => '../classes/dataBackend/file/download/uripicker/RegExpURIPicker.php', + 'malkusch\bav\ISO8859Encoding' => '../classes/encoding/ISO8859Encoding.php', + 'malkusch\bav\ValidatorFactory' => '../classes/validator/ValidatorFactory.php', + 'malkusch\bav\FallbackURIPicker' => '../classes/dataBackend/file/download/uripicker/FallbackURIPicker.php', + 'malkusch\bav\FileParserContext' => '../classes/dataBackend/file/fileParser/FileParserContext.php', + 'malkusch\bav\EncodingException' => '../classes/encoding/exception/EncodingException.php', + 'malkusch\bav\ContextValidation' => '../classes/validator/ContextValidation.php', + 'malkusch\bav\URIPickerException' => '../classes/dataBackend/file/download/uripicker/exception/URIPickerException.php', + 'malkusch\bav\StatementContainer' => '../classes/dataBackend/pdo/StatementContainer.php', + 'malkusch\bav\ValidatorIteration' => '../classes/validator/ValidatorIteration.php', + 'malkusch\bav\ValidatorException' => '../classes/validator/exception/ValidatorException.php', + 'malkusch\bav\DownloaderException' => '../classes/dataBackend/file/download/exception/DownloaderException.php', + 'malkusch\bav\FileParserException' => '../classes/dataBackend/file/fileParser/exception/FileParserException.php', + 'malkusch\bav\DoctrineDataBackend' => '../classes/dataBackend/orm/doctrine/DoctrineDataBackend.php', + 'malkusch\bav\AutomaticUpdatePlan' => '../classes/dataBackend/update/AutomaticUpdatePlan.php', + 'malkusch\bav\ConfigurationLocator' => '../classes/configuration/ConfigurationLocator.php', + 'malkusch\bav\DefaultConfiguration' => '../classes/configuration/DefaultConfiguration.php', + 'malkusch\bav\DataBackendContainer' => '../classes/dataBackend/DataBackendContainer.php', + 'malkusch\bav\DataBackendException' => '../classes/dataBackend/exception/DataBackendException.php', + 'malkusch\bav\ConfigurationRegistry' => '../classes/configuration/ConfigurationRegistry.php', + 'malkusch\bav\BankNotFoundException' => '../classes/dataBackend/exception/BankNotFoundException.php', + 'malkusch\bav\NoMainAgencyException' => '../classes/dataBackend/exception/NoMainAgencyException.php', + 'malkusch\bav\ConfigurationException' => '../classes/configuration/ConfigurationException.php', + 'malkusch\bav\DataBackendIOException' => '../classes/dataBackend/exception/DataBackendIOException.php', + 'malkusch\bav\FileValidatorException' => '../classes/dataBackend/file/validator/exception/FileValidatorException.php', + 'malkusch\bav\ValidatorBankDependent' => '../classes/validator/ValidatorBankDependent.php', + 'malkusch\bav\ValidatorESERException' => '../classes/validator/exception/ValidatorESERException.php', + 'malkusch\bav\InvalidContextException' => '../classes/dataBackend/exception/InvalidContextException.php', + 'malkusch\bav\PDODataBackendContainer' => '../classes/dataBackend/pdo/PDODataBackendContainer.php', + 'malkusch\bav\FileDataBackendContainer' => '../classes/dataBackend/file/FileDataBackendContainer.php', + 'malkusch\bav\InvalidFilesizeException' => '../classes/dataBackend/file/validator/exception/InvalidFilesizeException.php', + 'malkusch\bav\DoctrineBackendContainer' => '../classes/dataBackend/orm/doctrine/DoctrineBackendContainer.php', + 'malkusch\bav\NoTempDirectoryException' => '../classes/util/exception/NoTempDirectoryException.php', + 'malkusch\bav\FileParserContextException' => '../classes/dataBackend/file/fileParser/exception/FileParserContextException.php', + 'malkusch\bav\InvalidLineLengthException' => '../classes/dataBackend/file/validator/exception/InvalidLineLengthException.php', + 'malkusch\bav\WeightedIterationValidator' => '../classes/validator/WeightedIterationValidator.php', + 'malkusch\bav\FileParserNotExistsException' => '../classes/dataBackend/file/fileParser/exception/FileParserNotExistsException.php', + 'malkusch\bav\UnsupportedEncodingException' => '../classes/encoding/exception/UnsupportedEncodingException.php', + 'malkusch\bav\ValidatorOutOfBoundsException' => '../classes/validator/exception/ValidatorOutOfBoundsException.php', + 'malkusch\bav\TransformationIterationValidator' => '../classes/validator/TransformationIterationValidator.php', + 'malkusch\bav\UndefinedAttributeAgencyException' => '../classes/bank/exception/UndefinedAttributeAgencyException.php', + 'malkusch\bav\UndefinedFileParserContextException' => '../classes/dataBackend/file/fileParser/exception/UndefinedFileParserContextException.php', + 'malkusch\bav\MissingAttributesDataBackendIOException' => '../classes/dataBackend/exception/MissingAttributesDataBackendIOException.php', + 'malkusch\bav\FileParserIOException' => '../classes/dataBackend/file/fileParser/exception/FileParserIOException.php', + 'malkusch\bav\ParseException' => '../classes/dataBackend/file/fileParser/exception/ParseException.php', ); diff --git a/autoloader/index/1.php b/autoloader/index/1.php deleted file mode 100644 index f08de921..00000000 --- a/autoloader/index/1.php +++ /dev/null @@ -1,26 +0,0 @@ - '../tests/TestSuite.php', - 'backendtest' => '../tests/BackendTest.php', - 'validatortest' => '../tests/ValidatorTest.php', - 'agencyquerytest' => '../tests/AgencyQueryTest.php', - 'crossprojecttest' => '../tests/CrossProjectTest.php', - 'verifyimporttest' => '../tests/VerifyImportTest.php', - 'dataconstrainttest' => '../tests/DataConstraintTest.php', - 'bav_checkagainsttestapis' => '../tests/checkAgainstTestAPIs.php', -); diff --git a/bin/bav-install.php b/bin/bav-install.php new file mode 100755 index 00000000..918c9836 --- /dev/null +++ b/bin/bav-install.php @@ -0,0 +1,25 @@ +#!/bin/env php + + * @license WTFPL + * @see DataBackend + */ + +namespace malkusch\bav; + +require_once __DIR__ . "/../autoloader/autoloader.php"; + +try { + ConfigurationRegistry::getConfiguration()->setAutomaticInstallation(false); + $databack = ConfigurationRegistry::getConfiguration()->getDatabackendContainer()->getDataBackend(); + + $databack->install(); + echo "Bundesbank file downloaded.\n"; + +} catch (DataBackendException $error) { + die("Installation failed: {$error->getMessage()}\n"); + +} diff --git a/bin/bav-uninstall.php b/bin/bav-uninstall.php new file mode 100755 index 00000000..55f02cba --- /dev/null +++ b/bin/bav-uninstall.php @@ -0,0 +1,27 @@ +#!/bin/env php + + * @license WTFPL + * @see DataBackend + */ + +namespace malkusch\bav; + +require_once __DIR__ . "/../autoloader/autoloader.php"; + +try { + $configuration = ConfigurationRegistry::getConfiguration(); + $configuration->setAutomaticInstallation(false); + $configuration->setUpdatePlan(null); + + $databack = $configuration->getDatabackendContainer()->getDataBackend(); + $databack->uninstall(); + echo "Bundesbank file removed.\n"; + +} catch (DataBackendException $error) { + die("Deinstallation failed: {$error->getMessage()}\n"); + +} diff --git a/bin/bav-update.php b/bin/bav-update.php new file mode 100755 index 00000000..09ec5eca --- /dev/null +++ b/bin/bav-update.php @@ -0,0 +1,24 @@ +#!/bin/env php + + * @license WTFPL + * @see DataBackend + */ + +namespace malkusch\bav; + +require_once __DIR__ . "/../autoloader/autoloader.php"; + +try { + ConfigurationRegistry::getConfiguration()->setUpdatePlan(null); + $bav = new BAV(); + $bav->update(); + echo "Bundesbank file downloaded.\n"; + +} catch (DataBackendException $error) { + die("Installation failed: {$error->getMessage()}\n"); + +} diff --git a/classes/BAV.php b/classes/BAV.php index 2c2adc42..d52e63f7 100644 --- a/classes/BAV.php +++ b/classes/BAV.php @@ -1,82 +1,236 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Facade for BAV's API. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This class provides methods for validation of German bank accounts. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * If you don't inject a {@link Configuration} the facade will use the + * {@link ConfigurationRegistry}. The registry provides per default the + * {@link DefaultConfiguration}. * - * - * @package classes * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @api + * @see ConfigurationRegistry */ -abstract class BAV { +class BAV +{ + + /** + * @var Configuration + */ + private $configuration; + /** + * @var DataBackend + */ + private $backend; + + /** + * @var ContextValidation + */ + private $contextValidation; - static protected /** - * @var BAV_Encoding + * Inject the configuration. + * + * If the $configuration is null the configuration from + * {@link ConfigurationRegistry::getConfiguration()} will be used. + * + * @see ConfigurationRegistry */ - $encoding; + public function __construct(Configuration $configuration = null) + { + if (is_null($configuration)) { + $configuration = ConfigurationRegistry::getConfiguration(); + } + $this->configuration = $configuration; - static public function classConstructor() { - try { - self::setEncoding('UTF-8'); - - } catch (BAV_EncodingException_Unsupported $e) { - self::setEncoding('ISO-8859-15'); + $this->backend = $configuration->getDataBackendContainer()->getDataBackend(); + $this->contextValidation = new ContextValidation($this->backend); + } + + /** + * Returns the data backend + * + * @return DataBackend + */ + public function getDataBackend() + { + return $this->backend; + } + + /** + * Updates bav with a new bundesbank file. + * + * You might consider enabling automatic update with setting + * AutomaticUpdatePlan as configuration. + * + * @see AutomaticUpdatePlan + * @see Configuration::setUpdatePlan() + * @throws DataBackendException + */ + public function update() + { + $this->getDataBackend()->update(); + } + + /** + * Returns true if both the bank exists and the account is valid. + * + * @throws DataBackendException for some reason the validator might not be implemented + * @param string $bankID + * @param string $account + * @see isValidBank() + * @see getBank() + * @see Bank::isValid() + * @return bool + */ + public function isValidBankAccount($bankID, $account) + { + try { + $bank = $this->getBank($bankID); + return $bank->isValid($account); + + } catch (BankNotFoundException $e) { + return false; + } } + /** - * If you want to use another encoding + * Returns true if the account is valid for the current context. + * + * You have to have called isValidBank() before! If the current context + * is no valid bank every account will validate to true. * - * @throws BAV_EncodingException_Unsupported - * @param mixed $encoding - * @see BAV_Encoding + * @param string $account + * @see isValidBank() + * @see ContextValidation::isValidAccount() + * @throws InvalidContextException isValidBank() was not called before. + * @return bool */ - static public function setEncoding($encoding) { - self::$encoding = ($encoding instanceof BAV_Encoding) - ? $encoding - : BAV_Encoding::getInstance($encoding); + public function isValidAccount($account) + { + return $this->contextValidation->isValidAccount($account); } + /** - * @return BAV_Version version of BAV + * Returns true if a bank exists + * + * @throws DataBackendException + * @param string $bankID + * @return bool + * @see ContextValidation::isValidBank() */ - static public function get_bav_version() { - return new BAV_Version('0.27'); + public function isValidBank($bankID) + { + return $this->contextValidation->isValidBank($bankID); } + /** - * Returns the version of the API. Note that different BAV versions - * may have the same API version. + * Every bank has one main agency. * - * @return BAV_Version version of BAV's API + * This agency is not included in getAgencies(). + * + * @throws DataBackendException + * @throws BankNotFoundException + * @param string $bankID Bank id (Bankleitzahl) + * @see Bank::getMainAgency() + * @see getAgencies() + * @return Agency */ - static public function get_bav_api_version() { - return new BAV_Version('2.4'); + public function getMainAgency($bankID) + { + return $this->getBank($bankID)->getMainAgency(); } + /** + * A bank may have more agencies. + * + * The main agency is not included in this list. + * + * @param string $bankID Bank id (Bankleitzahl) + * @throws DataBackendException + * @throws BankNotFoundException + * @return Agency[] + */ + public function getAgencies($bankID) + { + return $this->getBank($bankID)->getAgencies(); + } + + /** + * With this method you get the Bank objects for certain IDs. Note + * that a call to this method with an identical id will return the same + * objects. + * + * @throws BankNotFoundException + * @throws DataBackendException + * @param string $bankID + * @return Bank + * @see DataBackend::isValidBank() + */ + public function getBank($bankID) + { + return $this->backend->getBank($bankID); + } + + /** + * Returns bank agencies for a given BIC. + * + * @param string $bic BIC + * @return Agency[] + */ + public function getBICAgencies($bic) + { + return $this->backend->getBICAgencies(BICUtil::normalize($bic)); + } + /** + * Returns if a bic is valid. + * + * @param string $bic BIC + * @return bool + */ + public function isValidBIC($bic) + { + return $this->backend->isValidBIC(BICUtil::normalize($bic)); + } + + /** + * Returns the third call back parameter for filter_var() for validating + * a bank. + * + * filter_var($bankID, FILTER_CALLBACK, $bav->getValidBankFilterCallback()); + * + * @return array + * @see isValidBank() + * @see filter_var() + */ + public function getValidBankFilterCallback() + { + return $this->contextValidation->getValidBankFilterCallback(); + } + + /** + * Returns the third call back parameter for filter_var() for validating + * a bank account. + * + * filter_var($account, FILTER_CALLBACK, $bav->getValidBankFilterCallback()); + * + * @return array + * @see isValidAccount() + * @see filter_var() + */ + public function getValidAccountFilterCallback() + { + return $this->contextValidation->getValidAccountFilterCallback(); + } } diff --git a/classes/BAV_Version.php b/classes/BAV_Version.php deleted file mode 100644 index 7c1095ca..00000000 --- a/classes/BAV_Version.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_Version extends BAV { - - - static private - /** - * @var BAV_Version - */ - $phpVersion; - - - private - /** - * @var array - */ - $elements = array(), - /** - * @var string - */ - $separator = ''; - - - /** - * @param string $version - * @param string $separator - */ - public function __construct($version, $separator = '.') { - $this->separator = $separator; - $this->elements = explode($separator, $version); - } - - - /** - * @return boolean - */ - public function isGreater(BAV_Version $version) { - $thoseElements = $version->getElements(count($this->elements)); - $thisElements = $this->getElements(count($thoseElements)); - - foreach ($thisElements as $i => $thisElement) { - if ($thoseElements[$i] !== $thisElement) { - return $this->_isGreater($thisElement, $thoseElements[$i]); - - } - - } - return false; - } - - - /** - * @return boolean - */ - public function equals(BAV_Version $version) { - $thoseElements = $version->getElements(count($this->elements)); - $thisElements = $this->getElements(count($thoseElements)); - - return $thoseElements == $thisElements; - } - - - /** - * @return boolean - */ - public function isLesser(BAV_Version $version) { - return ! $this->equals($version) && ! $this->isGreater($version); - } - - - /** - * @return string - */ - public function getString() { - return implode($this->separator, $this->elements); - } - - - /** - * @return string - */ - public function getNormalizedVersion() { - $elements = array_merge($this->elements); - for ($i = count($elements) - 1; $i > 0; $i--) { - $lastElement = array_pop($elements); - if ($lastElement !== '0') { - $elements[] = $lastElement; - break; - - } - - } - return implode($this->separator, $elements); - } - - - /** - * @param string $left - * @param string $right - * @return boolean - */ - private function _isGreater($left, $right) { - return $left > $right; - } - - - /** - * @param int $padding - * @return array - */ - private function getElements($padding = null) { - if (is_null($padding) || count($this->elements) >= $padding) { - return $this->elements; - - } - return array_pad($this->elements, $padding, '0'); - } - - - /** - * @return BAV_Version - */ - static public function getPHPVersion() { - if (empty(self::$phpVersion)) { - self::$phpVersion = new BAV_Version(phpversion()); - - } - return self::$phpVersion; - } - - -} - - -?> \ No newline at end of file diff --git a/classes/autoloader/BAV_Autoloader.php b/classes/autoloader/BAV_Autoloader.php deleted file mode 100644 index 81346f64..00000000 --- a/classes/autoloader/BAV_Autoloader.php +++ /dev/null @@ -1,74 +0,0 @@ - + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see BAV::getAgencies() + * @see BAV::getBICAgencies() + * @see BAV::getMainAgency() + * @api + */ +class Agency +{ + + /** + * @var int + */ + private $id = 0; + + /** + * @var Bank + */ + private $bank; + + /** + * @var string + */ + private $bic = ''; + + /** + * @var string + */ + private $city = ''; + + /** + * @var string + */ + private $pan = ''; + + /** + * @var string + */ + private $postcode = ''; + + /** + * @var string + */ + private $shortTerm = ''; + + /** + * @var string + */ + private $name = ''; + + /** + * Don't create this object directly. + * + * @param int $id + * @param string $name + * @param string $shortTerm + * @param string $city + * @param string $postcode + * @param string $bic might be empty + * @param string $pan might be empty + * @internal + * @see BAV::getAgencies() + * @see BAV::getMainAgency() + * @see BAV::getBICAgencies() + */ + public function __construct($id, Bank $bank, $name, $shortTerm, $city, $postcode, $bic = '', $pan = '') + { + $this->id = (int)$id; + $this->bank = $bank; + $this->bic = $bic; + $this->postcode = $postcode; + $this->city = $city; + $this->name = $name; + $this->shortTerm = $shortTerm; + $this->pan = $pan; + } + + /** + * @return bool + */ + public function isMainAgency() + { + return $this->bank->getMainAgency() === $this; + } + + /** + * @return Bank + */ + public function getBank() + { + return $this->bank; + } + + /** + * @return int + */ + public function getID() + { + return $this->id; + } + + /** + * @return string + */ + public function getPostcode() + { + return $this->postcode; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getShortTerm() + { + return $this->shortTerm; + } + + /** + * @return bool + */ + public function hasPAN() + { + return ! empty($this->pan); + } + + /** + * @return bool + */ + public function hasBIC() + { + return ! empty($this->bic); + } + + /** + * @throws UndefinedAttributeAgencyException + * @return string + */ + public function getPAN() + { + if (! $this->hasPAN()) { + throw new UndefinedAttributeAgencyException($this, 'pan'); + + } + return $this->pan; + } + + /** + * @throws UndefinedAttributeAgencyException + * @return string + */ + public function getBIC() + { + if (! $this->hasBIC()) { + throw new UndefinedAttributeAgencyException($this, 'bic'); + + } + return $this->bic; + } +} diff --git a/classes/bank/BAV_Agency.php b/classes/bank/BAV_Agency.php deleted file mode 100644 index d9ba465c..00000000 --- a/classes/bank/BAV_Agency.php +++ /dev/null @@ -1,176 +0,0 @@ -getMainAgency() or BAV_Bank->getAgencies(). - * - * - * Copyright (C) 2006 Markus Malkusch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage bank - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_Agency extends BAV { - - - private - /** - * @var int - */ - $id = 0, - /** - * @var BAV_Bank - */ - $bank, - /** - * @var string - */ - $bic = '', - /** - * @var string - */ - $city = '', - /** - * @var string - */ - $pan = '', - /** - * @var string - */ - $postcode = '', - /** - * @var string - */ - $shortTerm = '', - /** - * @var string - */ - $name = ''; - - - /** - * Don't create this object directly. Use BAV_Bank->getMainAgency() - * or BAV_Bank->getAgencies(). - * - * @param int $id - * @param string $name - * @param string $shortTerm - * @param string $city - * @param string $postcode - * @param string $bic might be empty - * @param string $pan might be empty - */ - public function __construct($id, BAV_Bank $bank, $name, $shortTerm, $city, $postcode, $bic = '', $pan = '') { - $this->id = (int)$id; - $this->bank = $bank; - $this->bic = $bic; - $this->postcode = $postcode; - $this->city = $city; - $this->name = $name; - $this->shortTerm = $shortTerm; - $this->pan = $pan; - } - /** - * @return bool - */ - public function isMainAgency() { - return $this->bank->getMainAgency() === $this; - } - /** - * @return BAV_Bank - */ - public function getBank() { - return $this->bank; - } - /** - * @return int - */ - public function getID() { - return $this->id; - } - /** - * @return string - */ - public function getPostcode() { - return $this->postcode; - } - /** - * @return string - */ - public function getCity() { - return $this->city; - } - /** - * @return string - */ - public function getName() { - return $this->name; - } - /** - * @return string - */ - public function getShortTerm() { - return $this->shortTerm; - } - /** - * @return bool - */ - public function hasPAN() { - return ! empty($this->pan); - } - /** - * @return bool - */ - public function hasBIC() { - return ! empty($this->bic); - } - /** - * @throws BAV_AgencyException_UndefinedAttribute - * @return string - */ - public function getPAN() { - if (! $this->hasPAN()) { - throw new BAV_AgencyException_UndefinedAttribute($this, 'pan'); - - } - return $this->pan; - } - /** - * @throws BAV_AgencyException_UndefinedAttribute - * @return string - */ - public function getBIC() { - if (! $this->hasBIC()) { - throw new BAV_AgencyException_UndefinedAttribute($this, 'bic'); - - } - return $this->bic; - } - - -} - - -?> \ No newline at end of file diff --git a/classes/bank/BAV_Bank.php b/classes/bank/Bank.php similarity index 55% rename from classes/bank/BAV_Bank.php rename to classes/bank/Bank.php index 6d6084d2..d6a1dad6 100644 --- a/classes/bank/BAV_Bank.php +++ b/classes/bank/Bank.php @@ -1,17 +1,15 @@ isValid(String $account)) and - * has a bank ID, a main agency (BAV_Bank->getMainAgency()) and optionally some - * more agencies (BAV_Bank->getAgencies()). Note that the main agency is not - * included in the array BAV_Bank->getAgencies() (which could even be empty). + * A bank can validate a bank account (Bank->isValid(String $account)) and + * has a bank ID, a main agency (Bank->getMainAgency()) and optionally some + * more agencies (Bank->getAgencies()). Note that the main agency is not + * included in the array Bank->getAgencies() (which could even be empty). * - * You should not create BAV_Bank objects directly. Use a BAV_DataBackend object - * to get a BAV_Bank object. + * You should not create Bank objects directly. Use a DataBackend object + * to get a Bank object. * * * Copyright (C) 2006 Markus Malkusch @@ -34,112 +32,131 @@ * @package classes * @subpackage bank * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Bank extends BAV { - +class Bank +{ - private /** * @var string */ - $bankID = '', + private $bankID = ''; + /** * @var string */ - $validationType = '', + private $validationType = ''; + /** - * @var BAV_Validator + * @var Validator */ - $validator, + private $validator; + /** - * @var BAV_DataBackend + * @var DataBackend */ - $dataBackend, + private $dataBackend; + /** - * @var BAV_Agency + * @var Agency */ - $mainAgency, + private $mainAgency; + /** * @var Array */ - $agencies; - + private $agencies; /** - * Do not even think to use new BAV_Bank()! - * Go and use BAV_DataBackend->getBank($bankID). + * Do not even think to use new Bank()! + * Go and use DataBackend->getBank($bankID). * * @param string $bankID * @param string $validationType */ - public function __construct(BAV_DataBackend $dataBackend, $bankID, $validationType) { + public function __construct(DataBackend $dataBackend, $bankID, $validationType) + { $this->dataBackend = $dataBackend; $this->bankID = $bankID; $this->validationType = $validationType; } + /** * @return string */ - public function getValidationType() { + public function getValidationType() + { return $this->validationType; } + /** * @return string */ - public function getBankID() { + public function getBankID() + { return (string) $this->bankID; } + /** * Every bank has one main agency. This agency is not included in getAgencies(). * - * @throws BAV_DataBackendException - * @return BAV_Agency + * @throws DataBackendException + * @return Agency */ - public function getMainAgency() { + public function getMainAgency() + { if (is_null($this->mainAgency)) { - $this->mainAgency = $this->dataBackend->_getMainAgency($this); - + $this->mainAgency = $this->dataBackend->getMainAgency($this); + } return $this->mainAgency; } + /** * A bank may have more agencies. * - * @throws BAV_DataBackendException - * @return array + * @throws DataBackendException + * @return Agency[] */ - public function getAgencies() { + public function getAgencies() + { if (is_null($this->agencies)) { - $this->agencies = $this->dataBackend->_getAgencies($this); - + $this->agencies = $this->dataBackend->getAgenciesForBank($this); + } return $this->agencies; } + + /** + * @internal + */ + public function setDataBackend(DataBackend $backend) + { + $this->dataBackend = $backend; + } + /** * Use this method to check your bank account. * - * @throws BAV_ValidatorException_NotExists for some reason the validator might not be implemented * @param string $account * @return bool */ - public function isValid($account) { + public function isValid($account) + { return $this->getValidator()->isValid($account); } + /** - * @throws BAV_ValidatorException_NotExists - * @return BAV_Validator + * @return Validator */ - public function getValidator() { + public function getValidator() + { if (is_null($this->validator)) { - $this->validator = BAV_Validator::getInstance($this); - + $factory = new ValidatorFactory(); + $this->validator = $factory->build($this); + } return $this->validator; } - - } - - -?> \ No newline at end of file diff --git a/classes/bank/exception/BAV_AgencyException.php b/classes/bank/exception/AgencyException.php similarity index 78% rename from classes/bank/exception/BAV_AgencyException.php rename to classes/bank/exception/AgencyException.php index 4eba75c6..3f35704f 100644 --- a/classes/bank/exception/BAV_AgencyException.php +++ b/classes/bank/exception/AgencyException.php @@ -1,6 +1,6 @@ @@ -23,30 +23,27 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_AgencyException extends RuntimeException { - +class AgencyException extends BAVException +{ - private /** - * @var BAV_Agency + * @var Agency */ - $agency; - - - public function __construct(BAV_Agency $agency) { + private $agency; + + public function __construct(Agency $agency) + { $this->agency = $agency; } + /** - * @return BAV_Agency + * @return Agency */ - public function getAgency() { + public function getAgency() + { return $this->agency; } - - } - - -?> \ No newline at end of file diff --git a/classes/bank/exception/BAV_AgencyException_UndefinedAttribute.php b/classes/bank/exception/UndefinedAttributeAgencyException.php similarity index 80% rename from classes/bank/exception/BAV_AgencyException_UndefinedAttribute.php rename to classes/bank/exception/UndefinedAttributeAgencyException.php index a0052e7e..9ff49529 100644 --- a/classes/bank/exception/BAV_AgencyException_UndefinedAttribute.php +++ b/classes/bank/exception/UndefinedAttributeAgencyException.php @@ -1,7 +1,6 @@ @@ -24,34 +23,31 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_AgencyException_UndefinedAttribute extends BAV_AgencyException { - +class UndefinedAttributeAgencyException extends AgencyException +{ - private /** * @var string */ - $attribute = ''; - - + private $attribute = ''; + /** * @param string $attribute */ - public function __construct(BAV_Agency $agency, $attribute) { + public function __construct(Agency $agency, $attribute) + { parent::__construct($agency); $this->attribute = $attribute; } + /** * @return string */ - public function getAttribute() { + public function getAttribute() + { return $this->attribute; } - - } - - -?> \ No newline at end of file diff --git a/classes/configuration/Configuration.php b/classes/configuration/Configuration.php new file mode 100644 index 00000000..63023675 --- /dev/null +++ b/classes/configuration/Configuration.php @@ -0,0 +1,146 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see ConfigurationRegistry + * @api + */ +class Configuration +{ + + /** + * @var bool + */ + private $automaticInstallation; + + /** + * @var Encoding + */ + private $encoding; + + /** + * @var DataBackendContainer + */ + private $backendContainer; + + /** + * @var UpdatePlan + */ + private $updatePlan; + + /** + * @var string + */ + private $tempDirectory; + + /** + * Sets the update plan. + * + * Set to null if you don't want to use an update plan. + */ + public function setUpdatePlan(UpdatePlan $updatePlan = null) + { + $this->updatePlan = $updatePlan; + } + + /** + * Gets the update plan. + * + * @return UpdatePlan|null + */ + public function getUpdatePlan() + { + return $this->updatePlan; + } + + /** + * Turns automatic installation on or off. + * + * If automatic installation is activated {@link DataBackendContainer} will + * check if it is installed and if not install the backend. + * + * @see DataBackend::install() + * @param bool $automaticInstallation Set true to turn installation on + */ + public function setAutomaticInstallation($automaticInstallation) + { + $this->automaticInstallation = $automaticInstallation; + } + + /** + * Returns true if automatic installation is activated. + * + * @return bool + */ + public function isAutomaticInstallation() + { + return $this->automaticInstallation; + } + + /** + * Sets the data {@link DataBackendContainer}. + */ + public function setDataBackendContainer(DataBackendContainer $backendContainer) + { + $this->backendContainer = $backendContainer; + } + + /** + * Returns the {@link DataBackendContainer}. + * + * @return DataBackendContainer + */ + public function getDataBackendContainer() + { + return $this->backendContainer; + } + + /** + * Sets the encoding. + */ + public function setEncoding(Encoding $encoding) + { + $this->encoding = $encoding; + } + + /** + * Returns the encoding. + * + * @return Encoding + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * Sets the temporary directory. + * + * If you set a temporary directory BAV will use this for temporary files. + * This option is optional. If it is not set the system's path will be used. + * + * The temporary directory is used for the installation and update process. + * + * @param string $tempDirectory + */ + public function setTempDirectory($tempDirectory) + { + $this->tempDirectory = $tempDirectory; + } + + /** + * Returns the optional configured temporary directory. + * + * @return string + */ + public function getTempDirectory() + { + return $this->tempDirectory; + } +} diff --git a/classes/configuration/ConfigurationException.php b/classes/configuration/ConfigurationException.php new file mode 100644 index 00000000..1ee97409 --- /dev/null +++ b/classes/configuration/ConfigurationException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class ConfigurationException extends BAVException +{ + +} diff --git a/classes/configuration/ConfigurationLocator.php b/classes/configuration/ConfigurationLocator.php new file mode 100644 index 00000000..da1248ae --- /dev/null +++ b/classes/configuration/ConfigurationLocator.php @@ -0,0 +1,59 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see ConfigurationRegistry + */ +class ConfigurationLocator +{ + + /** + * @var string[] + */ + private $paths = array(); + + /** + * Sets the paths where a location is expected. + * + * Those paths may be relative to the include_path. + * + * @param string[] $paths + */ + public function __construct($paths = array()) + { + $this->paths = $paths; + } + + /** + * Locates a configuration. + * + * @return Configuration|null + * @throws ConfigurationException + */ + public function locate() + { + foreach ($this->paths as $path) { + $resolvedPath = stream_resolve_include_path($path); + if (! $resolvedPath) { + continue; + + } + $configuration = require $resolvedPath; + if (! $configuration instanceof Configuration) { + throw new ConfigurationException( + "$resolvedPath must return a malkusch\\bav\\Configuration object." + ); + + } + return $configuration; + + } + return null; + } +} diff --git a/classes/configuration/ConfigurationRegistry.php b/classes/configuration/ConfigurationRegistry.php new file mode 100644 index 00000000..be925e97 --- /dev/null +++ b/classes/configuration/ConfigurationRegistry.php @@ -0,0 +1,90 @@ + + * setDataBackendContainer(new PDODataBackendContainer($pdo)); + * + * $configuration->setUpdatePlan(new AutomaticUpdatePlan()); + * + * return $configuration; + * + * + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see Configuration + * @api + */ +class ConfigurationRegistry +{ + + const BAV_PATH = "/../../configuration.php"; + + const INCLUDE_PATH = "bav/configuration.php"; + + /** + * @var Configuration + */ + private static $configuration; + + /** + * locate a configuration or register the default configuration. + * + * You may define the file bav/configuration.php. This file should return + * a Configuration object. + * + * @see DefaultConfiguration + * @throws ConfigurationException + */ + public static function classConstructor() + { + $locator = new ConfigurationLocator(array( + __DIR__ . self::BAV_PATH, + self::INCLUDE_PATH + )); + $configuration = $locator->locate(); + if ($configuration == null) { + $configuration = new DefaultConfiguration(); + + } + self::setConfiguration($configuration); + } + + /** + * Register a configuration programmatically. + * + * Alternatively you can provide the file bav/configuration.php which + * returns a {@link Configuration} object. + */ + public static function setConfiguration(Configuration $configuration) + { + self::$configuration = $configuration; + } + + /** + * Returns the configuration + * + * @return Configuration + */ + public static function getConfiguration() + { + return self::$configuration; + } +} diff --git a/classes/configuration/DefaultConfiguration.php b/classes/configuration/DefaultConfiguration.php new file mode 100644 index 00000000..52497418 --- /dev/null +++ b/classes/configuration/DefaultConfiguration.php @@ -0,0 +1,42 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @api + */ +class DefaultConfiguration extends Configuration +{ + + public function __construct() + { + $this->setAutomaticInstallation(true); + + $this->setUpdatePlan(new LogUpdatePlan()); + + $this->setDataBackendContainer(new FileDataBackendContainer()); + + $encoding = null; + try { + $encoding = Encoding::getInstance("UTF-8"); + + } catch (UnsupportedEncodingException $e) { + trigger_error("UTF-8 is not supported; bav is falling back to ISO-8859-15", E_WARNING); + $encoding = Encoding::getInstance("ISO-8859-15"); + + } + $this->setEncoding($encoding); + } +} diff --git a/classes/dataBackend/BAV_DataBackend.php b/classes/dataBackend/BAV_DataBackend.php deleted file mode 100644 index 94f08379..00000000 --- a/classes/dataBackend/BAV_DataBackend.php +++ /dev/null @@ -1,157 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -abstract class BAV_DataBackend extends BAV { - - - protected - /** - * @var array All created BAV_Bank objects - */ - $instances = array(); - - - /** - * You have to call this method to synchronize you're datastructure to the - * data of the Bundesbank. - * - * @throws BAV_DataBackendException - */ - abstract public function update(); - /** - * Removes the databackend physically. - * - * @throws BAV_DataBackendException - */ - abstract public function uninstall(); - /** - * Installs the databackend. An implementation of install() should also - * call update() to synchronize to the Bundebank. - * - * @throws BAV_DataBackendException - */ - abstract public function install(); - /** - * With this method you get the BAV_Bank objects for certain IDs. Note - * that a call to this method with an identical id will return the same - * objects. - * - * @throws BAV_DataBackendException_BankNotFound - * @throws BAV_DataBackendException - * @param string - * @return BAV_Bank - */ - public function getBank($bankID) { - if (! isset($this->instances[$bankID])) { - $this->instances[$bankID] = $this->getNewBank($bankID); - - } - return $this->instances[$bankID]; - } - /** - * Perhaps you just want to know if a bank exists. - * - * @throws BAV_DataBackendException - * @param String $bankID - * @return bool - */ - public function bankExists($bankID) { - try { - $this->getBank($bankID); - return true; - - } catch (BAV_DataBackendException_BankNotFound $e) { - return false; - - } - } - /** - * Returns an array with all banks. If you implement this method you should - * also take care that $instances is used an will be filled correctly in order - * to garantee that there will never exist two identical objects. - * - * @throws BAV_DataBackendException - * @return array - */ - abstract public function getAllBanks(); - /** - * This method will be called by getBank() if getBank() thinks it is necessary to - * create a new object. You have to return the new object and have not to take care - * about $instances. getBank() cares about $instances. Throw a BAV_DataBackendException_BankNotFound - * if the bank does not exist. - * - * @throws BAV_DataBackendException - * @throws BAV_DataBackendException_BankNotFound if the bank does not exist - * @param string - * @return BAV_Bank - */ - abstract protected function getNewBank($bankID); - /** - * YOU SHOULD NOT CALL THIS METHOD! - * Use BAV_Bank->getMainAgency() - * - * If you implement this method you should return the appropriate BAV_Agency object. This - * method is called by BAV_Bank->getMainAgency(), if the BAV_Bank object doesn't know its - * main agency. - * - * @throws BAV_DataBackendException - * @return BAV_Agency - * @see BAV_Bank::getMainAgency() - */ - abstract public function _getMainAgency(BAV_Bank $bank); - /** - * YOU SHOULD NOT CALL THIS METHOD! - * Use BAV_Bank->getAgencies() - * - * If you implement this method you should return an array with the appropriate BAV_Agency - * objects. This method is called by BAV_Bank->getAgencies(), if the BAV_Bank object doesn't - * know its agencies. A bank may have no agencies and will return an empty array. - * - * @throws BAV_DataBackendException - * @see BAV_Bank::getAgencies() - * @return array - */ - abstract public function _getAgencies(BAV_Bank $bank); - - -} - - -?> \ No newline at end of file diff --git a/classes/dataBackend/BAV_DataBackend_File.php b/classes/dataBackend/BAV_DataBackend_File.php deleted file mode 100644 index ab859c89..00000000 --- a/classes/dataBackend/BAV_DataBackend_File.php +++ /dev/null @@ -1,530 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @FIXME BAV_DataBackend_File is broken as Bundesbank appends new Banks at the end of the file - */ -class BAV_DataBackend_File extends BAV_DataBackend { - - - const DOWNLOAD_URI = "http://www.bundesbank.de/Redaktion/DE/Standardartikel/Kerngeschaeftsfelder/Unbarer_Zahlungsverkehr/bankleitzahlen_download.html"; - - - private - /** - * @var array - */ - $contextCache = array(), - /** - * @var BAV_FileParser - */ - $parser; - - - /** - * @param String $file The data source - */ - public function __construct($file = null) { - $this->parser = new BAV_FileParser($file); - } - - - /** - * For the file of March 8th 2010 (blz_20100308.txt) - * Bundesbank appended new banks at the end of the file. - * That broked binary search. This method sorts the lines so - * that binary search is working again. - * - * Be aware that this needs some amount of memory. - * - * @param String $file - * @throws BAV_DataBackendException_IO - */ - private function sortFile($file) { - //read the unordered bank file - $lines = file($file); - if (! is_array($lines) || empty($lines)) { - throw new BAV_DataBackendException_IO("Could not read lines in '$file'."); - - } - - //build a sorted index for the bankIDs - $index = array(); - foreach ($lines as $line => $data) { - $bankID = substr($data, BAV_FileParser::BANKID_OFFSET, BAV_FileParser::BANKID_LENGTH); - $index[$line] = $bankID; - - } - asort($index); - - //write a sorted bank file atomically - $temp = tempnam(self::getTempdir(), "BAV_"); - $tempH = fopen($temp, 'w'); - if (! ($temp && $tempH)) { - throw new BAV_DataBackendException_IO("Could not open a temporary file."); - - } - foreach (array_keys($index) as $line) { - $data = $lines[$line]; - - $writtenBytes = fputs($tempH, $data); - if ($writtenBytes != strlen($data)) { - throw new BAV_DataBackendException_IO("Could not write sorted data: '$data' into $temp."); - - } - - } - fclose($tempH); - $this->safeRename($temp, $file); - } - - - /** - * @see BAV_DataBackend::uninstall() - * @throws BAV_DataBackendException_IO - */ - public function uninstall() { - if (! unlink($this->parser->getFile())) { - throw new BAV_DataBackendException_IO(); - - } - } - /** - * @see BAV_DataBackend::install() - * @throws BAV_DataBackendException_IO - */ - public function install() { - $this->update(); - } - /** - * This method works only if your PHP is compiled with cURL. - * TODO: test this with a proxy - * - * @see BAV_DataBackend::update() - * @throws BAV_DataBackendException_IO - */ - public function update() { - $ch = curl_init(self::DOWNLOAD_URI); - if (! is_resource($ch)) { - throw new BAV_DataBackendException_IO(); - - } - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $content = curl_exec($ch); - $curl_info = curl_getinfo($ch); - if ($curl_info['http_code'] >= 400) { - throw new BAV_DataBackendException_IO( - sprintf( - "Failed to download '%s'. HTTP Code: %d", - self::DOWNLOAD_URI, - $curl_info['http_code'] - ) - ); - } - if (! $content) { - throw new BAV_DataBackendException_IO( - "Failed to download '" . self::DOWNLOAD_URI . "'." - ); - - } - $isTXT = preg_match('/Bankleitzahlendateien ungepackt.+href *= *"([^"]+\.txt[^"]*)"/sU', $content, $txtMatches); - $isZIP = (exec('unzip -v') == '') - ? false - : preg_match('/Bankleitzahlendateien gepackt.+href *= *"([^"]+\.zip[^"]*)"/sU', $content, $zipMatches); - - /** - * There is an unresolved bug, that doesn't allow to uncompress - * the zip archive. Zip support is disabled until it's repaired. - * - * @see http://sourceforge.net/forum/message.php?msg_id=7555232 - * TODO enable Zip support - */ - $isZIP = false; - - if (! ($isTXT || $isZIP)) { - throw new BAV_DataBackendException("Could not find a file."); - - } - - $temp = tempnam(self::getTempdir(), "BAV_"); - $tempH = fopen($temp, 'w'); - if (! ($temp && $tempH)) { - throw new BAV_DataBackendException_IO(); - - } - $path = $isZIP ? $zipMatches[1] : $txtMatches[1]; - if (strlen($path) > 0 && $path{0} != "/") { - $path = sprintf("/%s/%s", dirname(self::DOWNLOAD_URI), $path); - - } - $pathParts = explode('/', $path); - foreach($pathParts as $i => $part) { - switch ($part) { - case '..': - unset($pathParts[$i-1]); - - case '.': - unset($pathParts[$i]); - break; - } - - } - $path = implode('/', $pathParts); - $urlParts = parse_url(self::DOWNLOAD_URI); - $url = sprintf("%s://%s%s", $urlParts["scheme"], $urlParts["host"], $path); - - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_FILE, $tempH); - if (! curl_exec($ch)) { - fclose($tempH); - unlink($temp); - throw new BAV_DataBackendException_IO( - curl_error($ch), curl_errno($ch) - ); - - } - fclose($tempH); - curl_close($ch); - - if ($isZIP) { - $file = tempnam(self::getTempdir(), "BAV_"); - if (! $file) { - unlink($temp); - throw new BAV_DataBackendException_IO(); - - } - system('unzip -qqp '.$temp.' > '.$file, $error); - if (! unlink($temp) || $error !== 0) { - unlink($file); - throw new BAV_DataBackendException_IO(); - - } - - } else { - $file = $temp; - - } - - // blz_20100308.txt is not sorted. - $parser = new BAV_FileParser($file); - $lastBankID = $parser->getBankID($parser->getLines()); - if ($lastBankID < 80000000) { - $this->sortFile($file); - - } - - $this->safeRename($file, $this->parser->getFile()); - } - - - /** - * Renames a file atomically between different filesystems. - * - * @param String $source path of the source - * @param String $destination path of the destination - * @throws BAV_DataBackendException_IO - */ - private function safeRename($source, $destination) { - $isRenamed = @rename($source, $destination); - if ($isRenamed) { - return; - - } - - // copy to the target filesystem - $tempFileOnSameFS = "$destination.tmp"; - - $isCopied = copy($source, $tempFileOnSameFS); - if (! $isCopied) { - throw new BAV_DataBackendException_IO( - "failed to copy $source to $tempFileOnSameFS." - ); - - } - - $isUnlinked = unlink($source); - if (! $isUnlinked) { - trigger_error("Failed to unlink $source."); - - } - - $isRenamed = rename($tempFileOnSameFS, $destination); - if (! $isRenamed) { - throw new BAV_DataBackendException_IO( - "failed to rename $tempFileOnSameFS to $destination." - ); - - } - } - - - /** - * @throws BAV_DataBackendException_IO - * @throws BAV_DataBackendException - * @return array - * @see BAV_DataBackend::getAllBanks() - */ - public function getAllBanks() { - try { - for ($i = 0; $i < $this->parser->getLines(); $i++) { - if (isset($this->instances[$this->parser->getBankID($i)])) { - continue; - - } - $line = $this->parser->readLine($i); - $bank = $this->parser->getBank($this, $line); - $this->instances[$bank->getBankID()] = $bank; - $this->contextCache[$bank->getBankID()] = new BAV_FileParserContext($i); - } - return array_values($this->instances); - - } catch (BAV_FileParserException_IO $e) { - throw new BAV_DataBackendException_IO(); - - } catch (BAV_FileParserException $e) { - throw new BAV_DataBackendException(); - - } - } - /** - * @throws BAV_DataBackendException_IO - * @throws BAV_DataBackendException_BankNotFound - * @param String $bankID - * @see BAV_DataBackend::getNewBank() - * @return BAV_Bank - */ - public function getNewBank($bankID) { - try { - $this->parser->rewind(); - /** - * TODO Binary Search is also possible on $this->contextCache, - * to reduce the interval of $offset and $end; - */ - if (isset($this->contextCache[$bankID])) { - return $this->findBank( - $bankID, - $this->contextCache[$bankID]->getLine(), - $this->contextCache[$bankID]->getLine()); - - } else { - return $this->findBank($bankID, 0, $this->parser->getLines()); - - } - - } catch (BAV_FileParserException $e) { - throw new BAV_DataBackendException_IO(); - - } - } - /** - * @throws BAV_DataBackendException_BankNotFound - * @throws BAV_FileParserException_ParseError - * @throws BAV_FileParserException_IO - * @param int $bankID - * @param int $offset the line number to start - * @param int $length the line count - * @return BAV_Bank - */ - private function findBank($bankID, $offset, $end) { - if ($end - $offset < 0) { - throw new BAV_DataBackendException_BankNotFound($bankID); - - } - $line = $offset + (int)(($end - $offset) / 2); - $blz = $this->parser->getBankID($line); - - /** - * This handling is bad, as it may double the work - */ - if ($blz == '00000000') { - try { - return $this->findBank($bankID, $offset, $line - 1); - - } catch (BAV_DataBackendException_BankNotFound $e) { - return $this->findBank($bankID, $line + 1, $end); - - } - - } elseif (! isset($this->contextCache[$blz])) { - $this->contextCache[$blz] = new BAV_FileParserContext($line); - - } - - if ($blz < $bankID) { - return $this->findBank($bankID, $line + 1, $end); - - } elseif ($blz > $bankID) { - return $this->findBank($bankID, $offset, $line - 1); - - } else { - return $this->parser->getBank($this, $this->parser->readLine($line)); - - } - } - /** - * @see BAV_DataBackend::_getMainAgency() - * @throws BAV_DataBackendException - * @throws BAV_DataBackendException_NoMainAgency - * @return BAV_Agency - */ - public function _getMainAgency(BAV_Bank $bank) { - try { - $context = $this->defineContextInterval($bank->getBankID()); - for ($line = $context->getStart(); $line <= $context->getEnd(); $line++) { - $content = $this->parser->readLine($line); - if ($this->parser->isMainAgency($content)) { - return $this->parser->getAgency($bank, $content); - - } - } - // Maybe there are banks without a main agency - throw new BAV_DataBackendException_NoMainAgency($bank); - - } catch (BAV_FileParserContextException_Undefined $e) { - throw new LogicException("Start and end should be defined."); - - } catch (BAV_FileParserException_IO $e) { - throw new BAV_DataBackendException_IO("Parser Exception at bank {$bank->getBankID()}"); - - } catch (BAV_FileParserException_ParseError $e) { - throw new BAV_DataBackendException(get_class($e) . ": " . $e->getMessage()); - - } - } - /** - * @see BAV_DataBackend::_getAgencies() - * @throws BAV_DataBackendException_IO - * @throws BAV_DataBackendException - * @return array - */ - public function _getAgencies(BAV_Bank $bank) { - try { - $context = $this->defineContextInterval($bank->getBankID()); - $agencies = array(); - for ($line = $context->getStart(); $line <= $context->getEnd(); $line++) { - $content = $this->parser->readLine($line); - if (! $this->parser->isMainAgency($content)) { - $agencies[] = $this->parser->getAgency($bank, $content); - - } - } - return $agencies; - - } catch (BAV_FileParserContextException_Undefined $e) { - throw new LogicException("Start and end should be defined."); - - } catch (BAV_FileParserException_IO $e) { - throw new BAV_DataBackendException_IO(); - - } catch (BAV_FileParserException_ParseError $e) { - throw new BAV_DataBackendException(); - - } - } - - - /** - * @return BAV_FileParserContext - */ - private function defineContextInterval($bankID) { - if (! isset($this->contextCache[$bankID])) { - throw new LogicException("The contextCache object should exist!"); - - } - $context = $this->contextCache[$bankID]; - /** - * Find start - */ - if (! $context->isStartDefined()) { - for ($start = $context->getLine() - 1; $start >= 0; $start--) { - if ($this->parser->getBankID($start) != $bankID) { - break; - - } - } - $context->setStart($start + 1); - - } - /** - * Find end - */ - if (! $context->isEndDefined()) { - for ($end = $context->getLine() + 1; $end <= $this->parser->getLines(); $end++) { - if ($this->parser->getBankID($end) != $bankID) { - break; - - } - } - $context->setEnd($end - 1); - - } - return $context; - } - - - /** - * @throws BAV_DataBackendException_IO - * @return String a writable directory for temporary files - */ - public static function getTempdir() { - $tmpDirs = array( - function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : false, - empty($_ENV['TMP']) ? false : $_ENV['TMP'], - empty($_ENV['TMPDIR']) ? false : $_ENV['TMPDIR'], - empty($_ENV['TEMP']) ? false : $_ENV['TEMP'], - ini_get('upload_tmp_dir'), - '/tmp' - ); - - foreach ($tmpDirs as $tmpDir) { - if ($tmpDir && is_writable($tmpDir)) { - return realpath($tmpDir); - - } - - } - - $tempfile = tempnam(uniqid(mt_rand(), true), ''); - if (file_exists($tempfile)) { - unlink($tempfile); - return realpath(dirname($tempfile)); - - } - - throw new BAV_DataBackendException_IO(); - } - - -} \ No newline at end of file diff --git a/classes/dataBackend/BAV_DataBackend_PDO.php b/classes/dataBackend/BAV_DataBackend_PDO.php deleted file mode 100644 index 262bc238..00000000 --- a/classes/dataBackend/BAV_DataBackend_PDO.php +++ /dev/null @@ -1,503 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_DataBackend_PDO extends BAV_DataBackend { - - - private - /** - * @var array - */ - $agencies = array(), - /** - * @var PDOStatement - */ - $selectBank, - /** - * @var PDOStatement - */ - $selectMainAgency, - /** - * @var PDOStatement - */ - $selectAgencies, - /** - * @var PDOStatement - */ - $selectAgency, - /** - * @var PDOStatement - */ - $selectAgencysBank, - /** - * @var PDO - */ - $pdo, - /** - * @var string - */ - $prefix = ''; - - - /** - * @param String $prefix the prefix of the table names. Default is 'bav_'. - */ - public function __construct(PDO $pdo, $prefix = 'bav_') { - $this->pdo = $pdo; - $this->prefix = $prefix; - - $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - - - /** - * @return string - */ - public function getPrefix() { - return $this->prefix; - } - - - /** - * You may use an arbitrary SQL statement to receive BAV_Agency objects. - * Your statement should at least return the id of the agencies. - * - * If you want to perform well your query should provide all attributes of - * a BAV_Agency object (id, name, postcode, city, shortTerm, bank, pan, bic). - * If you don't, BAV needs to do one additional query for each object. - * - * @param string $sql - * @throws BAV_DataBackendException_IO_MissingAttributes - * @throws BAV_DataBackendException_IO - * @throws BAV_DataBackendException - * @return array - */ - public function getAgencies($sql) { - try { - $this->prepareStatements(); - $agencies = array(); - - foreach ($this->pdo->query($sql) as $result) { - if (! $this->isValidAgencyResult($result)) { - if (! array_key_exists('id', $result)) { - throw new BAV_DataBackendException_IO_MissingAttributes(); - - } - $this->selectAgency->execute(array(':agency' => $result['id'])); - $result = $this->selectAgency->fetch(PDO::FETCH_ASSOC); - $this->selectAgency->closeCursor(); - if ($result === false) { - throw new BAV_DataBackendException_IO(); - - } - } - if (! array_key_exists('bank', $result)) { - $this->selectAgencysBank->execute(array(':agency' => $result['id'])); - $bankResult = $this->selectAgencysBank->fetch(PDO::FETCH_ASSOC); - $this->selectAgencysBank->closeCursor(); - if ($bankResult === false) { - throw new BAV_DataBackendException_IO(); - - } - $result['bank'] = $bankResult['bank']; - - } - $agencies[] = $this->getAgencyObject($this->getBank($result['bank']), $result); - - } - return $agencies; - - } catch (PDOException $e) { - throw new BAV_DataBackendException_IO(); - - } catch (BAV_DataBackendException_BankNotFound $e) { - throw new LogicException($e); - - } - } - - - /** - * @throws PDOException - */ - private function prepareStatements() { - if (! is_null($this->selectBank)) { - return; - } - - $this->selectBank = $this->pdo->prepare("SELECT id, validator FROM {$this->prefix}bank WHERE id = :bankID"); - - $agencyAttributes - = "a.id, name, postcode, city, shortTerm AS 'shortTerm', pan, bic"; - $this->selectMainAgency = $this->pdo->prepare( - "SELECT $agencyAttributes FROM {$this->prefix}bank b - INNER JOIN {$this->prefix}agency a ON b.mainAgency = a.id - WHERE b.id = :bankID"); - $this->selectAgencies = $this->pdo->prepare( - "SELECT $agencyAttributes FROM {$this->prefix}agency a - WHERE bank = :bankID AND id != :mainAgency"); - $this->selectAgency = $this->pdo->prepare( - "SELECT $agencyAttributes, bank FROM {$this->prefix}agency a - WHERE id = :agency"); - $this->selectAgencysBank = $this->pdo->prepare( - "SELECT bank FROM {$this->prefix}agency - WHERE id = :agency"); - } - - - /** - * @see BAV_DataBackend::update() - * @throws BAV_DataBackendException - */ - public function update() { - $useTA = false; - try { - $fileBackend = new BAV_DataBackend_File(tempnam(BAV_DataBackend_File::getTempdir(), 'bav')); - $fileBackend->install(); - - $insertBank = $this->pdo->prepare( - "INSERT INTO {$this->prefix}bank - (id, validator, mainAgency) - VALUES(:bankID, :validator, :mainAgency)"); - $insertAgency = $this->pdo->prepare( - "INSERT INTO {$this->prefix}agency - (id, name, postcode, city, shortTerm, pan, bic, bank) - VALUES (:id, :name, :postcode, :city, :shortTerm, :pan, :bic, :bank)"); - try { - $this->pdo->beginTransaction(); - $useTA = true; - - } catch (PDOException $e) { - trigger_error("Your DBS doesn't support transactions. Your data may be corrupted."); - - } - $this->pdo->exec("DELETE FROM {$this->prefix}agency"); - $this->pdo->exec("DELETE FROM {$this->prefix}bank"); - - foreach ($fileBackend->getAllBanks() as $bank) { - try { - $insertBank->execute(array( - ":bankID" => $bank->getBankID(), - ":validator" => $bank->getValidationType(), - ":mainAgency" => $bank->getMainAgency()->getID(), - )); - $agencies = $bank->getAgencies(); - $agencies[] = $bank->getMainAgency(); - foreach ($agencies as $agency) { - $insertAgency->execute(array( - ":id" => $agency->getID(), - ":name" => $agency->getName(), - ":postcode" => $agency->getPostcode(), - ":city" => $agency->getCity(), - ":shortTerm" => $agency->getShortTerm(), - ":bank" => $bank->getBankID(), - ":pan" => $agency->hasPAN() ? $agency->getPAN() : null, - ":bic" => $agency->hasBIC() ? $agency->getBIC() : null - )); - - } - } catch(BAV_DataBackendException_NoMainAgency $e) { - trigger_error( - "Skipping bank {$e->getBank()->getBankID()} without any main agency." - ); - - } - } - if ($useTA) { - $this->pdo->commit(); - $useTA = false; - - } - $fileBackend->uninstall(); - - } catch (Exception $e) { - try { - if ($useTA) { - $this->pdo->rollback(); - - } - throw $e; - - } catch (PDOException $e2) { - throw new BAV_DataBackendException_IO( - get_class($e) . ": {$e->getMessage()}\nadditionally: {$e2->getMessage()}" - ); - - } - - } - } - - - /** - * @see BAV_DataBackend::install() - * @throws BAV_DataBackendException_IO - */ - public function install() { - try { - $createOptions = ''; - switch ($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { - - case 'mysql': - $createOptions .= " engine=InnoDB"; - break; - - } - $this->pdo->exec(" - - CREATE TABLE {$this->prefix}bank( - id int primary key, - validator char(2) NOT NULL, - mainAgency int NOT NULL - - /* FOREIGN KEY (mainAgency) REFERENCES {$this->prefix}agency(id) */ - )$createOptions - - "); - $this->pdo->exec(" - - CREATE TABLE {$this->prefix}agency( - id int primary key, - name varchar(".BAV_FileParser::NAME_LENGTH.") NOT NULL, - postcode varchar(".BAV_FileParser::POSTCODE_LENGTH.") NOT NULL, - city varchar(".BAV_FileParser::CITY_LENGTH.") NOT NULL, - shortTerm varchar(".BAV_FileParser::SHORTTERM_LENGTH.") NOT NULL, - bank int NOT NULL, - pan char(".BAV_FileParser::PAN_LENGTH.") NULL, - bic varchar(".BAV_FileParser::BIC_LENGTH.") NULL, - - FOREIGN KEY (bank) REFERENCES {$this->prefix}bank(id) - )$createOptions - - "); - $this->update(); - - } catch (PDOException $e) { - throw new BAV_DataBackendException_IO($e->getMessage()); - - } - } - /** - * @see BAV_DataBackend::uninstall() - * @throws BAV_DataBackendException_IO - */ - public function uninstall() { - try { - $this->pdo->exec("DROP TABLE {$this->prefix}bank"); - $this->pdo->exec("DROP TABLE {$this->prefix}agency"); - - } catch (PDOException $e) { - throw new BAV_DataBackendException_IO(); - - } - } - - - /** - * @see BAV_DataBackend::getAllBanks() - * @throws BAV_DataBackendException - * @return array - */ - public function getAllBanks() { - try { - foreach ($this->pdo->query("SELECT id, validator FROM {$this->prefix}bank") as $bankResult) { - if (isset($this->instances[$bankResult['id']])) { - continue; - - } - $bank = $this->getBankObject($bankResult); - $this->instances[$bank->getBankID()] = $bank; - - } - return array_values($this->instances); - - } catch (PDOException $e) { - throw new BAV_DataBackendException_IO(); - - } catch (BAV_DataBackendException_IO_MissingAttributes $e) { - $this->selectBank->closeCursor(); - throw new LogicException($e); - - } - } - /** - * @throws BAV_DataBackendException - * @throws BAV_DataBackendException_BankNotFound - * @param string $bankID - * @return BAV_Bank - * @see BAV_DataBackend::getNewBank() - */ - protected function getNewBank($bankID) { - try { - $this->prepareStatements(); - $this->selectBank->execute(array(':bankID' => $bankID)); - $result = $this->selectBank->fetch(PDO::FETCH_ASSOC); - if ($result === false) { - $this->selectBank->closeCursor(); - throw new BAV_DataBackendException_BankNotFound($bankID); - - } - $this->selectBank->closeCursor(); - return $this->getBankObject($result); - - } catch (PDOException $e) { - $this->selectBank->closeCursor(); - throw new BAV_DataBackendException_IO(); - - } catch (BAV_DataBackendException_IO_MissingAttributes $e) { - $this->selectBank->closeCursor(); - throw new LogicException($e); - - } - } - /** - * @return bool - */ - private function isValidBankResult(Array $result) { - return array_key_exists('id', $result) - && array_key_exists('validator', $result); - } - /** - * @return bool - */ - private function isValidAgencyResult(Array $result) { - return array_key_exists('id', $result) - && array_key_exists('name', $result) - && array_key_exists('shortTerm', $result) - && array_key_exists('city', $result) - && array_key_exists('postcode', $result) - && array_key_exists('bic', $result) - && array_key_exists('pan', $result); - } - /** - * @return BAV_Bank - * @throws BAV_DataBackendException_IO_MissingAttributes - */ - private function getBankObject(Array $fetchedResult) { - if (! $this->isValidBankResult($fetchedResult)) { - throw new BAV_DataBackendException_IO_MissingAttributes(); - - } - return new BAV_Bank($this, $fetchedResult['id'], $fetchedResult['validator']); - } - /** - * @return BAV_Agency - * @throws BAV_DataBackendException_IO_MissingAttributes - */ - private function getAgencyObject(BAV_Bank $bank, Array $fetchedResult) { - if (! $this->isValidAgencyResult($fetchedResult)) { - throw new BAV_DataBackendException_IO_MissingAttributes(); - - } - if (! array_key_exists($fetchedResult['id'], $this->agencies)) { - $this->agencies[$fetchedResult['id']] = new BAV_Agency( - $fetchedResult['id'], - $bank, - $fetchedResult['name'], - $fetchedResult['shortTerm'], - $fetchedResult['city'], - $fetchedResult['postcode'], - $fetchedResult['bic'], - $fetchedResult['pan']); - - } - return $this->agencies[$fetchedResult['id']]; - } - /** - * @throws BAV_DataBackendException - * @return BAV_Agency - * @see BAV_DataBackend::_getMainAgency() - */ - public function _getMainAgency(BAV_Bank $bank) { - try { - $this->prepareStatements(); - $this->selectMainAgency->execute(array(":bankID" => $bank->getBankID())); - $result = $this->selectMainAgency->fetch(); - if ($result === false) { - throw new BAV_DataBackendException(); - - } - $this->selectMainAgency->closeCursor(); - return $this->getAgencyObject($bank, $result); - - } catch (PDOException $e) { - $this->selectMainAgency->closeCursor(); - throw new BAV_DataBackendException_IO(); - - } catch (BAV_DataBackendException_IO_MissingAttributes $e) { - $this->selectMainAgency->closeCursor(); - throw new LogicException($e); - - } - } - /** - * @throws BAV_DataBackendException - * @return array - * @see BAV_DataBackend::_getAgencies() - */ - public function _getAgencies(BAV_Bank $bank) { - try { - $this->prepareStatements(); - $agencies = array(); - $this->selectAgencies->execute(array( - ":bankID" => $bank->getBankID(), - ":mainAgency" => $bank->getMainAgency()->getID())); - foreach ($this->selectAgencies->fetchAll() as $agencyResult) { - $agencies[] = $this->getAgencyObject($bank, $agencyResult); - - } - $this->selectAgencies->closeCursor(); - return $agencies; - - } catch (PDOException $e) { - $this->selectAgencies->closeCursor(); - throw new BAV_DataBackendException_IO(); - - } catch (BAV_DataBackendException_IO_MissingAttributes $e) { - $this->selectAgencies->closeCursor(); - throw new LogicException($e); - - } - } - - -} - - -?> \ No newline at end of file diff --git a/classes/dataBackend/DataBackend.php b/classes/dataBackend/DataBackend.php new file mode 100644 index 00000000..b2607989 --- /dev/null +++ b/classes/dataBackend/DataBackend.php @@ -0,0 +1,197 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see DataBackendContainer + */ +abstract class DataBackend +{ + + /** + * @var array All created Bank objects + */ + protected $instances = array(); + + /** + * You have to call this method to synchronize your datastructure to the + * data of the Bundesbank. + * + * @throws DataBackendException + */ + abstract public function update(); + + /** + * Removes the databackend physically. + * + * @throws DataBackendException + */ + abstract public function uninstall(); + + /** + * Installs the databackend. An implementation of install() should also + * call update() to synchronize to the Bundebank. + * + * @throws DataBackendException + */ + abstract public function install(); + + /** + * Returns true if the backend was installed. + * + * @return bool + * @throws DataBackendException + */ + abstract public function isInstalled(); + + /** + * Returns the timestamp of the last update. + * + * @return int timestamp + * @throws DataBackendException + */ + abstract public function getLastUpdate(); + + /** + * With this method you get the Bank objects for certain IDs. Note + * that a call to this method with an identical id will return the same + * objects. + * + * @throws BankNotFoundException + * @throws DataBackendException + * @param string + * @return Bank + */ + public function getBank($bankID) + { + if (! isset($this->instances[$bankID])) { + $this->instances[$bankID] = $this->getNewBank($bankID); + + } + return $this->instances[$bankID]; + } + + /** + * Return true if a bank exists. + * + * @throws DataBackendException + * @param String $bankID + * @deprecated 1.0.0 + * @see isValidBank() + * @return bool + */ + public function bankExists($bankID) + { + trigger_error("bankExists() is deprecated, use isValidBank().", E_USER_DEPRECATED); + return $this->isValidBank($bankID); + } + + /** + * Return true if a bank exists. + * + * @throws DataBackendException + * @param String $bankID + * @return bool + */ + public function isValidBank($bankID) + { + try { + $this->getBank($bankID); + return true; + + } catch (BankNotFoundException $e) { + return false; + + } + } + + /** + * Returns an array with all banks. If you implement this method you should + * also take care that $instances is used an will be filled correctly in order + * to garantee that there will never exist two identical objects. + * + * @throws DataBackendException + * @return Bank[] + */ + abstract public function getAllBanks(); + + /** + * This method will be called by getBank() if getBank() thinks it is necessary to + * create a new object. You have to return the new object and have not to take care + * about $instances. getBank() cares about $instances. Throw a BankNotFoundException + * if the bank does not exist. + * + * @throws DataBackendException + * @throws BankNotFoundException if the bank does not exist + * @param string + * @return Bank + */ + abstract protected function getNewBank($bankID); + + /** + * If you implement this method you should return the appropriate Agency object. This + * method is called by Bank->getMainAgency(), if the Bank object doesn't know its + * main agency. + * + * @throws DataBackendException + * @return Agency + * @see Bank::getMainAgency() + * @internal YOU SHOULD NOT CALL THIS METHOD! Use Bank->getMainAgency() + */ + abstract public function getMainAgency(Bank $bank); + + /** + * If you implement this method you should return an array with the appropriate Agency + * objects. This method is called by Bank->getAgencies(), if the Bank object doesn't + * know its agencies. A bank may have no agencies and will return an empty array. + * + * @throws DataBackendException + * @see Bank::getAgencies() + * @return Agency[] + * @internal YOU SHOULD NOT CALL THIS METHOD! Use Bank->getMainAgency() + */ + abstract public function getAgenciesForBank(Bank $bank); + + /** + * Returns bank agencies for a given BIC. + * + * @param string $bic BIC + * @return Agency[] + */ + abstract public function getBICAgencies($bic); + + /** + * Returns if a bic is valid. + * + * @param string $bic BIC + * @return bool + */ + public function isValidBIC($bic) + { + $agencies = $this->getBICAgencies($bic); + return ! empty($agencies); + } + + /** + * Frees memory of cached instances + */ + public function free() + { + $this->instances = array(); + } +} diff --git a/classes/dataBackend/DataBackendContainer.php b/classes/dataBackend/DataBackendContainer.php new file mode 100644 index 00000000..19307708 --- /dev/null +++ b/classes/dataBackend/DataBackendContainer.php @@ -0,0 +1,95 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see DataBackend + * @api + */ +abstract class DataBackendContainer +{ + + /** + * @var string Name of the installation lock file + */ + const INSTALL_LOCK = "bav_install.lock"; + + /** + * @var DataBackend + */ + private $backend; + + /** + * Returns the unconfigured backend which is only created by calling the + * constructor. + * + * @return DataBackend + */ + abstract protected function makeDataBackend(); + + /** + * Builds a configured data backend. + * + * If configured this method would automatically install the backend. I.e. a first + * call will take some amount of time. + * + * @return DataBackend + * @throws DataBackendException + */ + private function buildDataBackend() + { + $configuration = ConfigurationRegistry::getConfiguration(); + $backend = $this->makeDataBackend(); + + // Installation + if ($configuration->isAutomaticInstallation() && ! $backend->isInstalled()) { + $lock = new Lock(self::INSTALL_LOCK); + $lock->executeOnce( + function () use ($backend) { + $backend->install(); + } + ); + } + + // Update hook + register_shutdown_function(array($this, "applyUpdatePlan"), $backend); + + return $backend; + } + + /** + * Shut down hook for applying the update plan. + */ + public function applyUpdatePlan(DataBackend $backend) + { + $plan = ConfigurationRegistry::getConfiguration()->getUpdatePlan(); + if ($plan != null && $plan->isOutdated($backend)) { + $plan->perform($backend); + + } + } + + /** + * Returns a configured data backend. + * + * If configured this method would automatically install and update the backend. I.e. + * some calls might take longer. + * + * @see Configuration::setAutomaticInstallation() + * @see DataBackend::install() + * @return DataBackend + */ + public function getDataBackend() + { + if (is_null($this->backend)) { + $this->backend = $this->buildDataBackend(); + + } + return $this->backend; + } +} diff --git a/classes/dataBackend/SQLDataBackend.php b/classes/dataBackend/SQLDataBackend.php new file mode 100644 index 00000000..a76d006c --- /dev/null +++ b/classes/dataBackend/SQLDataBackend.php @@ -0,0 +1,26 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +abstract class SQLDataBackend extends DataBackend +{ + + /** + * You may use an arbitrary SQL statement to receive Agency objects. + * Your statement should at least return the id of the agencies. + * + * @param string $sql + * @throws MissingAttributesDataBackendIOException + * @throws DataBackendIOException + * @throws DataBackendException + * @return Agency[] + */ + abstract public function getAgencies($sql); +} diff --git a/classes/dataBackend/exception/BAV_DataBackendException_BankNotFound.php b/classes/dataBackend/exception/BankNotFoundException.php similarity index 82% rename from classes/dataBackend/exception/BAV_DataBackendException_BankNotFound.php rename to classes/dataBackend/exception/BankNotFoundException.php index ccc61388..b1c80c17 100644 --- a/classes/dataBackend/exception/BAV_DataBackendException_BankNotFound.php +++ b/classes/dataBackend/exception/BankNotFoundException.php @@ -1,6 +1,6 @@ @@ -23,31 +23,28 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_DataBackendException_BankNotFound extends BAV_DataBackendException { - +class BankNotFoundException extends DataBackendException +{ - private /** * @var string */ - $bankID; - - - public function __construct($bankID) { + private $bankID; + + public function __construct($bankID) + { parent::__construct("bank $bankID not found"); $this->bankID = $bankID; } + /** * @return string */ - public function getBankID() { + public function getBankID() + { return $this->bankID; } - - } - - -?> \ No newline at end of file diff --git a/classes/dataBackend/exception/BAV_DataBackendException.php b/classes/dataBackend/exception/DataBackendException.php similarity index 87% rename from classes/dataBackend/exception/BAV_DataBackendException.php rename to classes/dataBackend/exception/DataBackendException.php index 0cd13375..b8dc97db 100644 --- a/classes/dataBackend/exception/BAV_DataBackendException.php +++ b/classes/dataBackend/exception/DataBackendException.php @@ -1,5 +1,6 @@ @@ -22,12 +23,10 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_DataBackendException extends RuntimeException { - +class DataBackendException extends BAVException +{ } - - -?> \ No newline at end of file diff --git a/classes/dataBackend/exception/DataBackendIOException.php b/classes/dataBackend/exception/DataBackendIOException.php new file mode 100644 index 00000000..b6d52714 --- /dev/null +++ b/classes/dataBackend/exception/DataBackendIOException.php @@ -0,0 +1,32 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * @package classes + * @subpackage dataBackend + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + */ +class DataBackendIOException extends DataBackendException +{ + +} diff --git a/classes/dataBackend/exception/InvalidContextException.php b/classes/dataBackend/exception/InvalidContextException.php new file mode 100644 index 00000000..5c6a1763 --- /dev/null +++ b/classes/dataBackend/exception/InvalidContextException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + */ +class InvalidContextException extends BAVException +{ + +} diff --git a/classes/dataBackend/exception/MissingAttributesDataBackendIOException.php b/classes/dataBackend/exception/MissingAttributesDataBackendIOException.php new file mode 100644 index 00000000..b630d173 --- /dev/null +++ b/classes/dataBackend/exception/MissingAttributesDataBackendIOException.php @@ -0,0 +1,32 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * @package classes + * @subpackage dataBackend + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + */ +class MissingAttributesDataBackendIOException extends DataBackendIOException +{ + +} diff --git a/classes/dataBackend/exception/BAV_DataBackendException_NoMainAgency.php b/classes/dataBackend/exception/NoMainAgencyException.php similarity index 79% rename from classes/dataBackend/exception/BAV_DataBackendException_NoMainAgency.php rename to classes/dataBackend/exception/NoMainAgencyException.php index cab734ad..31fd3af2 100644 --- a/classes/dataBackend/exception/BAV_DataBackendException_NoMainAgency.php +++ b/classes/dataBackend/exception/NoMainAgencyException.php @@ -1,6 +1,6 @@ @@ -23,33 +23,28 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2010 Markus Malkusch */ -class BAV_DataBackendException_NoMainAgency extends BAV_DataBackendException { - +class NoMainAgencyException extends DataBackendException +{ - private /** - * @var BAV_Bank + * @var Bank */ - $bank; - - - public function __construct(BAV_Bank $bank) { + private $bank; + + public function __construct(Bank $bank) + { parent::__construct("bank {$bank->getBankID()} has no main agency."); $this->bank = $bank; } - - + /** - * @return BAV_Bank + * @return Bank */ - public function getBank() { + public function getBank() + { return $this->bank; } - - } - - -?> \ No newline at end of file diff --git a/classes/dataBackend/file/FileDataBackend.php b/classes/dataBackend/file/FileDataBackend.php new file mode 100644 index 00000000..6b53a1a9 --- /dev/null +++ b/classes/dataBackend/file/FileDataBackend.php @@ -0,0 +1,429 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class FileDataBackend extends DataBackend +{ + + // @codingStandardsIgnoreStart + const DOWNLOAD_URI = 'https://www.bundesbank.de/de/aufgaben/unbarer-zahlungsverkehr/serviceangebot/bankleitzahlen/download-bankleitzahlen-602592'; + // @codingStandardsIgnoreEnd + + /** + * @var array + */ + private $contextCache = array(); + + /** + * @var FileParser + */ + private $parser; + + /** + * @var Index_FixedSize + */ + private $index; + + /** + * @var FileUtil + */ + private $fileUtil; + + /** + * @param String $file The data source + */ + public function __construct($file = null) + { + $this->parser = new FileParser($file); + $this->fileUtil = new FileUtil(); + } + + /** + * @return FixedSizeIndex + */ + private function getIndex() + { + if ($this->index == null) { + $this->index = new FixedSizeIndex( + $this->parser->getFile(), + FileParser::BANKID_OFFSET, + FileParser::BANKID_LENGTH + ); + + } + return $this->index; + } + + /** + * Returns the path to the data file. + * + * @return string + */ + public function getFile() + { + return $this->parser->getFile(); + } + + /** + * For the file of March 8th 2010 (blz_20100308.txt) + * Bundesbank appended new banks at the end of the file. + * That broked binary search. This method sorts the lines so + * that binary search is working again. + * + * Be aware that this needs some amount of memory. + * + * @param String $file + * @throws DataBackendIOException + * @throws FileException + */ + private function sortFile($file) + { + //read the unordered bank file + $lines = file($file); + if (! is_array($lines) || empty($lines)) { + throw new DataBackendIOException("Could not read lines in '$file'."); + + } + + //build a sorted index for the bankIDs + $index = array(); + foreach ($lines as $line => $data) { + $bankID = substr($data, FileParser::BANKID_OFFSET, FileParser::BANKID_LENGTH); + $index[$line] = $bankID; + + } + asort($index); + + //write a sorted bank file atomically + $temp = tempnam($this->fileUtil->getTempDirectory(), ""); + $tempH = fopen($temp, 'w'); + if (! ($temp && $tempH)) { + throw new DataBackendIOException("Could not open a temporary file."); + + } + foreach (array_keys($index) as $line) { + $data = $lines[$line]; + + $writtenBytes = fputs($tempH, $data); + if ($writtenBytes != strlen($data)) { + throw new DataBackendIOException("Could not write sorted data: '$data' into $temp."); + + } + + } + fclose($tempH); + $this->fileUtil->safeRename($temp, $file); + } + + /** + * @see DataBackend::uninstall() + * @throws DataBackendIOException + */ + public function uninstall() + { + if (! unlink($this->parser->getFile())) { + throw new DataBackendIOException(); + + } + } + + /** + * @see DataBackend::install() + * @throws DataBackendIOException + */ + public function install() + { + $this->update(); + } + + /** + * This method works only if your PHP is compiled with cURL. + * + * @see DataBackend::update() + * @throws DataBackendIOException + * @throws FileException + * @throws DownloaderException + * @throws URIPickerException + */ + public function update() + { + $downloader = new Downloader(); + $content = $downloader->downloadContent(self::DOWNLOAD_URI); + + $uriPicker = new DOMURIPicker(); + $path = $uriPicker->pickURI($content, new \DateTime()); + + if (strlen($path) > 0 && $path[0] != "/") { + $path = sprintf("/%s/%s", dirname(self::DOWNLOAD_URI), $path); + + } + $pathParts = explode('/', $path); + foreach ($pathParts as $i => $part) { + switch ($part) { + case '..': + unset($pathParts[$i-1]); + // fall-through as the current part ("..") should be removed as well. + + case '.': + unset($pathParts[$i]); + break; + } + + } + $path = implode('/', $pathParts); + $urlParts = parse_url(self::DOWNLOAD_URI); + $url = sprintf("%s://%s%s", $urlParts["scheme"], $urlParts["host"], $path); + + // download file + $file = $downloader->downloadFile($url); + + // Validate file format. + $validator = new FileValidator(); + $validator->validate($file); + + // blz_20100308.txt is not sorted. + $parser = new FileParser($file); + $lastBankID = $parser->getBankID($parser->getLines()); + if ($lastBankID < 80000000) { + $this->sortFile($file); + + } + + $this->fileUtil->safeRename($file, $this->parser->getFile()); + chmod($this->parser->getFile(), 0644); + } + + /** + * @throws DataBackendIOException + * @throws DataBackendException + * @return Bank[] + * @see DataBackend::getAllBanks() + */ + public function getAllBanks() + { + try { + for ($i = 0; $i < $this->parser->getLines(); $i++) { + if (isset($this->instances[$this->parser->getBankID($i)])) { + continue; + + } + $line = $this->parser->readLine($i); + $bank = $this->parser->getBank($this, $line); + $this->instances[$bank->getBankID()] = $bank; + $this->contextCache[$bank->getBankID()] = new FileParserContext($i); + } + return array_values($this->instances); + + } catch (FileParserIOException $e) { + throw new DataBackendIOException($e->getMessage(), $e->getCode(), $e); + + } catch (FileParserException $e) { + throw new DataBackendException($e->getMessage(), $e->getCode(), $e); + + } + } + + /** + * @throws DataBackendIOException + * @throws BankNotFoundException + * @param String $bankID + * @see DataBackend::getNewBank() + * @return Bank + */ + public function getNewBank($bankID) + { + try { + $result = $this->getIndex()->search($bankID); + + if ($result == null) { + throw new BankNotFoundException($bankID); + + } + + $line = $result->getOffset() / $this->parser->getLineLength(); + $this->contextCache[$bankID] = new FileParserContext($line); + + return $this->parser->getBank($this, $this->parser->readLine($line)); + + } catch (FileParserException $e) { + throw new DataBackendIOException($e->getMessage(), $e->getCode(), $e); + + } catch (IndexException $e) { + throw new DataBackendIOException($e->getMessage(), $e->getCode(), $e); + + } + } + + /** + * @see DataBackend::getMainAgency() + * @throws DataBackendException + * @throws NoMainAgencyException + * @return Agency + */ + public function getMainAgency(Bank $bank) + { + try { + $context = $this->defineContextInterval($bank->getBankID()); + for ($line = $context->getStart(); $line <= $context->getEnd(); $line++) { + $content = $this->parser->readLine($line); + if ($this->parser->isMainAgency($content)) { + return $this->parser->getAgency($bank, $content); + + } + } + // Maybe there are banks without a main agency + throw new NoMainAgencyException($bank); + + } catch (UndefinedFileParserContextException $e) { + throw new \LogicException("Start and end should be defined."); + + } catch (FileParserIOException $e) { + throw new DataBackendIOException("Parser Exception at bank {$bank->getBankID()}"); + + } catch (ParseException $e) { + throw new DataBackendException(get_class($e) . ": " . $e->getMessage()); + + } + } + + /** + * @see DataBackend::getAgenciesForBank() + * @throws DataBackendIOException + * @throws DataBackendException + * @return Agency[] + */ + public function getAgenciesForBank(Bank $bank) + { + try { + $context = $this->defineContextInterval($bank->getBankID()); + $agencies = array(); + for ($line = $context->getStart(); $line <= $context->getEnd(); $line++) { + $content = $this->parser->readLine($line); + if (! $this->parser->isMainAgency($content)) { + $agencies[] = $this->parser->getAgency($bank, $content); + + } + } + return $agencies; + + } catch (UndefinedFileParserContextException $e) { + throw new \LogicException("Start and end should be defined."); + + } catch (FileParserIOException $e) { + throw new DataBackendIOException(); + + } catch (ParseException $e) { + throw new DataBackendException(); + + } + } + + /** + * @return FileParserContext + */ + private function defineContextInterval($bankID) + { + if (! isset($this->contextCache[$bankID])) { + throw new \LogicException("The contextCache object should exist!"); + + } + $context = $this->contextCache[$bankID]; + /** + * Find start + */ + if (! $context->isStartDefined()) { + for ($start = $context->getLine() - 1; $start >= 0; $start--) { + if ($this->parser->getBankID($start) != $bankID) { + break; + + } + } + $context->setStart($start + 1); + + } + /** + * Find end + */ + if (! $context->isEndDefined()) { + for ($end = $context->getLine() + 1; $end <= $this->parser->getLines(); $end++) { + if ($this->parser->getBankID($end) != $bankID) { + break; + + } + } + $context->setEnd($end - 1); + + } + return $context; + } + + /** + * Returns the timestamp of the last update. + * + * @return int timestamp + * @throws DataBackendException + */ + public function getLastUpdate() + { + $time = filemtime($this->parser->getFile()); + if ($time === false) { + return new DataBackendException( + "Could not read modification time from {$this->parser->getFile()}" + ); + + } + return $time; + } + + /** + * Returns true if the backend was installed. + * + * @return bool + */ + public function isInstalled() + { + return file_exists($this->parser->getFile()) + && filesize($this->parser->getFile()) > 0; + } + + /** + * Returns bank agencies for a given BIC. + * + * @todo This method is inefficient. Add index based implementation. + * @param string $bic BIC + * @return Agency[] + */ + public function getBICAgencies($bic) + { + $agencies = array(); + foreach ($this->getAllBanks() as $bank) { + $bankAgencies = $bank->getAgencies(); + $bankAgencies[] = $bank->getMainAgency(); + foreach ($bankAgencies as $agency) { + if ($agency->hasBIC() && $agency->getBIC() == $bic) { + $agencies[] = $agency; + + } + } + } + return $agencies; + } + + public function free() + { + parent::free(); + $this->contextCache = array(); + } +} diff --git a/classes/dataBackend/file/FileDataBackendContainer.php b/classes/dataBackend/file/FileDataBackendContainer.php new file mode 100644 index 00000000..e6649628 --- /dev/null +++ b/classes/dataBackend/file/FileDataBackendContainer.php @@ -0,0 +1,42 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see DataBackend + * @api + */ +class FileDataBackendContainer extends DataBackendContainer +{ + + /** + * @var string + */ + private $file; + + /** + * Sets the path for the backend. + * + * @param string $file Path to the bundesbank file + */ + public function __construct($file = null) + { + $this->file = $file; + } + + /** + * Returns the unconfigured backend which is only created by calling the + * constructor. + * + * @return FileDataBackend + */ + protected function makeDataBackend() + { + return new FileDataBackend($this->file); + } +} diff --git a/classes/dataBackend/file/download/Downloader.php b/classes/dataBackend/file/download/Downloader.php new file mode 100644 index 00000000..269d3ff4 --- /dev/null +++ b/classes/dataBackend/file/download/Downloader.php @@ -0,0 +1,105 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class Downloader +{ + + /** + * @var resource + */ + private $handle; + + /** + * Initializes the downloader. + * + * @throws DownloaderException + */ + public function __construct() + { + $this->handle = curl_init(); + if (!$this->handle) { + throw new DownloaderException("Failed initializing curl"); + + } + curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($this->handle, CURLOPT_FOLLOWLOCATION, true); + } + + /** + * Execute the curl call. + * + * @throws DownloaderException + * @return mixed + */ + private function download($uri) + { + curl_setopt($this->handle, CURLOPT_URL, $uri); + $result = curl_exec($this->handle); + + $curl_info = curl_getinfo($this->handle); + if ($curl_info['http_code'] >= 400) { + throw new DownloaderException( + sprintf( + "Failed to download '%s'. HTTP Code: %d", + $uri, + $curl_info['http_code'] + ) + ); + } + return $result; + } + + /** + * Downloads the content of an URI + * + * @param string $uri URI + * @return string Content of the page + * @throws DownloaderException + */ + public function downloadContent($uri) + { + curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, true); + + $content = $this->download($uri); + if (! $content) { + throw new DataBackendIOException("Failed to download '$uri'."); + + } + return $content; + } + + /** + * Downloads a file. + * + * @param string $uri URI + * @return string local path to downloaded file. + * @throws DownloaderException + */ + public function downloadFile($uri) + { + $fileUtil = new FileUtil(); + $file = tempnam($fileUtil->getTempDirectory(), "bavdownload"); + $fp = fopen($file, 'w'); + if (! ($file && $fp)) { + throw new DownloaderException("Failed opening a temporary file"); + + } + curl_setopt($this->handle, CURLOPT_FILE, $fp); + + if (! $this->download($uri)) { + fclose($fp); + unlink($file); + throw new DownloaderException(curl_error($this->handle), curl_errno($this->handle)); + + } + return $file; + } +} diff --git a/classes/dataBackend/file/download/exception/DownloaderException.php b/classes/dataBackend/file/download/exception/DownloaderException.php new file mode 100644 index 00000000..8e0c4e2e --- /dev/null +++ b/classes/dataBackend/file/download/exception/DownloaderException.php @@ -0,0 +1,16 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @see Downloader + * @license WTFPL + */ +class DownloaderException extends DataBackendException +{ + +} diff --git a/classes/dataBackend/file/download/uripicker/DOMURIPicker.php b/classes/dataBackend/file/download/uripicker/DOMURIPicker.php new file mode 100644 index 00000000..2342b436 --- /dev/null +++ b/classes/dataBackend/file/download/uripicker/DOMURIPicker.php @@ -0,0 +1,54 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class DOMURIPicker implements URIPicker +{ + + /** + * Returns true if this implementation is available on this platform. + * + * @return bool + */ + public function isAvailable() + { + return class_exists("\DOMXPath"); + } + + /** + * Returns the download URI from the Bundesbank html page. + * + * @param string $html + * @param \DateTime $currentDate + * + * @throws URIPickerException + * + * @return string + */ + public function pickURI($html, \DateTime $currentDate) + { + $doc = new \DOMDocument(); + libxml_use_internal_errors(true); + $doc->loadHTML($html); + + $xpath = new \DOMXpath($doc); + + $result = $xpath->query("(//a[contains(@href, 'blz-aktuell-txt-data.txt')]/@href)"); + + foreach ($result as $item) { + $link = $item->value; + if (!empty($link)) { + return $link; + } + } + + throw new URIPickerException("Did not find download URI"); + } +} diff --git a/classes/dataBackend/file/download/uripicker/URIPicker.php b/classes/dataBackend/file/download/uripicker/URIPicker.php new file mode 100644 index 00000000..003707e8 --- /dev/null +++ b/classes/dataBackend/file/download/uripicker/URIPicker.php @@ -0,0 +1,30 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +interface URIPicker +{ + /** + * Returns true if this implementation is available on this platform. + * + * @return bool + */ + public function isAvailable(); + + /** + * Returns the download URI from the Bundesbank html page. + * + * @param string $html + * @param \DateTime $currentDate + * + * @return string + */ + public function pickURI($html, \DateTime $currentDate); +} diff --git a/classes/dataBackend/file/download/uripicker/exception/URIPickerException.php b/classes/dataBackend/file/download/uripicker/exception/URIPickerException.php new file mode 100644 index 00000000..a6c46a85 --- /dev/null +++ b/classes/dataBackend/file/download/uripicker/exception/URIPickerException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class URIPickerException extends DataBackendException +{ + +} diff --git a/classes/dataBackend/file/fileParser/FileParser.php b/classes/dataBackend/file/fileParser/FileParser.php new file mode 100644 index 00000000..03054f5d --- /dev/null +++ b/classes/dataBackend/file/fileParser/FileParser.php @@ -0,0 +1,309 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * @package classes + * @subpackage dataBackend + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + */ +class FileParser +{ + + const FILE_ENCODING = 'ISO-8859-15'; + const BANKID_OFFSET = 0; // field 1 + const BANKID_LENGTH = 8; + const ISMAIN_OFFSET = 8; // field 2 + const ISMAIN_LENGTH = 1; + const NAME_OFFSET = 9; // field 3 + const NAME_LENGTH = 58; + const POSTCODE_OFFSET = 67; // field 4 + const POSTCODE_LENGTH = 5; + const CITY_OFFSET = 72; // field 5 + const CITY_LENGTH = 35; + const SHORTTERM_OFFSET = 107; // field 6 + const SHORTTERM_LENGTH = 27; + const PAN_OFFSET = 134; // field 7 + const PAN_LENGTH = 5; + const BIC_OFFSET = 139; // field 8 + const BIC_LENGTH = 11; + const TYPE_OFFSET = 150; // field 9 + const TYPE_LENGTH = 2; + const ID_OFFSET = 152; // field 10 + const ID_LENGTH = 6; + const STATE_OFFSET = 158; // field 11 + const STATE_LENGTH = 1; + const DELETE_OFFSET = 159; // field 12 + const DELETE_LENGTH = 1; + const SUCCESSOR_OFFSET = 160; // field 13 + const SUCCESSOR_LENGTH = 8; + + /** + * This field is only accessible from a new version of the file. + * The new version is only accessible from the Bundesbank ExtraNet. + */ + const IBAN_RULE_OFFSET = 168; // field 14 Rule + const IBAN_RULE_LENGTH = 4; + const IBAN_VERSION_OFFSET = 172; // field 14 Version + const IBAN_VERSION_LENGTH = 2; + + /** + * @var resource + */ + private $fp; + + /** + * @var string + */ + private $file = ''; + + /** + * @var int, + */ + private $lines = 0; + + /** + * @var int + */ + private $lineLength = 0; + + /** + * @var Encoding + */ + private $encoding; + + /** + * @param String $file The data source + */ + public function __construct($file = null) + { + $defaultFile = + __DIR__ . DIRECTORY_SEPARATOR . ".." + . DIRECTORY_SEPARATOR . ".." + . DIRECTORY_SEPARATOR . ".." + . DIRECTORY_SEPARATOR . ".." + . DIRECTORY_SEPARATOR . "data" + . DIRECTORY_SEPARATOR . "banklist.txt"; + + $this->file = is_null($file) ? $defaultFile: $file; + + $this->encoding = ConfigurationRegistry::getConfiguration()->getEncoding(); + } + + /** + * @throws FileParserIOException + * @throws FileParserNotExistsException + */ + private function init() + { + if (is_resource($this->fp)) { + return; + + } + $this->fp = @fopen($this->file, 'r'); + if (! is_resource($this->fp)) { + if (! file_exists($this->file)) { + throw new FileParserNotExistsException($this->file); + + } else { + throw new FileParserIOException(); + + } + + } + + + $dummyLine = fgets($this->fp); + if (! $dummyLine) { + throw new FileParserIOException(); + + } + $this->lineLength = strlen($dummyLine); + + clearstatcache(); // filesize() seems to be 0 sometimes + $filesize = filesize($this->file); + if (! $filesize) { + throw new FileParserIOException( + "Could not read filesize for '$this->file'." + ); + + } + + // size + 1, because the last line has no line break + $this->lines = floor(($filesize + 1) / $this->lineLength); + } + + /** + * @throws FileParserIOException + * @throws FileParserNotExistsException + * @return int + */ + public function getLines() + { + $this->init(); + return $this->lines; + } + + /** + * @throws FileParserIOException + * @throws FileParserNotExistsException + */ + public function rewind() + { + if (fseek($this->getFileHandle(), 0) === -1) { + throw new FileParserIOException(); + + } + } + + /** + * @throws FileParserIOException + * @throws FileParserNotExistsException + * @param int $line + * @param int $offset + */ + public function seekLine($line, $offset = 0) + { + if (fseek($this->getFileHandle(), $line * $this->lineLength + $offset) === -1) { + throw new FileParserIOException(); + + } + } + + /** + * @throws FileParserIOException + * @throws FileParserNotExistsException + * @param int $line + * @return string + */ + public function readLine($line) + { + $this->seekLine($line); + return $this->encoding->convert(fread($this->getFileHandle(), $this->lineLength), self::FILE_ENCODING); + } + + /** + * @throws FileParserIOException + * @throws FileParserNotExistsException + * @param int $line + * @return string + */ + public function getBankID($line) + { + $this->seekLine($line, self::BANKID_OFFSET); + return $this->encoding->convert(fread($this->getFileHandle(), self::BANKID_LENGTH), self::FILE_ENCODING); + } + + /** + * @throws FileParserNotExistsException + * @throws FileParserIOException + * @return resource + */ + public function getFileHandle() + { + $this->init(); + return $this->fp; + } + + /** + * @throws FileParserNotExistsException + * @throws FileParserIOException + * @return int + */ + public function getLineLength() + { + $this->init(); + return $this->lineLength; + } + + /** + */ + public function __destruct() + { + if (is_resource($this->fp)) { + fclose($this->fp); + + } + } + + /** + * @throws ParseException + * @param string $line + * @return Bank + */ + public function getBank(DataBackend $dataBackend, $line) + { + if ($this->encoding->strlen($line) < self::TYPE_OFFSET + self::TYPE_LENGTH) { + throw new ParseException("Invalid line length in Line $line."); + + } + $type = $this->encoding->substr($line, self::TYPE_OFFSET, self::TYPE_LENGTH); + $bankID = $this->encoding->substr($line, self::BANKID_OFFSET, self::BANKID_LENGTH); + return new Bank($dataBackend, $bankID, $type); + } + + /** + * @throws ParseException + * @param string $line + * @return Agency + */ + public function getAgency(Bank $bank, $line) + { + if ($this->encoding->strlen($line) < self::ID_OFFSET + self::ID_LENGTH) { + throw new ParseException("Invalid line length."); + + } + $id = trim($this->encoding->substr($line, self::ID_OFFSET, self::ID_LENGTH)); + $name = trim($this->encoding->substr($line, self::NAME_OFFSET, self::NAME_LENGTH)); + $shortTerm = trim($this->encoding->substr($line, self::SHORTTERM_OFFSET, self::SHORTTERM_LENGTH)); + $city = trim($this->encoding->substr($line, self::CITY_OFFSET, self::CITY_LENGTH)); + $postcode = $this->encoding->substr($line, self::POSTCODE_OFFSET, self::POSTCODE_LENGTH); + $bic = trim($this->encoding->substr($line, self::BIC_OFFSET, self::BIC_LENGTH)); + $pan = trim($this->encoding->substr($line, self::PAN_OFFSET, self::PAN_LENGTH)); + return new Agency($id, $bank, $name, $shortTerm, $city, $postcode, $bic, $pan); + } + + /** + * @throws ParseException + * @param string $line + * @return bool + */ + public function isMainAgency($line) + { + if ($this->encoding->strlen($line) < self::TYPE_OFFSET + self::TYPE_LENGTH) { + throw new ParseException("Invalid line length."); + + } + return $this->encoding->substr($line, self::ISMAIN_OFFSET, 1) === '1'; + } + + /** + * @return string + */ + public function getFile() + { + return $this->file; + } +} diff --git a/classes/dataBackend/fileParser/BAV_FileParserContext.php b/classes/dataBackend/file/fileParser/FileParserContext.php similarity index 69% rename from classes/dataBackend/fileParser/BAV_FileParserContext.php rename to classes/dataBackend/file/fileParser/FileParserContext.php index 432def41..2dc4ccda 100644 --- a/classes/dataBackend/fileParser/BAV_FileParserContext.php +++ b/classes/dataBackend/file/fileParser/FileParserContext.php @@ -1,10 +1,9 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_FileParserContext extends BAV { - +class FileParserContext +{ - private /** * @var int any line of the context */ - $line = 0, + private $line = 0; + /** * @var int the first line in the context */ - $start = null, + private $start = null; + /** * @var int the last line of the context */ - $end = null; - - + private $end = null; + /** * @param string $bankID * @param int $line */ - public function __construct($line) { + public function __construct($line) + { $this->line = $line; } + /** * @return int */ - public function getLine() { + public function getLine() + { return $this->line; } + /** - * @throws BAV_FileParserContextException_Undefined + * @throws UndefinedFileParserContextException * @return int */ - public function getStart() { + public function getStart() + { if (is_null($this->start)) { - throw new BAV_FileParserContextException_Undefined(); - + throw new UndefinedFileParserContextException(); + } return $this->start; } + /** * @return bool */ - public function isStartDefined() { + public function isStartDefined() + { return ! is_null($this->start); } + /** - * @throws BAV_FileParserContextException_Undefined + * @throws UndefinedFileParserContextException * @return int */ - public function getEnd() { + public function getEnd() + { if (is_null($this->end)) { - throw new BAV_FileParserContextException_Undefined(); - + throw new UndefinedFileParserContextException(); + } return $this->end; } + /** * @return bool */ - public function isEndDefined() { + public function isEndDefined() + { return ! is_null($this->end); } + /** * @param int $start */ - public function setStart($start) { + public function setStart($start) + { $this->start = $start; } + /** * @param int $end */ - public function setEnd($end) { + public function setEnd($end) + { $this->end = $end; } - - } - - -?> \ No newline at end of file diff --git a/classes/dataBackend/file/fileParser/exception/FileParserContextException.php b/classes/dataBackend/file/fileParser/exception/FileParserContextException.php new file mode 100644 index 00000000..737bca98 --- /dev/null +++ b/classes/dataBackend/file/fileParser/exception/FileParserContextException.php @@ -0,0 +1,32 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * @package classes + * @subpackage dataBackend + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + */ +class FileParserContextException extends BAVException +{ + +} diff --git a/classes/dataBackend/exception/BAV_DataBackendException_IO_MissingAttributes.php b/classes/dataBackend/file/fileParser/exception/FileParserException.php similarity index 87% rename from classes/dataBackend/exception/BAV_DataBackendException_IO_MissingAttributes.php rename to classes/dataBackend/file/fileParser/exception/FileParserException.php index 52485fcd..bb5e03bc 100644 --- a/classes/dataBackend/exception/BAV_DataBackendException_IO_MissingAttributes.php +++ b/classes/dataBackend/file/fileParser/exception/FileParserException.php @@ -1,6 +1,6 @@ @@ -23,12 +23,10 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_DataBackendException_IO_MissingAttributes extends BAV_DataBackendException_IO { - +class FileParserException extends BAVException +{ } - - -?> \ No newline at end of file diff --git a/classes/dataBackend/file/fileParser/exception/FileParserIOException.php b/classes/dataBackend/file/fileParser/exception/FileParserIOException.php new file mode 100644 index 00000000..3df28043 --- /dev/null +++ b/classes/dataBackend/file/fileParser/exception/FileParserIOException.php @@ -0,0 +1,32 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * @package classes + * @subpackage dataBackend + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + */ +class FileParserIOException extends FileParserException +{ + +} diff --git a/classes/dataBackend/fileParser/exception/BAV_FileParserException_FileNotExists.php b/classes/dataBackend/file/fileParser/exception/FileParserNotExistsException.php similarity index 80% rename from classes/dataBackend/fileParser/exception/BAV_FileParserException_FileNotExists.php rename to classes/dataBackend/file/fileParser/exception/FileParserNotExistsException.php index aea0800c..f6aada0a 100644 --- a/classes/dataBackend/fileParser/exception/BAV_FileParserException_FileNotExists.php +++ b/classes/dataBackend/file/fileParser/exception/FileParserNotExistsException.php @@ -1,6 +1,6 @@ @@ -23,33 +23,30 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_FileParserException_FileNotExists extends BAV_FileParserException { - +class FileParserNotExistsException extends FileParserException +{ - private /** * @var string */ - $parsedFile = ''; - - + private $parsedFile = ''; + /** * @param string $file */ - public function __construct($parsedFile) { + public function __construct($parsedFile) + { $this->parsedFile = $parsedFile; } + /** * @return string */ - public function getParsedFile() { + public function getParsedFile() + { return $this->parsedFile; } - - } - - -?> \ No newline at end of file diff --git a/classes/dataBackend/fileParser/exception/BAV_FileParserContextException.php b/classes/dataBackend/file/fileParser/exception/ParseException.php similarity index 87% rename from classes/dataBackend/fileParser/exception/BAV_FileParserContextException.php rename to classes/dataBackend/file/fileParser/exception/ParseException.php index c41464eb..54525d71 100644 --- a/classes/dataBackend/fileParser/exception/BAV_FileParserContextException.php +++ b/classes/dataBackend/file/fileParser/exception/ParseException.php @@ -1,5 +1,6 @@ @@ -22,12 +23,10 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_FileParserContextException extends RuntimeException { - +class ParseException extends FileParserException +{ } - - -?> \ No newline at end of file diff --git a/classes/dataBackend/file/fileParser/exception/UndefinedFileParserContextException.php b/classes/dataBackend/file/fileParser/exception/UndefinedFileParserContextException.php new file mode 100644 index 00000000..84e18630 --- /dev/null +++ b/classes/dataBackend/file/fileParser/exception/UndefinedFileParserContextException.php @@ -0,0 +1,32 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * @package classes + * @subpackage dataBackend + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + */ +class UndefinedFileParserContextException extends FileParserContextException +{ + +} diff --git a/classes/dataBackend/file/validator/FileValidator.php b/classes/dataBackend/file/validator/FileValidator.php new file mode 100644 index 00000000..841dd2c2 --- /dev/null +++ b/classes/dataBackend/file/validator/FileValidator.php @@ -0,0 +1,59 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class FileValidator +{ + + const FILESIZE = 1500000; // 1.5MB + + /** + * Validates a bundesbank file. + * + * @param string $file bundesbank file. + * @throws FileValidatorException + */ + public function validate($file) + { + $parser = new FileParser($file); + + // file size is normally around 3 MB. Less than 1.5 is not valid + $size = filesize($file); + if ($size < self::FILESIZE) { + throw new InvalidFilesizeException( + "Get updated BAV version:" + . " file size should not be less than " . self::FILESIZE . " but was $size." + ); + + } + + // check line length + $minLength = FileParser::SUCCESSOR_OFFSET + FileParser::SUCCESSOR_LENGTH; + if ($parser->getLineLength() < $minLength) { + throw new InvalidLineLengthException( + "Get updated BAV version:" + . " Line length shouldn't be less than $minLength but was {$parser->getLineLength()}." + ); + + } + + // rough check that line length is constant. + if ($size % $parser->getLineLength() != 0) { + throw new InvalidLineLengthException("Get updated BAV version: Line length is not constant."); + + } + + $firstLine = $parser->readLine(0); + if (! preg_match("/^100000001Bundesbank/", $firstLine)) { + throw new FieldException("Get updated BAV version: first line has unexpected content: $firstLine"); + + } + } +} diff --git a/classes/dataBackend/file/validator/exception/FieldException.php b/classes/dataBackend/file/validator/exception/FieldException.php new file mode 100644 index 00000000..e826a210 --- /dev/null +++ b/classes/dataBackend/file/validator/exception/FieldException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class FieldException extends FileValidatorException +{ + +} diff --git a/classes/dataBackend/file/validator/exception/FileValidatorException.php b/classes/dataBackend/file/validator/exception/FileValidatorException.php new file mode 100644 index 00000000..1587eef3 --- /dev/null +++ b/classes/dataBackend/file/validator/exception/FileValidatorException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class FileValidatorException extends DataBackendException +{ + +} diff --git a/classes/dataBackend/file/validator/exception/InvalidFilesizeException.php b/classes/dataBackend/file/validator/exception/InvalidFilesizeException.php new file mode 100644 index 00000000..c46b5811 --- /dev/null +++ b/classes/dataBackend/file/validator/exception/InvalidFilesizeException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class InvalidFilesizeException extends FileValidatorException +{ + +} diff --git a/classes/dataBackend/file/validator/exception/InvalidLineLengthException.php b/classes/dataBackend/file/validator/exception/InvalidLineLengthException.php new file mode 100644 index 00000000..7f68128f --- /dev/null +++ b/classes/dataBackend/file/validator/exception/InvalidLineLengthException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class InvalidLineLengthException extends FileValidatorException +{ + +} diff --git a/classes/dataBackend/fileParser/BAV_FileParser.php b/classes/dataBackend/fileParser/BAV_FileParser.php deleted file mode 100644 index bcfa19d1..00000000 --- a/classes/dataBackend/fileParser/BAV_FileParser.php +++ /dev/null @@ -1,261 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_FileParser extends BAV { - - - const FILE_ENCODING = 'ISO-8859-15'; - const BANKID_OFFSET = 0; - const BANKID_LENGTH = 8; - const ISMAIN_OFFSET = 8; - const ISMAIN_LENGTH = 1; - const NAME_OFFSET = 9; - const NAME_LENGTH = 58; - const POSTCODE_OFFSET = 67; - const POSTCODE_LENGTH = 5; - const CITY_OFFSET = 72; - const CITY_LENGTH = 35; - const SHORTTERM_OFFSET = 107; - const SHORTTERM_LENGTH = 27; - const PAN_OFFSET = 134; - const PAN_LENGTH = 5; - const BIC_OFFSET = 139; - const BIC_LENGTH = 11; - const TYPE_OFFSET = 150; - const TYPE_LENGTH = 2; - const ID_OFFSET = 152; - const ID_LENGTH = 6; - - - private - /** - * @var resource - */ - $fp, - /** - * @var string - */ - $file = '', - /** - * @var int, - */ - $lines = 0, - /** - * @var int - */ - $lineLength = 0; - - - /** - * @param String $file The data source - */ - public function __construct($file = null) { - $this->file = is_null($file) - ? __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "banklist.txt" - : $file; - } - /** - * @throws BAV_FileParserException_IO - * @throws BAV_FileParserException_FileNotExists - */ - private function init() { - if (is_resource($this->fp)) { - return; - - } - $this->fp = @fopen($this->file, 'r'); - if (! is_resource($this->fp)) { - if (! file_exists($this->file)) { - throw new BAV_FileParserException_FileNotExists($this->file); - - } else { - throw new BAV_FileParserException_IO(); - - } - - } - - - $dummyLine = fgets($this->fp, 1024); - if (! $dummyLine) { - throw new BAV_FileParserException_IO(); - - } - $this->lineLength = strlen($dummyLine); - - clearstatcache(); // filesize() seems to be 0 sometimes - $filesize = filesize($this->file); - if (! $filesize) { - throw new BAV_FileParserException_IO( - "Could not read filesize for '$this->file'." - ); - - } - $this->lines = floor(($filesize - 1) / $this->lineLength); - } - /** - * @throws BAV_FileParserException_IO - * @throws BAV_FileParserException_FileNotExists - * @return int - */ - public function getLines() { - $this->init(); - return $this->lines; - } - /** - * @throws BAV_FileParserException_IO - * @throws BAV_FileParserException_FileNotExists - */ - public function rewind() { - if (fseek($this->getFileHandle(), 0) === -1) { - throw new BAV_FileParserException_IO(); - - } - } - /** - * @throws BAV_FileParserException_IO - * @throws BAV_FileParserException_FileNotExists - * @param int $line - * @param int $offset - */ - public function seekLine($line, $offset = 0) { - if (fseek($this->getFileHandle(), $line * $this->lineLength + $offset) === -1) { - throw new BAV_FileParserException_IO(); - - } - } - /** - * @throws BAV_FileParserException_IO - * @throws BAV_FileParserException_FileNotExists - * @param int $line - * @return string - */ - public function readLine($line) { - $this->seekLine($line); - return self::$encoding->convert(fread($this->getFileHandle(), $this->lineLength), self::FILE_ENCODING); - } - /** - * @throws BAV_FileParserException_IO - * @throws BAV_FileParserException_FileNotExists - * @param int $line - * @return string - */ - public function getBankID($line) { - $this->seekLine($line, self::BANKID_OFFSET); - return self::$encoding->convert(fread($this->getFileHandle(), self::BANKID_LENGTH), self::FILE_ENCODING); - } - /** - * @throws BAV_FileParserException_FileNotExists - * @throws BAV_FileParserException_IO - * @return resource - */ - public function getFileHandle() { - $this->init(); - return $this->fp; - } - /** - * @throws BAV_FileParserException_FileNotExists - * @throws BAV_FileParserException_IO - * @return int - */ - public function getLineLength() { - $this->init(); - return $this->lineLength; - } - /** - */ - public function __destruct() { - if (is_resource($this->fp)) { - fclose($this->fp); - - } - } - /** - * @throws BAV_FileParserException_ParseError - * @param string $line - * @return BAV_Bank - */ - public function getBank(BAV_DataBackend $dataBackend, $line) { - if (self::$encoding->strlen($line) < self::TYPE_OFFSET + self::TYPE_LENGTH) { - throw new BAV_FileParserException_ParseError("Invalid line length in Line $line."); - - } - $type = self::$encoding->substr($line, self::TYPE_OFFSET, self::TYPE_LENGTH); - $bankID = self::$encoding->substr($line, self::BANKID_OFFSET, self::BANKID_LENGTH); - return new BAV_Bank($dataBackend, $bankID, $type); - } - /** - * @throws BAV_FileParserException_ParseError - * @param string $line - * @return BAV_Agency - */ - public function getAgency(BAV_Bank $bank, $line) { - if (self::$encoding->strlen($line) < self::ID_OFFSET + self::ID_LENGTH) { - throw new BAV_FileParserException_ParseError("Invalid line length."); - - } - $id = trim(self::$encoding->substr($line, self::ID_OFFSET, self::ID_LENGTH)); - $name = trim(self::$encoding->substr($line, self::NAME_OFFSET, self::NAME_LENGTH)); - $shortTerm = trim(self::$encoding->substr($line, self::SHORTTERM_OFFSET, self::SHORTTERM_LENGTH)); - $city = trim(self::$encoding->substr($line, self::CITY_OFFSET, self::CITY_LENGTH)); - $postcode = self::$encoding->substr($line, self::POSTCODE_OFFSET, self::POSTCODE_LENGTH); - $bic = trim(self::$encoding->substr($line, self::BIC_OFFSET, self::BIC_LENGTH)); - $pan = trim(self::$encoding->substr($line, self::PAN_OFFSET, self::PAN_LENGTH)); - return new BAV_Agency($id, $bank, $name, $shortTerm, $city, $postcode, $bic, $pan); - } - /** - * @throws BAV_FileParserException_ParseError - * @param string $line - * @return bool - */ - public function isMainAgency($line) { - if (self::$encoding->strlen($line) < self::TYPE_OFFSET + self::TYPE_LENGTH) { - throw new BAV_FileParserException_ParseError("Invalid line length."); - - } - return self::$encoding->substr($line, self::ISMAIN_OFFSET, 1) === '1'; - } - /** - * @return string - */ - public function getFile() { - return $this->file; - } - - -} - -?> \ No newline at end of file diff --git a/classes/dataBackend/fileParser/exception/BAV_FileParserContextException_Undefined.php b/classes/dataBackend/fileParser/exception/BAV_FileParserContextException_Undefined.php deleted file mode 100644 index 3d1cb463..00000000 --- a/classes/dataBackend/fileParser/exception/BAV_FileParserContextException_Undefined.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_FileParserContextException_Undefined extends BAV_FileParserContextException { - - -} - - -?> \ No newline at end of file diff --git a/classes/dataBackend/fileParser/exception/BAV_FileParserException.php b/classes/dataBackend/fileParser/exception/BAV_FileParserException.php deleted file mode 100644 index 1523ff22..00000000 --- a/classes/dataBackend/fileParser/exception/BAV_FileParserException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_FileParserException extends RuntimeException { - - -} - - -?> \ No newline at end of file diff --git a/classes/dataBackend/fileParser/exception/BAV_FileParserException_IO.php b/classes/dataBackend/fileParser/exception/BAV_FileParserException_IO.php deleted file mode 100644 index 757763b1..00000000 --- a/classes/dataBackend/fileParser/exception/BAV_FileParserException_IO.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_FileParserException_IO extends BAV_FileParserException { - - -} - - -?> \ No newline at end of file diff --git a/classes/dataBackend/fileParser/exception/BAV_FileParserException_ParseError.php b/classes/dataBackend/fileParser/exception/BAV_FileParserException_ParseError.php deleted file mode 100644 index 30891cff..00000000 --- a/classes/dataBackend/fileParser/exception/BAV_FileParserException_ParseError.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_FileParserException_ParseError extends BAV_FileParserException { - - -} - - -?> \ No newline at end of file diff --git a/classes/dataBackend/orm/MetaData.php b/classes/dataBackend/orm/MetaData.php new file mode 100644 index 00000000..b7822bfc --- /dev/null +++ b/classes/dataBackend/orm/MetaData.php @@ -0,0 +1,67 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class MetaData +{ + + const LASTMODIFIED = "lastModified"; + + /** + * @var String + */ + private $name; + + /** + * @var String + */ + private $value; + + /** + * Sets the name + * + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Gets the name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets the value + * + * @param string $value + */ + public function setValue($value) + { + $this->value = $value; + } + + /** + * Gets the value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/classes/dataBackend/orm/doctrine/DoctrineBackendContainer.php b/classes/dataBackend/orm/doctrine/DoctrineBackendContainer.php new file mode 100644 index 00000000..cf44694f --- /dev/null +++ b/classes/dataBackend/orm/doctrine/DoctrineBackendContainer.php @@ -0,0 +1,75 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see DataBackend + * @link http://www.doctrine-project.org/ + * @api + */ +class DoctrineBackendContainer extends DataBackendContainer +{ + + /** + * @var EntityManager + */ + private $em; + + /** + * Return the paths to the XML-Mappings + * + * @return string[] + */ + public static function getXMLMappings() + { + return array(__DIR__ . "/mapping/"); + } + + /** + * Builds a container for a connection. + * + * @param mixed $connection Doctrine::DBAL connection + * @return DoctrineBackendContainer + */ + public static function buildByConnection($connection, $isDevMode = false) + { + $mappings = self::getXMLMappings(); + $config = Setup::createXMLMetadataConfiguration($mappings, $isDevMode); + + $entityManager = EntityManager::create($connection, $config); + return new self($entityManager); + } + + /** + * Injects the EntityManager + */ + public function __construct(EntityManager $entityManager) + { + $this->em = $entityManager; + } + + /** + * Gets the EntityManager + * + * @return EntityManager + */ + public function getEntityManager() + { + return $this->em; + } + + protected function makeDataBackend() + { + return new DoctrineDataBackend($this->em); + } +} diff --git a/classes/dataBackend/orm/doctrine/DoctrineDataBackend.php b/classes/dataBackend/orm/doctrine/DoctrineDataBackend.php new file mode 100644 index 00000000..44b013a5 --- /dev/null +++ b/classes/dataBackend/orm/doctrine/DoctrineDataBackend.php @@ -0,0 +1,210 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @link http://www.doctrine-project.org/ + */ +class DoctrineDataBackend extends SQLDataBackend +{ + + /** + * @var EntityManager + */ + private $em; + + public function __construct(EntityManager $em) + { + $this->em = $em; + } + + protected function getNewBank($bankID) + { + try { + $bank = $this->em->find('malkusch\bav\Bank', $bankID); + if ($bank == null) { + throw new BankNotFoundException($bankID); + + } + $bank->setDataBackend($this); + return $bank; + + } catch (ORMException $e) { + throw new DataBackendException($e); + + } + } + + public function getAgenciesForBank(Bank $bank) + { + $query = $this->em->createQuery( + "select agency from malkusch\bav\Agency agency where agency.id != :mainAgency and agency.bank=:bank" + ); + $query->setParameters(array( + "mainAgency" => $bank->getMainAgency()->getID(), + "bank" => $bank + )); + return $query->getResult(); + } + + public function getAllBanks() + { + return $this->em->getRepository("malkusch\bav\Bank")->findAll(); + } + + public function getBICAgencies($bic) + { + return $this->em->getRepository("malkusch\bav\Agency")->findBy(array( + "bic" => $bic + )); + } + + public function getLastUpdate() + { + $lastModified = $this->em->find("malkusch\bav\MetaData", MetaData::LASTMODIFIED); + if ($lastModified == null) { + throw new DataBackendException(); + + } + return $lastModified->getValue(); + } + + public function getMainAgency(Bank $bank) + { + // Return the Doctrine proxy + return $bank->getMainAgency(); + } + + private function getClassesMetadata() + { + return array( + $this->em->getClassMetadata('malkusch\bav\Bank'), + $this->em->getClassMetadata('malkusch\bav\Agency'), + $this->em->getClassMetadata('malkusch\bav\MetaData'), + ); + } + + public function install() + { + $tool = new SchemaTool($this->em); + $classes = $this->getClassesMetadata(); + $tool->createSchema($classes); + + $this->update(); + } + + public function isInstalled() + { + try { + $this->em->find("malkusch\bav\MetaData", MetaData::LASTMODIFIED); + return true; + + } catch (DBALException $e) { + return false; + + } + } + + public function uninstall() + { + $tool = new SchemaTool($this->em); + $classes = $this->getClassesMetadata(); + $tool->dropSchema($classes); + $this->em->clear(); + } + + public function update() + { + $this->em->transactional(function (EntityManager $em) { + + // Download data + $fileUtil = new FileUtil(); + $fileBackend = new FileDataBackend(tempnam($fileUtil->getTempDirectory(), 'bav')); + $fileBackend->install(); + + // Delete all + $em->createQuery("DELETE FROM malkusch\bav\Agency")->execute(); + $em->createQuery("DELETE FROM malkusch\bav\Bank")->execute(); + + // Inserting data + foreach ($fileBackend->getAllBanks() as $bank) { + try { + $em->persist($bank); + + $agencies = $bank->getAgencies(); + $agencies[] = $bank->getMainAgency(); + foreach ($agencies as $agency) { + $em->persist($agency); + + } + } catch (NoMainAgencyException $e) { + trigger_error( + "Skipping bank {$e->getBank()->getBankID()} without any main agency." + ); + } + } + + // last modified + $lastModified = $em->find("malkusch\bav\MetaData", MetaData::LASTMODIFIED); + if ($lastModified == null) { + $lastModified = new MetaData(); + + } + $lastModified->setName(MetaData::LASTMODIFIED); + $lastModified->setValue(time()); + $em->persist($lastModified); + }); + } + + public function free() + { + parent::free(); + $this->em->clear(); + } + + /** + * You may use an arbitrary SQL statement to receive Agency objects. + * Your statement should at least return the id of the agencies. + * + * @param string $sql + * @throws MissingAttributesDataBackendIOException + * @throws DataBackendIOException + * @throws DataBackendException + * @return Agency[] + */ + public function getAgencies($sql) + { + $agencies = array(); + $backend = $this; + $em = $this->em; + $this->em->transactional(function () use (&$agencies, $sql, $backend, $em) { + $stmt = $em->getConnection()->executeQuery($sql); + + foreach ($stmt as $result) { + if (! array_key_exists('id', $result)) { + throw new MissingAttributesDataBackendIOException(); + + } + $id = $result["id"]; + $agency = $em->find("malkusch\bav\Agency", $id); + $agencies[] = $agency; + + $agency->getBank()->setDataBackend($backend); + + } + }); + return $agencies; + } +} diff --git a/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.Agency.dcm.xml b/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.Agency.dcm.xml new file mode 100644 index 00000000..4bbd6919 --- /dev/null +++ b/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.Agency.dcm.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.Bank.dcm.xml b/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.Bank.dcm.xml new file mode 100644 index 00000000..3ed9ae65 --- /dev/null +++ b/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.Bank.dcm.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.MetaData.dcm.xml b/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.MetaData.dcm.xml new file mode 100644 index 00000000..744a3540 --- /dev/null +++ b/classes/dataBackend/orm/doctrine/mapping/malkusch.bav.MetaData.dcm.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/classes/dataBackend/pdo/PDODataBackend.php b/classes/dataBackend/pdo/PDODataBackend.php new file mode 100644 index 00000000..72bfb833 --- /dev/null +++ b/classes/dataBackend/pdo/PDODataBackend.php @@ -0,0 +1,637 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class PDODataBackend extends SQLDataBackend +{ + + /** + * @var array + */ + private $agencies = array(); + + /** + * @var string + */ + private $agencyAttributes = + "a.id, name, postcode, city, shortTerm AS 'shortTerm', pan, bic"; + + /** + * @var StatementContainer + */ + private $statementContainer; + + /** + * @var \PDO + */ + private $pdo; + + /** + * @var string + */ + private $prefix = ''; + + /** + * @param String $prefix the prefix of the table names. + */ + public function __construct(\PDO $pdo, $prefix = "bav_") + { + $this->pdo = $pdo; + $this->prefix = $prefix; + $this->statementContainer = new StatementContainer($pdo); + + $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * You may use an arbitrary SQL statement to receive Agency objects. + * Your statement should at least return the id of the agencies. + * + * If you want to perform well your query should provide all attributes of + * a Agency object (id, name, postcode, city, shortTerm, bank, pan, bic). + * If you don't, BAV needs to do one additional query for each object. + * + * @param string $sql + * @throws MissingAttributesDataBackendIOException + * @throws DataBackendIOException + * @throws DataBackendException + * @return Agency[] + */ + public function getAgencies($sql) + { + try { + $agencies = array(); + + foreach ($this->pdo->query($sql) as $result) { + if (! $this->isValidAgencyResult($result)) { + if (! array_key_exists('id', $result)) { + throw new MissingAttributesDataBackendIOException(); + + } + $stmt = $this->statementContainer->prepare( + "SELECT $this->agencyAttributes, bank FROM {$this->prefix}agency a + WHERE id = :agency" + ); + $stmt->execute(array(':agency' => $result['id'])); + $result = $stmt->fetch(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + if ($result === false) { + throw new DataBackendIOException(); + + } + } + if (! array_key_exists('bank', $result)) { + $stmt = $this->statementContainer->prepare( + "SELECT bank FROM {$this->prefix}agency + WHERE id = :agency" + ); + $stmt->execute(array(':agency' => $result['id'])); + $bankResult = $stmt->fetch(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + if ($bankResult === false) { + throw new DataBackendIOException(); + + } + $result['bank'] = $bankResult['bank']; + + } + $agencies[] = $this->getAgencyObject($this->getBank($result['bank']), $result); + + } + return $agencies; + + } catch (\PDOException $e) { + throw new DataBackendIOException(); + + } catch (BankNotFoundException $e) { + throw new \LogicException($e); + + } + } + + /** + * @see DataBackend::update() + * @throws DataBackendException + */ + public function update() + { + $useTA = false; + try { + $fileUtil = new FileUtil(); + $fileBackend = new FileDataBackend(tempnam($fileUtil->getTempDirectory(), 'bav')); + $fileBackend->install(); + + $insertBank = $this->pdo->prepare( + "INSERT INTO {$this->prefix}bank + (id, validator, mainAgency) + VALUES(:bankID, :validator, :mainAgency)" + ); + $insertAgency = $this->pdo->prepare( + "INSERT INTO {$this->prefix}agency + (id, name, postcode, city, shortTerm, pan, bic, bank) + VALUES (:id, :name, :postcode, :city, :shortTerm, :pan, :bic, :bank)" + ); + try { + $this->pdo->beginTransaction(); + $useTA = true; + + } catch (\PDOException $e) { + trigger_error("Your DBS doesn't support transactions. Your data may be corrupted."); + + } + $this->pdo->exec("DELETE FROM {$this->prefix}agency"); + $this->pdo->exec("DELETE FROM {$this->prefix}bank"); + + foreach ($fileBackend->getAllBanks() as $bank) { + try { + $insertBank->execute(array( + ":bankID" => $bank->getBankID(), + ":validator" => $bank->getValidationType(), + ":mainAgency" => $bank->getMainAgency()->getID(), + )); + $agencies = $bank->getAgencies(); + $agencies[] = $bank->getMainAgency(); + foreach ($agencies as $agency) { + $insertAgency->execute(array( + ":id" => $agency->getID(), + ":name" => $agency->getName(), + ":postcode" => $agency->getPostcode(), + ":city" => $agency->getCity(), + ":shortTerm" => $agency->getShortTerm(), + ":bank" => $bank->getBankID(), + ":pan" => $agency->hasPAN() ? $agency->getPAN() : null, + ":bic" => $agency->hasBIC() ? $agency->getBIC() : null + )); + + } + } catch (NoMainAgencyException $e) { + trigger_error( + "Skipping bank {$e->getBank()->getBankID()} without any main agency." + ); + + } + } + + // Update modification timestamp + $modificationStmt = $this->pdo->prepare( + "UPDATE {$this->prefix}meta SET value=:value WHERE name=:name" + ); + $modificationStmt->execute(array( + ":name" => MetaData::LASTMODIFIED, + ":value" => time() + )); + + + if ($useTA) { + $this->pdo->commit(); + $useTA = false; + + } + $fileBackend->uninstall(); + + } catch (Exception $e) { + try { + if ($useTA) { + $this->pdo->rollback(); + + } + throw $e; + + } catch (\PDOException $e2) { + throw new DataBackendIOException( + get_class($e) . ": {$e->getMessage()}\nadditionally: {$e2->getMessage()}" + ); + + } + + } + } + + /** + * @see DataBackend::install() + * @throws DataBackendIOException + */ + public function install() + { + try { + $createOptions = ''; + switch ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { + case 'mysql': + $createOptions .= " engine=InnoDB"; + break; + + } + $this->pdo->exec( + "CREATE TABLE {$this->prefix}bank( + id int primary key, + validator char(2) NOT NULL, + mainAgency int NOT NULL + + /* FOREIGN KEY (mainAgency) REFERENCES {$this->prefix}agency(id) */ + )$createOptions" + ); + $this->pdo->exec( + "CREATE TABLE {$this->prefix}agency( + id int primary key, + name varchar(".FileParser::NAME_LENGTH.") NOT NULL, + postcode varchar(".FileParser::POSTCODE_LENGTH.") NOT NULL, + city varchar(".FileParser::CITY_LENGTH.") NOT NULL, + shortTerm varchar(".FileParser::SHORTTERM_LENGTH.") NOT NULL, + bank int NOT NULL, + pan char(".FileParser::PAN_LENGTH.") NULL, + bic varchar(".FileParser::BIC_LENGTH.") NULL, + + FOREIGN KEY (bank) REFERENCES {$this->prefix}bank(id) + )$createOptions" + ); + + try { + $this->pdo->exec("CREATE INDEX bic ON {$this->prefix}agency (bic)"); + + } catch (\PDOException $e) { + trigger_error("Failed to create index for bic: {$e->getMessage()}", E_USER_WARNING); + + } + + $this->pdo->exec( + "CREATE TABLE {$this->prefix}meta( + name char(32) NOT NULL primary key, + value varchar(128) + )$createOptions" + ); + $insertMetaStmt = $this->pdo->prepare( + "INSERT INTO {$this->prefix}meta (name, value) VALUES (:name, :value)" + ); + $insertMetaStmt->execute(array( + ":name" => MetaData::LASTMODIFIED, + ":value" => null + )); + $this->update(); + + } catch (\PDOException $e) { + throw new DataBackendIOException($e->getMessage(), 0, $e); + + } + } + + /** + * @see DataBackend::uninstall() + * @throws DataBackendIOException + */ + public function uninstall() + { + try { + $this->pdo->exec("DROP TABLE {$this->prefix}agency"); + $this->pdo->exec("DROP TABLE {$this->prefix}bank"); + $this->pdo->exec("DROP TABLE {$this->prefix}meta"); + + } catch (\PDOException $e) { + throw new DataBackendIOException(); + + } + } + + /** + * @see DataBackend::getAllBanks() + * @throws DataBackendException + * @return Bank[] + */ + public function getAllBanks() + { + try { + foreach ($this->pdo->query("SELECT id, validator FROM {$this->prefix}bank") as $bankResult) { + if (isset($this->instances[$bankResult['id']])) { + continue; + + } + $bank = $this->getBankObject($bankResult); + $this->instances[$bank->getBankID()] = $bank; + + } + return array_values($this->instances); + + } catch (\PDOException $e) { + throw new DataBackendIOException(); + + } catch (MissingAttributesDataBackendIOException $e) { + throw new \LogicException($e); + + } + } + + /** + * @throws DataBackendException + * @throws BankNotFoundException + * @param string $bankID + * @return Bank + * @see DataBackend::getNewBank() + */ + protected function getNewBank($bankID) + { + try { + $stmt = $this->statementContainer->prepare( + "SELECT id, validator FROM {$this->prefix}bank WHERE id = :bankID" + ); + $stmt->execute(array(':bankID' => $bankID)); + $result = $stmt->fetch(\PDO::FETCH_ASSOC); + if ($result === false) { + $stmt->closeCursor(); + throw new BankNotFoundException($bankID); + + } + $stmt->closeCursor(); + return $this->getBankObject($result); + + } catch (\PDOException $e) { + $stmt->closeCursor(); + throw new DataBackendIOException(); + + } catch (MissingAttributesDataBackendIOException $e) { + $stmt->closeCursor(); + throw new \LogicException($e); + + } + } + + /** + * @return bool + */ + private function isValidBankResult(Array $result) + { + return array_key_exists('id', $result) + && array_key_exists('validator', $result); + } + + /** + * @return bool + */ + private function isValidAgencyResult(Array $result) + { + return array_key_exists('id', $result) + && array_key_exists('name', $result) + && array_key_exists('shortTerm', $result) + && array_key_exists('city', $result) + && array_key_exists('postcode', $result) + && array_key_exists('bic', $result) + && array_key_exists('pan', $result); + } + + /** + * @return Bank + * @throws MissingAttributesDataBackendIOException + */ + private function getBankObject(Array $fetchedResult) + { + if (! $this->isValidBankResult($fetchedResult)) { + throw new MissingAttributesDataBackendIOException(); + + } + return new Bank($this, $fetchedResult['id'], $fetchedResult['validator']); + } + + /** + * @return Agency + * @throws MissingAttributesDataBackendIOException + */ + private function getAgencyObject(Bank $bank, Array $fetchedResult) + { + if (! $this->isValidAgencyResult($fetchedResult)) { + throw new MissingAttributesDataBackendIOException(); + + } + if (! array_key_exists($fetchedResult['id'], $this->agencies)) { + $this->agencies[$fetchedResult['id']] = new Agency( + $fetchedResult['id'], + $bank, + $fetchedResult['name'], + $fetchedResult['shortTerm'], + $fetchedResult['city'], + $fetchedResult['postcode'], + $fetchedResult['bic'], + $fetchedResult['pan'] + ); + + } + return $this->agencies[$fetchedResult['id']]; + } + + /** + * @throws DataBackendException + * @return Agency + * @see DataBackend::getMainAgency() + */ + public function getMainAgency(Bank $bank) + { + try { + $stmt = $this->statementContainer->prepare( + "SELECT $this->agencyAttributes FROM {$this->prefix}bank b + INNER JOIN {$this->prefix}agency a ON b.mainAgency = a.id + WHERE b.id = :bankID" + ); + $stmt->execute(array(":bankID" => $bank->getBankID())); + $result = $stmt->fetch(); + if ($result === false) { + throw new DataBackendException(); + + } + $stmt->closeCursor(); + return $this->getAgencyObject($bank, $result); + + } catch (\PDOException $e) { + $stmt->closeCursor(); + throw new DataBackendIOException($e->getMessage(), 0, $e); + + } catch (MissingAttributesDataBackendIOException $e) { + $stmt->closeCursor(); + throw new \LogicException($e); + + } + } + + /** + * @throws DataBackendException + * @return Agency[] + * @see DataBackend::getAgenciesForBank() + */ + public function getAgenciesForBank(Bank $bank) + { + try { + $stmt = $this->statementContainer->prepare( + "SELECT $this->agencyAttributes FROM {$this->prefix}agency a + WHERE bank = :bankID AND id != :mainAgency" + ); + $agencies = array(); + $stmt->execute(array( + ":bankID" => $bank->getBankID(), + ":mainAgency" => $bank->getMainAgency()->getID())); + foreach ($stmt->fetchAll() as $agencyResult) { + $agencies[] = $this->getAgencyObject($bank, $agencyResult); + + } + $stmt->closeCursor(); + return $agencies; + + } catch (\PDOException $e) { + $stmt->closeCursor(); + throw new DataBackendIOException($e->getMessage(), 0, $e); + + } catch (MissingAttributesDataBackendIOException $e) { + $stmt->closeCursor(); + throw new \LogicException($e); + + } + } + + /** + * Returns the timestamp of the last update. + * + * @return int timestamp + * @throws DataBackendException + */ + public function getLastUpdate() + { + try { + $stmt = $this->statementContainer->prepare( + "SELECT value FROM {$this->prefix}meta + WHERE name = :name" + ); + $stmt->execute(array( + ":name" => MetaData::LASTMODIFIED, + )); + $result = $stmt->fetch(); + if ($result === false) { + throw new DataBackendException(); + + } + $stmt->closeCursor(); + return $result["value"]; + + } catch (\PDOException $e) { + $stmt->closeCursor(); + throw new DataBackendIOException($e->getMessage(), $e->getCode(), $e); + + } + } + + /** + * Returns true if the backend was installed. + * + * @return bool + * @throws DataBackendException + */ + public function isInstalled() + { + try { + switch ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { + case "sqlite": + $query = + "SELECT count(*) FROM sqlite_master + WHERE type='table' AND name = '{$this->prefix}meta'"; + break; + + default: + $query = + "SELECT CASE WHEN EXISTS( + (SELECT * FROM information_schema.tables + WHERE table_name='{$this->prefix}meta') + ) THEN 1 ELSE 0 END"; + break; + + } + + $stmt = $this->statementContainer->prepare($query); + $stmt->execute(); + $result = $stmt->fetch(); + if ($result === false) { + throw new DataBackendException(); + + } + $stmt->closeCursor(); + return $result[0] == 1; + + } catch (\PDOException $e) { + $stmt->closeCursor(); + throw new DataBackendIOException($e->getMessage(), 0, $e); + + } + } + + /** + * Returns if a bic is valid. + * + * @param string $bic BIC + * @return bool + */ + public function isValidBIC($bic) + { + try { + $stmt = $this->statementContainer->prepare( + "SELECT bic FROM {$this->prefix}agency WHERE bic = :bic GROUP BY (bic)" + ); + $stmt->execute(array(":bic" => $bic)); + + $rows = $stmt->fetchAll(); + return ! empty($rows); + + } catch (\PDOException $e) { + $stmt->closeCursor(); + throw new DataBackendIOException($e->getMessage(), 0, $e); + + } + } + + /** + * Returns bank agencies for a given BIC. + * + * @param string $bic BIC + * @return Agency[] + */ + public function getBICAgencies($bic) + { + try { + $stmt = $this->statementContainer->prepare( + "SELECT bank, $this->agencyAttributes FROM {$this->prefix}agency a + WHERE bic = :bic" + ); + $agencies = array(); + $stmt->execute(array(":bic" => $bic)); + foreach ($stmt->fetchAll() as $result) { + $agencies[] = $this->getAgencyObject($this->getBank($result['bank']), $result); + + } + $stmt->closeCursor(); + return $agencies; + + } catch (\PDOException $e) { + $stmt->closeCursor(); + throw new DataBackendIOException($e->getMessage(), 0, $e); + + } catch (MissingAttributesDataBackendIOException $e) { + $stmt->closeCursor(); + throw new \LogicException($e); + + } + } + + public function free() + { + parent::free(); + $this->agencies = array(); + } +} diff --git a/classes/dataBackend/pdo/PDODataBackendContainer.php b/classes/dataBackend/pdo/PDODataBackendContainer.php new file mode 100644 index 00000000..438bdee3 --- /dev/null +++ b/classes/dataBackend/pdo/PDODataBackendContainer.php @@ -0,0 +1,48 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see DataBackend + * @api + */ +class PDODataBackendContainer extends DataBackendContainer +{ + + /** + * @var \PDO + */ + private $pdo; + + /** + * @var string + */ + private $prefix; + + /** + * Sets the PDO and the table prefix. + * + * @param String $prefix the prefix of the table names. Default is 'bav_'. + */ + public function __construct(\PDO $pdo, $prefix = 'bav_') + { + $this->pdo = $pdo; + $this->prefix = $prefix; + } + + /** + * Returns the unconfigured backend which is only created by calling the + * constructor. + * + * @return PDODataBackend + */ + protected function makeDataBackend() + { + return new PDODataBackend($this->pdo, $this->prefix); + } +} diff --git a/classes/dataBackend/pdo/StatementContainer.php b/classes/dataBackend/pdo/StatementContainer.php new file mode 100644 index 00000000..8bf3d161 --- /dev/null +++ b/classes/dataBackend/pdo/StatementContainer.php @@ -0,0 +1,50 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class StatementContainer +{ + + /** + * @var \PDOStatement[] + */ + private $statements = array(); + + /** + * @var \PDO + */ + private $pdo; + + /** + * Inject the pdo. + */ + public function __construct(\PDO $pdo) + { + $this->pdo = $pdo; + } + + /** + * Returns a PDOStatement + * + * This method will return the same object for equal queries. + * + * @param string $sql + * @return \PDOStatement + * @throws \PDOException + */ + public function prepare($sql) + { + if (! array_key_exists($sql, $this->statements)) { + $this->statements[$sql] = $this->pdo->prepare($sql); + + } + return $this->statements[$sql]; + } +} diff --git a/classes/dataBackend/update/AutomaticUpdatePlan.php b/classes/dataBackend/update/AutomaticUpdatePlan.php new file mode 100644 index 00000000..3f0a237e --- /dev/null +++ b/classes/dataBackend/update/AutomaticUpdatePlan.php @@ -0,0 +1,57 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @api + */ +class AutomaticUpdatePlan extends UpdatePlan +{ + + /** + * @var string Name of the update lock file + */ + const UPDATE_LOCK = "bav_update.lock"; + + /** + * @var bool + */ + private $notice = true; + + /** + * Set to false if you don't want to see an E_USER_NOTICE about an update. + * + * @param bool $notice + */ + public function setNotice($notice) + { + $this->notice = $notice; + } + + /** + * Perform an update. + * + * If enabled (default) this method will send a E_USER_NOTICE about the update. + * + * @see setNotice() + */ + public function perform(DataBackend $backend) + { + $isNotice = $this->notice; + $lock = new Lock(self::UPDATE_LOCK); + $lock->nonblockingExecuteOnce( + function () use ($backend, $isNotice) { + $backend->update(); + if ($isNotice) { + trigger_error("bav's bank data was updated sucessfully.", E_USER_NOTICE); + + } + } + ); + } +} diff --git a/classes/dataBackend/update/LogUpdatePlan.php b/classes/dataBackend/update/LogUpdatePlan.php new file mode 100644 index 00000000..22e813ec --- /dev/null +++ b/classes/dataBackend/update/LogUpdatePlan.php @@ -0,0 +1,26 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @api + */ +class LogUpdatePlan extends UpdatePlan +{ + + /** + * Log an E_USER_WARNING + */ + public function perform(DataBackend $backend) + { + trigger_error( + "bav's bank data is outdated. Update the data with e.g. bin/bav-update.php", + E_USER_WARNING + ); + } +} diff --git a/classes/dataBackend/update/UpdatePlan.php b/classes/dataBackend/update/UpdatePlan.php new file mode 100644 index 00000000..ecd11833 --- /dev/null +++ b/classes/dataBackend/update/UpdatePlan.php @@ -0,0 +1,87 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @api + */ +abstract class UpdatePlan +{ + + /** + * Bundesbank releases updates in those months + */ + private static $updateMonths = array( + 3, // March + 6, // June + 9, // September + 12, // December + ); + + /** + * Number of months before an update month when Bundesbank is supposed + * to deliver the updated file. + * + * @var int + */ + private static $relaseThreshold = 1; + + /** + * Perform the update process. + */ + abstract public function perform(DataBackend $backend); + + /** + * Returns true if the data is to old and needs an update + * + * @see DataBackend::getLastUpdate() + * @return bool + */ + public function isOutdated(DataBackend $backend) + { + /* + * The following code creates a sorted list with the release months (update month - $relaseThreshold) + * and the current month. To build that threshold date simply pick the month before the current month from + * that list. + * + * Note that the second parameter of the date() calls is there on purpose. This allows + * to mock time() for testing. + */ + + /* + * The current month gets an increment of 0.5 for the case that the current month is a + * release month (e.g. the list will look (2, 2.5, 5, 8, 11)). + */ + $currentMonth = date("n", time()) + 0.5; + + $monthList = array($currentMonth); + foreach (self::$updateMonths as $month) { + $releaseMonth = $month - self::$relaseThreshold; + $monthList[] = $releaseMonth; + + } + sort($monthList); // You have now something like (2, 2.5, 5, 8, 11). + + // Now add the cycle between the last and the first month(11, 2, 3.5, 5, 8, 11, 2). + $monthList[] = self::$updateMonths[0] - self::$relaseThreshold; // this is acually not needed. + array_unshift($monthList, self::$updateMonths[count(self::$updateMonths) - 1] - self::$relaseThreshold); + + $index = array_search($currentMonth, $monthList); + assert($index > 0); + $previousIndex = $index - 1; + + $thresholdMonth = $monthList[$previousIndex]; + + // flip the year if the threshold was in the last year. + $year = $thresholdMonth > $currentMonth ? date("Y", time()) - 1 : date("Y", time()); + + $threshold = mktime(0, 0, 0, $thresholdMonth, 1, $year); + + return $backend->getLastUpdate() < $threshold; + } +} diff --git a/classes/encoding/BAV_Encoding.php b/classes/encoding/BAV_Encoding.php deleted file mode 100644 index 7329403e..00000000 --- a/classes/encoding/BAV_Encoding.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -abstract class BAV_Encoding extends BAV { - - - protected - /** - * @var String - */ - $enc = 'UTF-8'; - - /** - * @throws BAV_EncodingException_Unsupported - * @param String $encoding - */ - public function __construct($encoding = 'UTF-8') { - if (! $this->isSupported($encoding)) { - throw new BAV_EncodingException_Unsupported($encoding); - - } - $this->enc = $encoding; - } - /** - * @return int length of $string - */ - abstract public function strlen($string); - /** - * @param String $string - * @param int $offset - * @param int $length - * @return String - */ - abstract public function substr($string, $offset, $length = null); - /** - * @throws BAV_EncodingException - * @param String $string - * @param String $from_encoding - * @return $string the encoded string - */ - abstract public function convert($string, $from_encoding); - /** - * @param String - * @return bool - */ - static public function isSupported($encoding) { - return false; - } - /** - * @throws BAV_EncodingException_Unsupported - * @param String $encoding - * @return BAV_Encoding - */ - static public function getInstance($encoding) { - if (BAV_Encoding_Iconv::isSupported($encoding)) { - return new BAV_Encoding_Iconv($encoding); - - } elseif (BAV_Encoding_MB::isSupported($encoding)) { - return new BAV_Encoding_MB($encoding); - - } elseif (BAV_Encoding_ISO8859::isSupported($encoding)) { - return new BAV_Encoding_ISO8859($encoding); - - } else { - throw new BAV_EncodingException_Unsupported($encoding); - - } - } - - -} - - -?> \ No newline at end of file diff --git a/classes/encoding/Encoding.php b/classes/encoding/Encoding.php new file mode 100644 index 00000000..364f6fb2 --- /dev/null +++ b/classes/encoding/Encoding.php @@ -0,0 +1,81 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +abstract class Encoding +{ + + /** + * @var String + */ + protected $enc = 'UTF-8'; + + /** + * @throws UnsupportedEncodingException + * @param String $encoding + */ + public function __construct($encoding = 'UTF-8') + { + if (! $this->isSupported($encoding)) { + throw new UnsupportedEncodingException($encoding); + + } + $this->enc = $encoding; + } + + /** + * @return int length of $string + */ + abstract public function strlen($string); + + /** + * @param String $string + * @param int $offset + * @param int $length + * @return String + */ + abstract public function substr($string, $offset, $length = null); + + /** + * @throws EncodingException + * @param String $string + * @param String $from_encoding + * @return $string the encoded string + */ + abstract public function convert($string, $from_encoding); + + /** + * @param String + * @return bool + */ + public static function isSupported($encoding) + { + return false; + } + + /** + * @throws UnsupportedEncodingException + * @param String $encoding + * @return Encoding + */ + public static function getInstance($encoding) + { + if (MBEncoding::isSupported($encoding)) { + return new MBEncoding($encoding); + + } elseif (ISO8859Encoding::isSupported($encoding)) { + return new ISO8859Encoding($encoding); + + } else { + throw new UnsupportedEncodingException($encoding); + + } + } +} diff --git a/classes/encoding/BAV_Encoding_ISO8859.php b/classes/encoding/ISO8859Encoding.php similarity index 80% rename from classes/encoding/BAV_Encoding_ISO8859.php rename to classes/encoding/ISO8859Encoding.php index 993180b3..c9878237 100644 --- a/classes/encoding/BAV_Encoding_ISO8859.php +++ b/classes/encoding/ISO8859Encoding.php @@ -1,7 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Encoding_ISO8859 extends BAV_Encoding { +class ISO8859Encoding extends Encoding +{ /** * @return bool */ - static public function isSupported($encoding) { + public static function isSupported($encoding) + { return preg_match('~^ISO-8859-([1-9]|1[0-5])$~', $encoding); } + /** * @return int length of $string */ - public function strlen($string) { + public function strlen($string) + { return strlen($string); } + /** * @param String $string * @param int $offset * @param int $length * @return String */ - public function substr($string, $offset, $length = null) { + public function substr($string, $offset, $length = null) + { return is_null($length) ? substr($string, $offset) : substr($string, $offset, $length); } + /** - * @throws BAV_EncodingException + * @throws EncodingException * @param String $string * @param String $from_encoding * @return $string the encoded string */ - public function convert($string, $from_encoding) { + public function convert($string, $from_encoding) + { if ($from_encoding == $this->enc) { return $string; - + } - throw new BAV_EncodingException(); + throw new EncodingException(); } - - } - - -?> \ No newline at end of file diff --git a/classes/encoding/BAV_Encoding_Iconv.php b/classes/encoding/IconvEncoding.php similarity index 64% rename from classes/encoding/BAV_Encoding_Iconv.php rename to classes/encoding/IconvEncoding.php index 87f9c6ff..a3c9aee1 100644 --- a/classes/encoding/BAV_Encoding_Iconv.php +++ b/classes/encoding/IconvEncoding.php @@ -1,13 +1,11 @@ * * This program is free software; you can redistribute it and/or modify @@ -24,64 +22,69 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + * @deprecated 1.0.1 PHP 5.6.0 deprecated the iconv_* methods */ -class BAV_Encoding_Iconv extends BAV_Encoding { - +class IconvEncoding extends Encoding +{ /** * @return bool */ - static public function isSupported($encoding) { + public static function isSupported($encoding) + { return function_exists("iconv_set_encoding"); } + /** - * @throws BAV_EncodingException_Unsupported - * @param String $encoding + * @throws UnsupportedEncodingException + * @param String $encoding */ - public function __construct($encoding = 'UTF-8') { + public function __construct($encoding = 'UTF-8') + { parent::__construct($encoding); iconv_set_encoding("internal_encoding", $encoding); } + /** * @return int length of $string */ - public function strlen($string) { + public function strlen($string) + { return iconv_strlen($string); } + /** - * @param String $string - * @param int $offset - * @param int $length + * @param String $string + * @param int $offset + * @param int $length * @return String */ - public function substr($string, $offset, $length = null) { + public function substr($string, $offset, $length = null) + { return is_null($length) ? iconv_substr($string, $offset) : iconv_substr($string, $offset, $length); } + /** - * @throws BAV_EncodingException - * @param String $string - * @param String $from_encoding + * @throws EncodingException + * @param String $string + * @param String $from_encoding * @return $string the encoded string */ - public function convert($string, $from_encoding) { + public function convert($string, $from_encoding) + { $encoded = iconv($from_encoding, $this->enc, $string); if ($encoded === false) { - throw new BAV_EncodingException(); - + throw new EncodingException(); + } return $encoded; } - - } - - -?> \ No newline at end of file diff --git a/classes/encoding/BAV_Encoding_MB.php b/classes/encoding/MBEncoding.php similarity index 80% rename from classes/encoding/BAV_Encoding_MB.php rename to classes/encoding/MBEncoding.php index 77808925..3b380f48 100644 --- a/classes/encoding/BAV_Encoding_MB.php +++ b/classes/encoding/MBEncoding.php @@ -1,6 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Encoding_MB extends BAV_Encoding { +class MBEncoding extends Encoding +{ /** * @return bool */ - static public function isSupported($encoding) { + public static function isSupported($encoding) + { return function_exists("mb_list_encodings") && in_array($encoding, mb_list_encodings()); } + /** - * @throws BAV_EncodingException_Unsupported + * @throws UnsupportedEncodingException * @param String $encoding */ - public function __construct($encoding = 'UTF-8') { + public function __construct($encoding = 'UTF-8') + { parent::__construct($encoding); mb_internal_encoding($encoding); } + /** * @return int length of $string */ - public function strlen($string) { + public function strlen($string) + { return mb_strlen($string); } + /** * @param String $string * @param int $offset * @param int $length * @return String */ - public function substr($string, $offset, $length = null) { + public function substr($string, $offset, $length = null) + { return is_null($length) ? mb_substr($string, $offset) : mb_substr($string, $offset, $length); } + /** * @param String $string * @param String $from_encoding * @return $string the encoded string */ - public function convert($string, $from_encoding) { + public function convert($string, $from_encoding) + { return mb_convert_encoding($string, $this->enc, $from_encoding); } - - } - - -?> \ No newline at end of file diff --git a/classes/encoding/exception/BAV_EncodingException.php b/classes/encoding/exception/BAV_EncodingException.php deleted file mode 100644 index 1e83dd8d..00000000 --- a/classes/encoding/exception/BAV_EncodingException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage dataBackend - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_EncodingException extends RuntimeException { - - -} - - -?> \ No newline at end of file diff --git a/classes/dataBackend/exception/BAV_DataBackendException_IO.php b/classes/encoding/exception/EncodingException.php similarity index 87% rename from classes/dataBackend/exception/BAV_DataBackendException_IO.php rename to classes/encoding/exception/EncodingException.php index 069f7967..6176b56f 100644 --- a/classes/dataBackend/exception/BAV_DataBackendException_IO.php +++ b/classes/encoding/exception/EncodingException.php @@ -1,6 +1,6 @@ @@ -23,12 +23,10 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_DataBackendException_IO extends BAV_DataBackendException { - +class EncodingException extends BAVException +{ } - - -?> \ No newline at end of file diff --git a/classes/encoding/exception/BAV_EncodingException_Unsupported.php b/classes/encoding/exception/UnsupportedEncodingException.php similarity index 80% rename from classes/encoding/exception/BAV_EncodingException_Unsupported.php rename to classes/encoding/exception/UnsupportedEncodingException.php index f70d8d23..8aed228d 100644 --- a/classes/encoding/exception/BAV_EncodingException_Unsupported.php +++ b/classes/encoding/exception/UnsupportedEncodingException.php @@ -1,6 +1,6 @@ @@ -23,32 +23,29 @@ * @package classes * @subpackage dataBackend * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_EncodingException_Unsupported extends BAV_EncodingException { - +class UnsupportedEncodingException extends EncodingException +{ - private /** * @var String */ - $encoding = ''; - - - public function __construct($encoding) { + private $encoding = ''; + + public function __construct($encoding) + { parent::__construct(); - + $this->encoding = $encoding; } + /** * @return String */ - public function getEncoding() { + public function getEncoding() + { return $this->encoding; } - - } - - -?> \ No newline at end of file diff --git a/classes/exception/BAVException.php b/classes/exception/BAVException.php new file mode 100644 index 00000000..bb8ce8c1 --- /dev/null +++ b/classes/exception/BAVException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class BAVException extends \Exception +{ + +} diff --git a/classes/util/BICUtil.php b/classes/util/BICUtil.php new file mode 100644 index 00000000..28371bce --- /dev/null +++ b/classes/util/BICUtil.php @@ -0,0 +1,25 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class BICUtil +{ + + /** + * Extends an 8 character BIC to an 11 character BIC. + * + * @param string $bic BIC + * @return string + */ + public static function normalize($bic) + { + return (strlen($bic) == 8) ? "{$bic}XXX" : $bic; + } +} diff --git a/classes/util/FileUtil.php b/classes/util/FileUtil.php new file mode 100644 index 00000000..1b47f416 --- /dev/null +++ b/classes/util/FileUtil.php @@ -0,0 +1,131 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class FileUtil +{ + + /** + * @var Configuration + */ + private $configuration; + + /** + * @var string + */ + private $cachedTempDirectory = null; + + /** + * Inject the configuration. + */ + public function __construct(Configuration $configuration = null) + { + if (is_null($configuration)) { + $configuration = ConfigurationRegistry::getConfiguration(); + + } + $this->configuration = $configuration; + } + + /** + * Renames a file atomically between different filesystems. + * + * @param String $source path of the source + * @param String $destination path of the destination + * @throws FileException + */ + public function safeRename($source, $destination) + { + $isRenamed = @rename($source, $destination); + if ($isRenamed) { + return; + + } + + // copy to the target filesystem + $tempFileOnSameFS = "$destination.tmp"; + + $isCopied = copy($source, $tempFileOnSameFS); + if (! $isCopied) { + throw new FileException( + "failed to copy $source to $tempFileOnSameFS." + ); + + } + + $isUnlinked = unlink($source); + if (! $isUnlinked) { + trigger_error("Failed to unlink $source."); + + } + + $isRenamed = rename($tempFileOnSameFS, $destination); + if (! $isRenamed) { + throw new FileException( + "failed to rename $tempFileOnSameFS to $destination." + ); + + } + } + + /** + * Returns a writable directory for temporary files + * + * @return String + * @see Configuration::setTempDirectory() + * @throws NoTempDirectoryException + */ + public function getTempDirectory() + { + if (! is_null($this->configuration->getTempDirectory())) { + return $this->configuration->getTempDirectory(); + + } + + if (is_null($this->cachedTempDirectory)) { + $this->cachedTempDirectory = $this->findTempDirectory(); + + } + return $this->cachedTempDirectory; + } + + /** + * @return string + * @throws NoTempDirectoryException + */ + private function findTempDirectory() + { + $tmpDirs = array( + function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : false, + empty($_ENV['TMP']) ? false : $_ENV['TMP'], + empty($_ENV['TMPDIR']) ? false : $_ENV['TMPDIR'], + empty($_ENV['TEMP']) ? false : $_ENV['TEMP'], + ini_get('upload_tmp_dir'), + '/tmp', + __DIR__ . "/../../data/" + ); + + foreach ($tmpDirs as $tmpDir) { + if ($tmpDir && is_writable($tmpDir)) { + return realpath($tmpDir); + + } + } + + $tempfile = tempnam(uniqid(mt_rand(), true), ''); + if (file_exists($tempfile)) { + unlink($tempfile); + return realpath(dirname($tempfile)); + + } + + throw new NoTempDirectoryException(); + } +} diff --git a/classes/util/Lock.php b/classes/util/Lock.php new file mode 100644 index 00000000..7b4cc059 --- /dev/null +++ b/classes/util/Lock.php @@ -0,0 +1,150 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + * @see DataBackend + */ +class Lock +{ + + /** + * @var string + */ + private $name; + + /** + * @var resource + */ + private $handle; + + /** + * @param string $name lock name + * @throws LockException + */ + public function __construct($name) + { + $this->name = $name; + + $fileUtil = new FileUtil(); + $lockFile = $fileUtil->getTempDirectory() . DIRECTORY_SEPARATOR . $name; + + $this->handle = fopen($lockFile, "w"); + if (! is_resource($this->handle)) { + throw new LockException("Could not open lock file $lockFile."); + + } + } + + /** + * Get a lock and execute a task. + * + * If more processes call this method only the process which aquired the lock + * will execute the task. The others will block but won't execute the task. + * + * @throws Exception + */ + public function executeOnce(\Closure $task) + { + $isBlocked = $this->checkedLock(); + $error = null; + try { + if (! $isBlocked) { + call_user_func($task); + + } + } catch (\Exception $e) { + $error = $e; + + } + $this->unlock(); + if (! is_null($error)) { + throw $error; + + } + } + + /** + * Get a lock and execute a task only if the lock was aquired. + * + * If more processes call this method only the process which aquired the lock + * will execute the task. The others will continue execution. + * + * @throws Exception + */ + public function nonblockingExecuteOnce(\Closure $task) + { + if (! $this->nonblockingLock()) { + return; + + } + $error = null; + try { + call_user_func($task); + + } catch (\Exception $e) { + $error = $e; + + } + $this->unlock(); + if (! is_null($error)) { + throw $error; + + } + } + + /** + * Blocking lock + * + * @throws LockException + */ + public function lock() + { + if (! flock($this->handle, LOCK_EX)) { + throw new LockException("flock() failed for {$this->name}."); + + } + } + + /** + * Nonblocking lock which returns if the lock was aquired + * + * @return bool true if the lock was aquired. + */ + public function nonblockingLock() + { + return flock($this->handle, LOCK_EX | LOCK_NB); + } + + /** + * Blocking lock which returns if the lock did block. + * + * @throws LockException + * @return bool true if the lock was blocked. + */ + public function checkedLock() + { + $isLocked = ! flock($this->handle, LOCK_EX | LOCK_NB); + if ($isLocked) { + $this->lock(); + + } + return $isLocked; + } + + /** + * @throws LockException + */ + public function unlock() + { + if (! flock($this->handle, LOCK_UN)) { + throw new LockException("flock() failed releasing {$this->name}."); + + } + } +} diff --git a/classes/util/exception/FileException.php b/classes/util/exception/FileException.php new file mode 100644 index 00000000..c02388d4 --- /dev/null +++ b/classes/util/exception/FileException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class FileException extends BAVException +{ + +} diff --git a/classes/util/exception/LockException.php b/classes/util/exception/LockException.php new file mode 100644 index 00000000..7dc9a2a4 --- /dev/null +++ b/classes/util/exception/LockException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class LockException extends BAVException +{ + +} diff --git a/classes/util/exception/NoTempDirectoryException.php b/classes/util/exception/NoTempDirectoryException.php new file mode 100644 index 00000000..00629446 --- /dev/null +++ b/classes/util/exception/NoTempDirectoryException.php @@ -0,0 +1,15 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class NoTempDirectoryException extends FileException +{ + +} diff --git a/classes/validator/ContextValidation.php b/classes/validator/ContextValidation.php new file mode 100644 index 00000000..c48709bf --- /dev/null +++ b/classes/validator/ContextValidation.php @@ -0,0 +1,130 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class ContextValidation +{ + + /** + * @var bool + */ + private $initialized = false; + + /** + * @var DataBackend + */ + private $backend; + + /** + * @var Bank + */ + private $bank; + + /** + * Injects the backend. + */ + public function __construct(DataBackend $backend) + { + $this->backend = $backend; + } + + /** + * Returns true if a bank exists. + * + * This method sets the bank context and should be called first. + * + * @throws DataBackendException + * @param string $bankID + * @return bool + * @see DataBackend::isValidBank() + */ + public function isValidBank($bankID) + { + try { + $this->initialized = true; + $this->bank = $this->backend->getBank($bankID); + return true; + + } catch (BankNotFoundException $e) { + $this->bank = null; + return false; + + } + } + + /** + * Returns true if the account is valid for the current context. + * + * You have to have called isValidBank() before! If the current context + * is no valid bank every account will validate to true. + * + * @param string $account + * @see isValidBank() + * @see Bank::isValid() + * @throws InvalidContextException isValidBank() was not called before. + * @return bool + */ + public function isValidAccount($account) + { + if (! $this->initialized) { + throw new InvalidContextException("You have to call isValidBank() before."); + + } + + // No valid bank makes every account valid + if ($this->bank == null) { + return true; + + } + + return $this->bank->isValid($account); + } + + /** + * Returns the third call back parameter for filter_var() for validating + * a bank. + * + * filter_var($bankID, FILTER_CALLBACK, $validation->getValidBankFilterCallback()); + * + * @return array + * @see isValidBank() + * @see filter_var() + */ + public function getValidBankFilterCallback() + { + $validation = $this; + return array("options" => function ($bankID) use ($validation) { + return $validation->isValidBank($bankID); + }); + } + + /** + * Returns the third call back parameter for filter_var() for validating + * a bank account. + * + * filter_var($account, FILTER_CALLBACK, $validation->getValidBankFilterCallback()); + * + * @return array + * @see isValidAccount() + * @see filter_var() + */ + public function getValidAccountFilterCallback() + { + $validation = $this; + return array("options" => function ($account) use ($validation) { + return $validation->isValidAccount($account); + }); + } +} diff --git a/classes/validator/BAV_Validator_Iteration_Transformation.php b/classes/validator/TransformationIterationValidator.php similarity index 75% rename from classes/validator/BAV_Validator_Iteration_Transformation.php rename to classes/validator/TransformationIterationValidator.php index d95cd5ed..8ab68295 100644 --- a/classes/validator/BAV_Validator_Iteration_Transformation.php +++ b/classes/validator/TransformationIterationValidator.php @@ -1,6 +1,6 @@ @@ -23,63 +23,68 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -abstract class BAV_Validator_Iteration_Transformation extends BAV_Validator_Iteration { - +abstract class TransformationIterationValidator extends ValidatorIteration +{ - private /** * @var Array */ - $rowIteration = array(), + private $rowIteration = array(); + /** * @var Array */ - $matrix = array(); - - + private $matrix = array(); + /** * The iteration step */ - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->getTransformedNumber(); } + /** */ - public function setMatrix(Array $matrix) { + public function setMatrix(Array $matrix) + { $this->matrix = $matrix; if (empty($this->rowIteration)) { - for($i = 0; $i < count($matrix); $i++) { + for ($i = 0; $i < count($matrix); $i++) { $this->rowIteration[] = $i; - + } - + } } + /** */ - public function setRowIteration(Array $rowIteration) { + public function setRowIteration(Array $rowIteration) + { $this->rowIteration = $rowIteration; } + /** * @return array */ - protected function getTransformationRow() { + protected function getTransformationRow() + { return $this->matrix[$this->rowIteration[$this->i % count($this->rowIteration)]]; } + /** * @param int $i * @return int */ - protected function getTransformedNumber() { + protected function getTransformedNumber() + { $row = $this->getTransformationRow(); return array_key_exists($this->number, $row) ? $row[$this->number] : 0; } - } - - -?> \ No newline at end of file diff --git a/classes/validator/BAV_Validator.php b/classes/validator/Validator.php similarity index 50% rename from classes/validator/BAV_Validator.php rename to classes/validator/Validator.php index a27f5007..d058f42e 100644 --- a/classes/validator/BAV_Validator.php +++ b/classes/validator/Validator.php @@ -1,10 +1,6 @@ @@ -23,233 +19,268 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -abstract class BAV_Validator extends BAV { +abstract class Validator +{ - - protected /** * @var int */ - $normalizedSize = 10, + protected $normalizedSize = 10; + /** * @var string */ - $account = '', + protected $account = ''; + /** * @var int */ - $checknumberPosition = -1, + protected $checknumberPosition = -1; + /** * @var int */ - $eserChecknumberOffset = 0, + protected $eserChecknumberOffset = 0; + /** * @var bool */ - $doNormalization = true, + protected $doNormalization = true; + /** - * @var BAV_Bank + * @var Bank */ - $bank; + protected $bank; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { $this->bank = $bank; $this->setChecknumberPosition(-1); } + /** - * @throws BAV_ValidatorException_NotExists - * @return BAV_Validator + * Raises a E_USER_WARNING for non string accounts. + * + * @param string $account bank account */ - static public function getInstance(BAV_Bank $bank) { - $type = trim(strtoupper($bank->getValidationType())); - $class = "BAV_Validator_$type"; - $file = __DIR__."/validators/$class.php"; - if (! file_exists($file)) { - throw new BAV_ValidatorException_NotExists($bank); - + protected function checkType($account) + { + if (is_string($account)) { + return; + } - require_once $file; - return new $class($bank); + trigger_error( + "Only validation of strings are defined." + . "Note that e.g. an (int) 0020012357 evaluates to (string) '4199663'.", + E_USER_WARNING + ); } - /** - * @param string $account + * Validates a bank account. + * + * Null is considered invalid. + * + * Note: The parameter $account should be a string. If it's not a string + * an E_USER_WARNING will be raised. Bank accounts may start with leading + * zeros, wich lead to unexpected results if not treated as a string ( + * e.g. (int) 0020012357 evaluates to (string) '4199663'). + * + * @param string $account bank account * @return bool */ - public function isValid($account) { - try { + public function isValid($account) + { + try { + if ($account == null) { + return false; + + } + $this->checkType($account); $this->init($account); $this->validate(); return ltrim($account, "0") != "" && $this->getResult(); - - } catch (BAV_ValidatorException_OutOfBounds $e) { - return false; - - } + + } catch (ValidatorOutOfBoundsException $e) { + return false; + + } } - - - public function setChecknumberPosition($position) { + + public function setChecknumberPosition($position) + { $this->checknumberPosition = $position; } - public function setNormalizedSize($size) { + + public function setNormalizedSize($size) + { $this->normalizedSize = $size; } + /** * @param string $account */ - protected function init($account) { + protected function init($account) + { $this->account = $account; if ($this->doNormalization) { $this->normalizeAccount($this->normalizedSize); - + } } + abstract protected function validate(); + /** * @return bool */ abstract protected function getResult(); - - + /** * @return string */ - protected function getChecknumber() { - return $this->account{$this->getNormalizedPosition($this->checknumberPosition)}; + protected function getChecknumber() + { + return $this->account[$this->getNormalizedPosition($this->checknumberPosition)]; } + /** * converts negative positions. * - * @param int $pos + * @param int $pos * @return int - * @throws BAV_ValidatorException_OutOfBounds - */ - protected function getNormalizedPosition($pos) { - if ($pos >= strlen($this->account) || $pos < -strlen($this->account)) { - throw new BAV_ValidatorException_OutOfBounds("Cannot access offset $pos in String $this->account"); - - } - + * @throws ValidatorOutOfBoundsException + */ + protected function getNormalizedPosition($pos) + { + if ($pos >= strlen($this->account) || $pos < -strlen($this->account)) { + throw new ValidatorOutOfBoundsException("Cannot access offset $pos in String $this->account"); + + } + if ($pos >= 0) { return $pos; } return strlen($this->account) + $pos; } - - + /** * Some validators need this * - * @param int $int + * @param int $int * @return int */ - protected function crossSum($int) { + protected function crossSum($int) + { $sum = 0; $str_int = (string) $int; for ($i = 0; $i < strlen($str_int); $i++) { - //$sum = bcadd($str_int{$i}, $sum); - $sum += $str_int{$i}; + //$sum = bcadd($str_int{$i}, $sum); + $sum += $str_int[$i]; } return $sum; } - - + /** - * @throws BAV_ValidatorException_OutOfBounds - * @param int $int + * @throws ValidatorOutOfBoundsException + * @param int $int */ - protected function normalizeAccount($size) { + protected function normalizeAccount($size) + { $account = (string) $this->account; if (strlen($account) > $size) { - throw new BAV_ValidatorException_OutOfBounds("Can't normalize $account to size $size."); + throw new ValidatorOutOfBoundsException("Can't normalize $account to size $size."); } $this->account = str_repeat('0', $size - strlen($account)) . $account; } + /** - * @throws BAV_ValidatorException_ESER + * @throws ValidatorESERException * @return string */ - protected function getESER8() { + protected function getESER8() + { $account = ltrim($this->account, '0'); - + if (strlen($account) != 8) { - throw new BAV_ValidatorException_ESER(); + throw new ValidatorESERException(); } $bankID = $this->bank->getBankID(); - if ($bankID{3} != 5) { - throw new BAV_ValidatorException_ESER(); + if ($bankID[3] != 5) { + throw new ValidatorESERException(); } $blzPart = ltrim(substr($bankID, 4), '0'); - + $this->eserChecknumberOffset = -(4 - strlen($blzPart)); - + if (empty($blzPart)) { - throw new BAV_ValidatorException_ESER(); + throw new ValidatorESERException(); } $accountPart = ltrim(substr($account, 2), '0'); - $eser = $blzPart.$account{0}.$account{1}.$accountPart; + $eser = $blzPart.$account[0].$account[1].$accountPart; return $eser; } + /** - * @throws BAV_ValidatorException_ESER + * @throws ValidatorESERException * @return string */ - protected function getESER9() { + protected function getESER9() + { $bankID = $this->bank->getBankID(); $account = ltrim($this->account, '0'); if (strlen($account) != 9) { - throw new BAV_ValidatorException_ESER(); + throw new ValidatorESERException(); } - if ($bankID{3} != 5) { - throw new BAV_ValidatorException_ESER(); + if ($bankID[3] != 5) { + throw new ValidatorESERException(); } $blzPart0 = substr($bankID, -4, 2); $blzPart1 = substr($bankID, -1); - $accountPart0 = $account{0}; - $t = $account{1}; - $p = $account{2}; + $accountPart0 = $account[0]; + $t = $account[1]; + $p = $account[2]; $accountTail = ltrim(substr($account, 3), '0'); $eser = $blzPart0.$t.$blzPart1.$accountPart0.$p.$accountTail; return $eser; } - protected function getEserChecknumberPosition() { + + protected function getEserChecknumberPosition() + { return $this->getNormalizedPosition($this->checknumberPosition + $this->eserChecknumberOffset); } - protected function getEserChecknumber() { - return $this->account{$this->getEserChecknumberPosition()}; + + protected function getEserChecknumber() + { + return $this->account[$this->getEserChecknumberPosition()]; } - protected function isBetween($a, $b) { + + protected function isBetween($a, $b) + { $account = (int) ltrim($this->account, '0'); - + return $a < $b ? $account >= $a && $account <= $b : $account >= $b && $account <= $a; } - } - - -?> \ No newline at end of file diff --git a/classes/validator/BAV_Validator_BankDependent.php b/classes/validator/ValidatorBankDependent.php similarity index 89% rename from classes/validator/BAV_Validator_BankDependent.php rename to classes/validator/ValidatorBankDependent.php index 1811d84a..4ca92ae0 100644 --- a/classes/validator/BAV_Validator_BankDependent.php +++ b/classes/validator/ValidatorBankDependent.php @@ -1,8 +1,10 @@ * * This program is free software; you can redistribute it and/or modify @@ -23,11 +25,10 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2009 Markus Malkusch */ -interface BAV_Validator_BankDependent { - -} +interface ValidatorBankDependent +{ - -?> \ No newline at end of file +} diff --git a/classes/validator/BAV_Validator_Chain.php b/classes/validator/ValidatorChain.php similarity index 80% rename from classes/validator/BAV_Validator_Chain.php rename to classes/validator/ValidatorChain.php index 539473ae..216fb21f 100644 --- a/classes/validator/BAV_Validator_Chain.php +++ b/classes/validator/ValidatorChain.php @@ -1,7 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_Chain extends BAV_Validator { +class ValidatorChain extends Validator +{ - - protected /** * @var Array a list of validators */ - $validators = array(); - + protected $validators = array(); /** * Adds a validator to the chain * - * @param BAV_Validator $validator Validator + * @param Validator $validator Validator * * @return void */ - public function addValidator(BAV_Validator $validator) { + public function addValidator(Validator $validator) + { $this->validators[] = $validator; } - /** * Iterates through the validators. * * @return bool */ - protected function getResult() { + protected function getResult() + { foreach ($this->validators as $validator) { if (! $this->continueValidation($validator)) { return false; - + } if ($this->useValidator($validator) && $validator->isValid($this->account)) { return true; - + } - + } return false; } + /** * should not be used */ - final protected function validate() { + final protected function validate() + { } + /** * After each successless iteration step this method will be called and * should return if the iteration should stop and the account is invalid. * * @return bool */ - protected function continueValidation(BAV_Validator $validator) { + protected function continueValidation(Validator $validator) + { return true; } + /** * Decide if you really want to use this validator * * @return bool */ - protected function useValidator(BAV_Validator $validator) { + protected function useValidator(Validator $validator) + { return true; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/ValidatorFactory.php b/classes/validator/ValidatorFactory.php new file mode 100644 index 00000000..61267a4a --- /dev/null +++ b/classes/validator/ValidatorFactory.php @@ -0,0 +1,27 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @license WTFPL + */ +class ValidatorFactory +{ + + /** + * Builds a validator for a bank. + * + * @return Validator + * @see Bank::getValidationType() + * @see Bank::getValidator() + */ + public function build(Bank $bank) + { + $class = sprintf('%s\Validator%s', __NAMESPACE__, $bank->getValidationType()); + return new $class($bank); + } +} diff --git a/classes/validator/BAV_Validator_Iteration.php b/classes/validator/ValidatorIteration.php similarity index 71% rename from classes/validator/BAV_Validator_Iteration.php rename to classes/validator/ValidatorIteration.php index 79c28c2f..39c0ef51 100644 --- a/classes/validator/BAV_Validator_Iteration.php +++ b/classes/validator/ValidatorIteration.php @@ -1,6 +1,6 @@ @@ -19,96 +19,101 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -abstract class BAV_Validator_Iteration extends BAV_Validator { - +abstract class ValidatorIteration extends Validator +{ - protected /** * @var int */ - $i = 0, + protected $i = 0; + /** * @var int */ - $position = 0, + protected $position = 0; + /** * @var int */ - $number = 0, + protected $number = 0; + /** * @var int an accumulator for the iteration */ - $accumulator = 0; - - - private + protected $accumulator = 0; + /** * @var int The inclusive beginning point of the iteration */ - $start = -2, + private $start = -2; + /** * @var int The inclusive ending point of the iteration */ - $end = 0; - + private $end = 0; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - + $this->setStart(-2); $this->setEnd(0); } + /** * @param int $start */ - public function setStart($start) { + public function setStart($start) + { $this->start = $start; } + /** * @param int $end */ - public function setEnd($end) { + public function setEnd($end) + { $this->end = $end; } + /** * @param string $account */ - protected function init($account) { + protected function init($account) + { parent::init($account); $this->accumulator = 0; } - protected function validate() { + + protected function validate() + { $start = $this->getNormalizedPosition($this->start); $end = $this->getNormalizedPosition($this->end); $length = abs($end - $start) + 1; - + $this->position = $start; $stepping = (($end - $start < 0) ? -1 : +1); - - - for($this->i = 0; $this->i < $length; $this->i++) { - $this->number = (int)$this->account{$this->position}; + + + for ($this->i = 0; $this->i < $length; $this->i++) { + $this->number = (int)$this->account[$this->position]; $this->iterationStep(); $this->position += $stepping; } } + /** * The iteration step * * @param int $i */ abstract protected function iterationStep(); - - } - - -?> \ No newline at end of file diff --git a/classes/validator/BAV_Validator_Iteration_Weighted.php b/classes/validator/WeightedIterationValidator.php similarity index 78% rename from classes/validator/BAV_Validator_Iteration_Weighted.php rename to classes/validator/WeightedIterationValidator.php index 9ccb538b..9828d549 100644 --- a/classes/validator/BAV_Validator_Iteration_Weighted.php +++ b/classes/validator/WeightedIterationValidator.php @@ -1,6 +1,6 @@ @@ -23,49 +23,42 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -abstract class BAV_Validator_Iteration_Weighted extends BAV_Validator_Iteration { - +abstract class WeightedIterationValidator extends ValidatorIteration +{ - protected /** * @var int */ - $divisor = 0; - - - private + protected $divisor = 0; + /** * @var Array an array of rotating weights */ - $weights = array(); - - + private $weights = array(); + /** */ - public function setWeights(Array $weights) { + public function setWeights(Array $weights) + { $this->weights = $weights; } - - + /** * @param int $divisor */ - public function setDivisor($divisor) { + public function setDivisor($divisor) + { $this->divisor = $divisor; } - - + /** * @return int */ - protected function getWeight() { + protected function getWeight() + { return $this->weights[$this->i % count($this->weights)]; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/exception/BAV_ValidatorException_NotExists.php b/classes/validator/exception/BAV_ValidatorException_NotExists.php deleted file mode 100644 index 9281bebb..00000000 --- a/classes/validator/exception/BAV_ValidatorException_NotExists.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_ValidatorException_NotExists extends BAV_ValidatorException { - - - private - /** - * @var BAV_Bank - */ - $bank; - - - public function __construct(BAV_Bank $bank) { - $this->bank = $bank; - } - /** - * @return BAV_Bank - */ - public function getBank() { - return $this->bank; - } - - -} - - -?> \ No newline at end of file diff --git a/classes/validator/exception/BAV_ValidatorException_ESER.php b/classes/validator/exception/ValidatorESERException.php similarity index 86% rename from classes/validator/exception/BAV_ValidatorException_ESER.php rename to classes/validator/exception/ValidatorESERException.php index e8caa55d..797cf30c 100644 --- a/classes/validator/exception/BAV_ValidatorException_ESER.php +++ b/classes/validator/exception/ValidatorESERException.php @@ -1,6 +1,6 @@ @@ -23,12 +23,10 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_ValidatorException_ESER extends BAV_ValidatorException { - +class ValidatorESERException extends ValidatorException +{ } - - -?> \ No newline at end of file diff --git a/classes/validator/exception/BAV_ValidatorException.php b/classes/validator/exception/ValidatorException.php similarity index 87% rename from classes/validator/exception/BAV_ValidatorException.php rename to classes/validator/exception/ValidatorException.php index 54a21d72..d51aba14 100644 --- a/classes/validator/exception/BAV_ValidatorException.php +++ b/classes/validator/exception/ValidatorException.php @@ -1,5 +1,6 @@ @@ -22,12 +23,10 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_ValidatorException extends RuntimeException { - +class ValidatorException extends BAVException +{ } - - -?> \ No newline at end of file diff --git a/classes/validator/exception/BAV_ValidatorException_OutOfBounds.php b/classes/validator/exception/ValidatorOutOfBoundsException.php similarity index 86% rename from classes/validator/exception/BAV_ValidatorException_OutOfBounds.php rename to classes/validator/exception/ValidatorOutOfBoundsException.php index 2ce7b373..84537b86 100644 --- a/classes/validator/exception/BAV_ValidatorException_OutOfBounds.php +++ b/classes/validator/exception/ValidatorOutOfBoundsException.php @@ -1,6 +1,6 @@ @@ -23,12 +23,10 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_ValidatorException_OutOfBounds extends BAV_ValidatorException { - +class ValidatorOutOfBoundsException extends ValidatorException +{ } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_68.php b/classes/validator/validators/BAV_Validator_68.php deleted file mode 100644 index 1871c852..00000000 --- a/classes/validator/validators/BAV_Validator_68.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_Validator_68 extends BAV_Validator_Chain { - - - private - /** - * @var BAV_Validator_10 - */ - $validator10; - - - public function __construct(BAV_Bank $bank) { - parent::__construct($bank); - - $this->validator10 = new BAV_Validator_00($bank); - $this->validator10->setEnd(3); - - $this->validators[] = new BAV_Validator_00($bank); - - $this->validators[] = new BAV_Validator_00($bank); - $this->validators[1]->setWeights(array(2, 1, 2, 1, 2, 0, 0, 1)); - } - - - public function isValid($account) { - switch (strlen($account)) { - - case 10: - return $account{3} == 9 && $this->validator10->isValid($account); - - case 9: - if ($account >= 400000000 && $account <= 499999999) { - return false; - - } - - case 6: case 7: case 8: case 9: - return parent::isValid($account); - - default: - return false; - - } - } - - -} - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C5.php b/classes/validator/validators/BAV_Validator_C5.php deleted file mode 100644 index e65e7a03..00000000 --- a/classes/validator/validators/BAV_Validator_C5.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2007 Markus Malkusch - */ -class BAV_Validator_C5 extends BAV_Validator { - - - protected - /** - * @var BAV_Validator - */ - $validator, - /** - * @var BAV_Validator_75 - */ - $mode1, - /** - * @var BAV_Validator_29 - */ - $mode2, - /** - * @var BAV_Validator_00 - */ - $mode3, - /** - * @var BAV_Validator_09 - */ - $mode4; - - - public function __construct(BAV_Bank $bank) { - parent::__construct($bank); - - $this->mode1 = new BAV_Validator_75($bank); - $this->mode2 = new BAV_Validator_29($bank); - $this->mode3 = new BAV_Validator_00($bank); - $this->mode4 = new BAV_Validator_09($bank); - } - protected function validate() { - $account = ltrim($this->account, '0'); - $length = strlen($account); - - switch ($length) { - - case 6: - case 9: - if ($account{0} < 9) { - $this->validator = $this->mode1; - } - break; - - case 8: - if ($account{0} >= 3 && $account{0} <= 5) { - $this->validator = $this->mode4; - - } - break; - - case 10: - if ($account{0} == 1 || $account{0} >= 4 && $account{0} <= 6 || $account{0} == 9) { - $this->validator = $this->mode2; - - } elseif ($account{0} == 3) { - $this->validator = $this->mode3; - - } else { - $circle = substr($account, 0, 2); - if ($circle == 70 || $circle = 85) { - $this->validator = $this->mode4; - - } - } - break; - - default: - $this->validator = null; - break; - } - } - /** - * @return bool - */ - protected function getResult() { - return ! is_null($this->validator) && $this->validator->isValid($this->account); - } - - -} - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_00.php b/classes/validator/validators/Validator00.php similarity index 85% rename from classes/validator/validators/BAV_Validator_00.php rename to classes/validator/validators/Validator00.php index b199ff55..2771578a 100644 --- a/classes/validator/validators/BAV_Validator_00.php +++ b/classes/validator/validators/Validator00.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setDivisor(10); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - protected function getResult() { + protected function getResult() + { $result = $this->divisor - ($this->accumulator % $this->divisor); $result = ($result == $this->divisor) ? 0 : $result; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_01.php b/classes/validator/validators/Validator01.php similarity index 83% rename from classes/validator/validators/BAV_Validator_01.php rename to classes/validator/validators/Validator01.php index f33ea6d0..50b7104d 100644 --- a/classes/validator/validators/BAV_Validator_01.php +++ b/classes/validator/validators/Validator01.php @@ -1,7 +1,6 @@ setWeights(array(3, 7, 1)); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_02.php b/classes/validator/validators/Validator02.php similarity index 85% rename from classes/validator/validators/BAV_Validator_02.php rename to classes/validator/validators/Validator02.php index 82952d43..bdf0a0ba 100644 --- a/classes/validator/validators/BAV_Validator_02.php +++ b/classes/validator/validators/Validator02.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9)); $this->setDivisor(11); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->divisor - $this->accumulator % $this->divisor; $result = ($result == $this->divisor) ? 0 : $result; return $result == 10 ? false : (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_03.php b/classes/validator/validators/Validator03.php similarity index 88% rename from classes/validator/validators/BAV_Validator_03.php rename to classes/validator/validators/Validator03.php index f6a1098b..077815f1 100644 --- a/classes/validator/validators/BAV_Validator_03.php +++ b/classes/validator/validators/Validator03.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_04.php b/classes/validator/validators/Validator04.php similarity index 88% rename from classes/validator/validators/BAV_Validator_04.php rename to classes/validator/validators/Validator04.php index d28ec720..4264b3c3 100644 --- a/classes/validator/validators/BAV_Validator_04.php +++ b/classes/validator/validators/Validator04.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_05.php b/classes/validator/validators/Validator05.php similarity index 88% rename from classes/validator/validators/BAV_Validator_05.php rename to classes/validator/validators/Validator05.php index 77fa60ac..e192b001 100644 --- a/classes/validator/validators/BAV_Validator_05.php +++ b/classes/validator/validators/Validator05.php @@ -1,7 +1,6 @@ setWeights(array(7, 3, 1)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_06.php b/classes/validator/validators/Validator06.php similarity index 85% rename from classes/validator/validators/BAV_Validator_06.php rename to classes/validator/validators/Validator06.php index c92be066..64d50715 100644 --- a/classes/validator/validators/BAV_Validator_06.php +++ b/classes/validator/validators/Validator06.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); $this->setDivisor(11); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->divisor - $this->accumulator % $this->divisor; $result = $result == $this->divisor ? 0 : $result % 10; return (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_07.php b/classes/validator/validators/Validator07.php similarity index 88% rename from classes/validator/validators/BAV_Validator_07.php rename to classes/validator/validators/Validator07.php index 67fb0661..2ca71ac1 100644 --- a/classes/validator/validators/BAV_Validator_07.php +++ b/classes/validator/validators/Validator07.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_08.php b/classes/validator/validators/Validator08.php similarity index 80% rename from classes/validator/validators/BAV_Validator_08.php rename to classes/validator/validators/Validator08.php index ac1c536d..3adab20a 100644 --- a/classes/validator/validators/BAV_Validator_08.php +++ b/classes/validator/validators/Validator08.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } - - - protected function getResult() { - return ((int)$this->account<= 60000) - ? false + + protected function getResult() + { + return ((int)$this->account < 60000) + ? true : parent::getResult(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_09.php b/classes/validator/validators/Validator09.php similarity index 86% rename from classes/validator/validators/BAV_Validator_09.php rename to classes/validator/validators/Validator09.php index 47348032..ddd8fbda 100644 --- a/classes/validator/validators/BAV_Validator_09.php +++ b/classes/validator/validators/Validator09.php @@ -1,7 +1,6 @@ \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_10.php b/classes/validator/validators/Validator10.php similarity index 88% rename from classes/validator/validators/BAV_Validator_10.php rename to classes/validator/validators/Validator10.php index d1158cc1..a6ba929d 100644 --- a/classes/validator/validators/BAV_Validator_10.php +++ b/classes/validator/validators/Validator10.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_11.php b/classes/validator/validators/Validator11.php similarity index 88% rename from classes/validator/validators/BAV_Validator_11.php rename to classes/validator/validators/Validator11.php index ba14d3fa..7b563023 100644 --- a/classes/validator/validators/BAV_Validator_11.php +++ b/classes/validator/validators/Validator11.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); } - - - protected function getResult() { + + protected function getResult() + { $result = 11 - $this->accumulator % 11; switch ($result) { case 11: @@ -46,8 +44,4 @@ protected function getResult() { } return (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_13.php b/classes/validator/validators/Validator13.php similarity index 73% rename from classes/validator/validators/BAV_Validator_13.php rename to classes/validator/validators/Validator13.php index 8f3ec848..fb5625c1 100644 --- a/classes/validator/validators/BAV_Validator_13.php +++ b/classes/validator/validators/Validator13.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setStart(6); $this->setEnd(1); $this->setChecknumberPosition(7); } - - + /** * @param string $account * @return bool */ - public function isValid($account) { - if (parent::isValid($account)) { - return true; - - } - $account = ltrim($account, '0') . '00'; - return strlen($account) <= $this->normalizedSize - && parent::isValid($account); + public function isValid($account) + { + if (parent::isValid($account)) { + return true; + + } + $account = ltrim($account, '0') . '00'; + return strlen($account) <= $this->normalizedSize + && parent::isValid($account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_14.php b/classes/validator/validators/Validator14.php similarity index 89% rename from classes/validator/validators/BAV_Validator_14.php rename to classes/validator/validators/Validator14.php index b5655cfd..f7b85425 100644 --- a/classes/validator/validators/BAV_Validator_14.php +++ b/classes/validator/validators/Validator14.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); $this->setStart(-2); $this->setEnd(3); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_15.php b/classes/validator/validators/Validator15.php similarity index 88% rename from classes/validator/validators/BAV_Validator_15.php rename to classes/validator/validators/Validator15.php index 70be2d6d..a47999a5 100644 --- a/classes/validator/validators/BAV_Validator_15.php +++ b/classes/validator/validators/Validator15.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5)); $this->setStart(-2); $this->setEnd(5); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_16.php b/classes/validator/validators/Validator16.php similarity index 71% rename from classes/validator/validators/BAV_Validator_16.php rename to classes/validator/validators/Validator16.php index 1096e17a..3a8d551e 100644 --- a/classes/validator/validators/BAV_Validator_16.php +++ b/classes/validator/validators/Validator16.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); } - - - protected function getResult() { - return $this->accumulator % 11 === 1 - ? $this->getChecknumber() === $this->account{$this->getNormalizedPosition($this->checknumberPosition) - 1} - : parent::getResult(); - } - + protected function getResult() + { + return $this->accumulator % 11 === 1 + ? $this->getChecknumber() === $this->account[$this->getNormalizedPosition($this->checknumberPosition) - 1] + : parent::getResult(); + } } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_17.php b/classes/validator/validators/Validator17.php similarity index 85% rename from classes/validator/validators/BAV_Validator_17.php rename to classes/validator/validators/Validator17.php index 08982446..6a8e4578 100644 --- a/classes/validator/validators/BAV_Validator_17.php +++ b/classes/validator/validators/Validator17.php @@ -1,7 +1,6 @@ setWeights(array(1, 2)); $this->setStart(1); $this->setEnd(6); $this->setChecknumberPosition(7); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator - 1) % 11) % 10; return $this->accumulator != 0 && (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_18.php b/classes/validator/validators/Validator18.php similarity index 88% rename from classes/validator/validators/BAV_Validator_18.php rename to classes/validator/validators/Validator18.php index f0e051fd..e63faecb 100644 --- a/classes/validator/validators/BAV_Validator_18.php +++ b/classes/validator/validators/Validator18.php @@ -1,7 +1,6 @@ setWeights(array(3, 9, 7, 1)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_19.php b/classes/validator/validators/Validator19.php similarity index 88% rename from classes/validator/validators/BAV_Validator_19.php rename to classes/validator/validators/Validator19.php index 2eab1eff..66616ac4 100644 --- a/classes/validator/validators/BAV_Validator_19.php +++ b/classes/validator/validators/Validator19.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 1)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_20.php b/classes/validator/validators/Validator20.php similarity index 88% rename from classes/validator/validators/BAV_Validator_20.php rename to classes/validator/validators/Validator20.php index c952aae7..d046f405 100644 --- a/classes/validator/validators/BAV_Validator_20.php +++ b/classes/validator/validators/Validator20.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 3)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_21.php b/classes/validator/validators/Validator21.php similarity index 77% rename from classes/validator/validators/BAV_Validator_21.php rename to classes/validator/validators/Validator21.php index 369111ac..f658e638 100644 --- a/classes/validator/validators/BAV_Validator_21.php +++ b/classes/validator/validators/Validator21.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } - - - protected function getResult() { - for ($result = $this->accumulator; $result >= 10; $result = $this->crossSum($result)); + + protected function getResult() + { + $result = $this->accumulator; + while ($result >= 10) { + $result = $this->crossSum($result); + + } $result = 10 - $result; return (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_22.php b/classes/validator/validators/Validator22.php similarity index 83% rename from classes/validator/validators/BAV_Validator_22.php rename to classes/validator/validators/Validator22.php index 2dbd7c77..d5ecfac2 100644 --- a/classes/validator/validators/BAV_Validator_22.php +++ b/classes/validator/validators/Validator22.php @@ -1,7 +1,6 @@ setWeights(array(3, 1)); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += ($this->number * $this->getWeight()) % 10; } - - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_23.php b/classes/validator/validators/Validator23.php similarity index 89% rename from classes/validator/validators/BAV_Validator_23.php rename to classes/validator/validators/Validator23.php index 1a1e8224..707bbc0e 100644 --- a/classes/validator/validators/BAV_Validator_23.php +++ b/classes/validator/validators/Validator23.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); @@ -35,8 +33,4 @@ public function __construct(BAV_Bank $bank) { $this->setEnd(0); $this->setChecknumberPosition(6); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_24.php b/classes/validator/validators/Validator24.php similarity index 80% rename from classes/validator/validators/BAV_Validator_24.php rename to classes/validator/validators/Validator24.php index 5becd93b..6923dc97 100644 --- a/classes/validator/validators/BAV_Validator_24.php +++ b/classes/validator/validators/Validator24.php @@ -1,7 +1,6 @@ setWeights(array(1, 2, 3)); $this->setStart(0); $this->setEnd(-2); } - - - protected function init($account) { - parent::init($account); - + + protected function init($account) + { + parent::init($account); + $this->account = preg_replace('~^([3456]|9..)?0*~', '', $this->account); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += ($this->number * $this->getWeight() + $this->getWeight()) % 11; } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % 10; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_25.php b/classes/validator/validators/Validator25.php similarity index 67% rename from classes/validator/validators/BAV_Validator_25.php rename to classes/validator/validators/Validator25.php index c445ce7a..41ca737f 100644 --- a/classes/validator/validators/BAV_Validator_25.php +++ b/classes/validator/validators/Validator25.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9)); } - - - protected function iterationStep() { + + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - - protected function getResult() { + + protected function getResult() + { $result = 11 - ($this->accumulator % 11); switch ($result) { - - case 10: - $result = 0; - if ($this->account{1} != 8 && $this->account{1} != 9) { - return false; + case 10: + $result = 0; + if ($this->account[1] != 8 && $this->account[1] != 9) { + return false; - } - break; - - case 11: - $result = 0; - break; - - - } - return (string)$result === $this->getCheckNumber(); - } + } + break; + case 11: + $result = 0; + break; + } + return (string)$result === $this->getCheckNumber(); + } } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_26.php b/classes/validator/validators/Validator26.php similarity index 87% rename from classes/validator/validators/BAV_Validator_26.php rename to classes/validator/validators/Validator26.php index de2e4d03..bd1f5174 100644 --- a/classes/validator/validators/BAV_Validator_26.php +++ b/classes/validator/validators/Validator26.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); @@ -35,19 +33,14 @@ public function __construct(BAV_Bank $bank) { $this->setEnd(0); $this->setChecknumberPosition(7); } - - - protected function init($account) { + + protected function init($account) + { parent::init($account); - + if (substr($this->account, 0, 2) === '00') { $this->account = substr($this->account, 2).'00'; } } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_27.php b/classes/validator/validators/Validator27.php similarity index 80% rename from classes/validator/validators/BAV_Validator_27.php rename to classes/validator/validators/Validator27.php index 660713d0..d5d80acd 100644 --- a/classes/validator/validators/BAV_Validator_27.php +++ b/classes/validator/validators/Validator27.php @@ -1,8 +1,6 @@ validator00 = new BAV_Validator_00($bank); - + + $this->validator00 = new Validator00($bank); + $this->setMatrix(array( array(0,1,5,9,3,7,4,8,2,6), array(0,1,7,6,9,8,3,2,5,4), @@ -47,23 +42,24 @@ public function __construct(BAV_Bank $bank) { array(0,1,2,3,4,5,6,7,8,9), )); } + /** * @param string $account * @return bool */ - public function isValid($account) { + public function isValid($account) + { return (int) $account <= 999999999 ? $this->validator00->isValid($account) : parent::isValid($account); } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_28.php b/classes/validator/validators/Validator28.php similarity index 89% rename from classes/validator/validators/BAV_Validator_28.php rename to classes/validator/validators/Validator28.php index 1ec340cd..65790fcb 100644 --- a/classes/validator/validators/BAV_Validator_28.php +++ b/classes/validator/validators/Validator28.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8)); $this->setStart(-4); $this->setEnd(0); $this->setChecknumberPosition(-3); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_29.php b/classes/validator/validators/Validator29.php similarity index 88% rename from classes/validator/validators/BAV_Validator_29.php rename to classes/validator/validators/Validator29.php index 4c8f63e6..79a29d1b 100644 --- a/classes/validator/validators/BAV_Validator_29.php +++ b/classes/validator/validators/Validator29.php @@ -1,7 +1,6 @@ setMatrix(array( array (0, 1, 5, 9, 3, 7, 4, 8, 2, 6), array (0, 1, 7, 6, 9, 8, 3, 2, 5, 4), @@ -37,14 +35,13 @@ public function __construct(BAV_Bank $bank) { array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) )); } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_30.php b/classes/validator/validators/Validator30.php similarity index 86% rename from classes/validator/validators/BAV_Validator_30.php rename to classes/validator/validators/Validator30.php index 5f38f7aa..ecc4b9a6 100644 --- a/classes/validator/validators/BAV_Validator_30.php +++ b/classes/validator/validators/Validator30.php @@ -1,7 +1,6 @@ setWeights(array(2, 0, 0, 0, 0, 1, 2, 1, 2)); $this->setStart(0); $this->setEnd(-2); } - - - protected function iterationStep() { + + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_31.php b/classes/validator/validators/Validator31.php similarity index 84% rename from classes/validator/validators/BAV_Validator_31.php rename to classes/validator/validators/Validator31.php index b9f54670..35dc83d6 100644 --- a/classes/validator/validators/BAV_Validator_31.php +++ b/classes/validator/validators/Validator31.php @@ -1,7 +1,6 @@ setWeights(array(9, 8, 7, 6, 5, 4, 3, 2, 1)); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % 11; if ($result == 11) { $result = 0; - + } elseif ($result == 10) { return false; - + } return (string)$result === $this->getCheckNumber(); } - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_32.php b/classes/validator/validators/Validator32.php similarity index 89% rename from classes/validator/validators/BAV_Validator_32.php rename to classes/validator/validators/Validator32.php index a6ab0f0f..7346ab00 100644 --- a/classes/validator/validators/BAV_Validator_32.php +++ b/classes/validator/validators/Validator32.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); $this->setEnd(3); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_33.php b/classes/validator/validators/Validator33.php similarity index 89% rename from classes/validator/validators/BAV_Validator_33.php rename to classes/validator/validators/Validator33.php index 816055b2..e32550ea 100644 --- a/classes/validator/validators/BAV_Validator_33.php +++ b/classes/validator/validators/Validator33.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6)); $this->setEnd(4); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_34.php b/classes/validator/validators/Validator34.php similarity index 88% rename from classes/validator/validators/BAV_Validator_34.php rename to classes/validator/validators/Validator34.php index 2abff18b..c1b919e7 100644 --- a/classes/validator/validators/BAV_Validator_34.php +++ b/classes/validator/validators/Validator34.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5, 10, 9, 7)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_35.php b/classes/validator/validators/Validator35.php similarity index 80% rename from classes/validator/validators/BAV_Validator_35.php rename to classes/validator/validators/Validator35.php index 0c69e8f1..c2185e64 100644 --- a/classes/validator/validators/BAV_Validator_35.php +++ b/classes/validator/validators/Validator35.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % 11; if ($result === 10) { - return $this->account{9} === $this->account{8}; - + return $this->account[9] === $this->account[8]; + } return (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_36.php b/classes/validator/validators/Validator36.php similarity index 89% rename from classes/validator/validators/BAV_Validator_36.php rename to classes/validator/validators/Validator36.php index 77fdc6b0..f4254442 100644 --- a/classes/validator/validators/BAV_Validator_36.php +++ b/classes/validator/validators/Validator36.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5)); $this->setEnd(5); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_37.php b/classes/validator/validators/Validator37.php similarity index 89% rename from classes/validator/validators/BAV_Validator_37.php rename to classes/validator/validators/Validator37.php index c71db390..b95dab95 100644 --- a/classes/validator/validators/BAV_Validator_37.php +++ b/classes/validator/validators/Validator37.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5, 10)); $this->setEnd(4); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_38.php b/classes/validator/validators/Validator38.php similarity index 89% rename from classes/validator/validators/BAV_Validator_38.php rename to classes/validator/validators/Validator38.php index 3b9a13bd..ecca7957 100644 --- a/classes/validator/validators/BAV_Validator_38.php +++ b/classes/validator/validators/Validator38.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5, 10, 9)); $this->setEnd(3); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_39.php b/classes/validator/validators/Validator39.php similarity index 89% rename from classes/validator/validators/BAV_Validator_39.php rename to classes/validator/validators/Validator39.php index d8fac50f..607ca55f 100644 --- a/classes/validator/validators/BAV_Validator_39.php +++ b/classes/validator/validators/Validator39.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5, 10, 9, 7)); $this->setEnd(2); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_40.php b/classes/validator/validators/Validator40.php similarity index 88% rename from classes/validator/validators/BAV_Validator_40.php rename to classes/validator/validators/Validator40.php index 83a16d87..94ff50bf 100644 --- a/classes/validator/validators/BAV_Validator_40.php +++ b/classes/validator/validators/Validator40.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5, 10, 9, 7, 3, 6)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_41.php b/classes/validator/validators/Validator41.php similarity index 82% rename from classes/validator/validators/BAV_Validator_41.php rename to classes/validator/validators/Validator41.php index c3dd9337..ad03dec9 100644 --- a/classes/validator/validators/BAV_Validator_41.php +++ b/classes/validator/validators/Validator41.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } - - - protected function init($account) { + + protected function init($account) + { parent::init($account); - - if ($this->account{3} == 9) { + + if ($this->account[3] == 9) { $this->setEnd(3); - + } else { $this->setEnd(0); - + } } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_42.php b/classes/validator/validators/Validator42.php similarity index 89% rename from classes/validator/validators/BAV_Validator_42.php rename to classes/validator/validators/Validator42.php index 976b250b..77047561 100644 --- a/classes/validator/validators/BAV_Validator_42.php +++ b/classes/validator/validators/Validator42.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 9)); $this->setEnd(1); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_43.php b/classes/validator/validators/Validator43.php similarity index 83% rename from classes/validator/validators/BAV_Validator_43.php rename to classes/validator/validators/Validator43.php index 35c5f079..071b8372 100644 --- a/classes/validator/validators/BAV_Validator_43.php +++ b/classes/validator/validators/Validator43.php @@ -1,7 +1,6 @@ setWeights(array(1, 2, 3, 4, 5, 6, 7, 8, 9)); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_44.php b/classes/validator/validators/Validator44.php similarity index 88% rename from classes/validator/validators/BAV_Validator_44.php rename to classes/validator/validators/Validator44.php index bf57259e..45894674 100644 --- a/classes/validator/validators/BAV_Validator_44.php +++ b/classes/validator/validators/Validator44.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5, 10, 0, 0, 0, 0)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_45.php b/classes/validator/validators/Validator45.php similarity index 80% rename from classes/validator/validators/BAV_Validator_45.php rename to classes/validator/validators/Validator45.php index 931e6c4e..0bf4bed3 100644 --- a/classes/validator/validators/BAV_Validator_45.php +++ b/classes/validator/validators/Validator45.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } + /** * @return bool */ - protected function getResult() { - return $this->account{0} === '0' - || $this->account{4} === '1' + protected function getResult() + { + return $this->account[0] === '0' + || $this->account[4] === '1' || parent::getResult(); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_46.php b/classes/validator/validators/Validator46.php similarity index 89% rename from classes/validator/validators/BAV_Validator_46.php rename to classes/validator/validators/Validator46.php index 938a9c22..acf4952b 100644 --- a/classes/validator/validators/BAV_Validator_46.php +++ b/classes/validator/validators/Validator46.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6)); $this->setStart(-4); $this->setEnd(2); $this->setChecknumberPosition(7); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_47.php b/classes/validator/validators/Validator47.php similarity index 89% rename from classes/validator/validators/BAV_Validator_47.php rename to classes/validator/validators/Validator47.php index 700c6388..be7af272 100644 --- a/classes/validator/validators/BAV_Validator_47.php +++ b/classes/validator/validators/Validator47.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6)); $this->setStart(-3); $this->setEnd(3); $this->setChecknumberPosition(-2); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_48.php b/classes/validator/validators/Validator48.php similarity index 89% rename from classes/validator/validators/BAV_Validator_48.php rename to classes/validator/validators/Validator48.php index be8e6bbb..668ace03 100644 --- a/classes/validator/validators/BAV_Validator_48.php +++ b/classes/validator/validators/Validator48.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); $this->setStart(-3); $this->setEnd(2); $this->setChecknumberPosition(-2); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_49.php b/classes/validator/validators/Validator49.php similarity index 78% rename from classes/validator/validators/BAV_Validator_49.php rename to classes/validator/validators/Validator49.php index cc65e67e..0ca03e67 100644 --- a/classes/validator/validators/BAV_Validator_49.php +++ b/classes/validator/validators/Validator49.php @@ -1,9 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_49 extends BAV_Validator_Chain { - +class Validator49 extends ValidatorChain +{ /** */ - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->validators[] = new BAV_Validator_00($bank); - $this->validators[] = new BAV_Validator_01($bank); - } - + $this->validators[] = new Validator00($bank); + $this->validators[] = new Validator01($bank); + } } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_50.php b/classes/validator/validators/Validator50.php similarity index 85% rename from classes/validator/validators/BAV_Validator_50.php rename to classes/validator/validators/Validator50.php index 50ab6860..a001592a 100644 --- a/classes/validator/validators/BAV_Validator_50.php +++ b/classes/validator/validators/Validator50.php @@ -1,7 +1,6 @@ normalizedSize && parent::isValid($account); } - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - + $this->setWeights(array(2, 3, 4, 5, 6, 7)); $this->setStart(-5); $this->setEnd(0); $this->setChecknumberPosition(-4); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_51.php b/classes/validator/validators/Validator51.php similarity index 50% rename from classes/validator/validators/BAV_Validator_51.php rename to classes/validator/validators/Validator51.php index 8623c4ce..6250d767 100644 --- a/classes/validator/validators/BAV_Validator_51.php +++ b/classes/validator/validators/Validator51.php @@ -1,10 +1,6 @@ - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_51 extends BAV_Validator_Chain { +class Validator51 extends ValidatorChain +{ - - private /** * @var array */ - $defaultValidators = array(), + private $defaultValidators = array(); + /** * @var array */ - $exceptionValidators = array(), + private $exceptionValidators = array(); + /** - * @var BAV_Validator_33 + * @var Validator33 */ - $validatorC; - - - public function __construct(BAV_Bank $bank) { + private $validatorD; + + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->validatorC = new BAV_Validator_33($this->bank); - - $this->defaultValidators[] = new BAV_Validator_06($this->bank); - $this->defaultValidators[] = new BAV_Validator_33($this->bank); - $this->defaultValidators[] = $this->validatorC; - + + $this->defaultValidators[0] = new Validator06($this->bank); $this->defaultValidators[0]->setWeights(array(2, 3, 4, 5, 6, 7)); $this->defaultValidators[0]->setEnd(3); - + + $this->defaultValidators[1] = new Validator33($this->bank); $this->defaultValidators[1]->setWeights(array(2, 3, 4, 5, 6)); $this->defaultValidators[1]->setEnd(4); - - $this->defaultValidators[2]->setWeights(array(2, 3, 4, 5, 6)); - $this->defaultValidators[2]->setEnd(4); - $this->defaultValidators[2]->setDivisor(7); - + + $this->defaultValidators[2] = new Validator00($this->bank); + $this->defaultValidators[2]->setWeights(array(2, 1)); + $this->defaultValidators[2]->setEnd(3); + $this->defaultValidators[2]->setDivisor(10); + + $this->validatorD = new Validator33($this->bank); + $this->defaultValidators[3] = $this->validatorD; + $this->defaultValidators[3]->setWeights(array(2, 3, 4, 5, 6)); + $this->defaultValidators[3]->setEnd(4); + $this->defaultValidators[3]->setDivisor(7); + $this->exceptionValidators = self::getExceptionValidators($bank); } - - + /** - * @return array + * @return Validator[] */ - static public function getExceptionValidators(BAV_Bank $bank) { + public static function getExceptionValidators(Bank $bank) + { $exceptionValidators = array(); - $exceptionValidators[] = new BAV_Validator_51x($bank); - $exceptionValidators[] = new BAV_Validator_51x($bank); - + $exceptionValidators[] = new Validator51x($bank); + $exceptionValidators[] = new Validator51x($bank); + $exceptionValidators[1]->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); $exceptionValidators[1]->setEnd(0); - + return $exceptionValidators; } - /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? $this->exceptionValidators : $this->defaultValidators; } - - - protected function continueValidation(BAV_Validator $validator) { - if ($validator !== $this->validatorC) { + + protected function continueValidation(Validator $validator) + { + if ($validator !== $this->validatorD) { return true; - - } - switch ($this->account{9}) { - case 7: case 8: case 9: - return false; - - default: - return true; - + } - } + switch ($this->account[9]) { + case 7: + case 8: + case 9: + return false; + default: + return true; + } + } } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_51x.php b/classes/validator/validators/Validator51x.php similarity index 85% rename from classes/validator/validators/BAV_Validator_51x.php rename to classes/validator/validators/Validator51x.php index d5122fc9..f7204b26 100644 --- a/classes/validator/validators/BAV_Validator_51x.php +++ b/classes/validator/validators/Validator51x.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8)); $this->setStart(-2); $this->setEnd(2); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 11 - ($this->accumulator % 11); $result = $result == 11 ? 0 : $result % 10; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_52.php b/classes/validator/validators/Validator52.php similarity index 70% rename from classes/validator/validators/BAV_Validator_52.php rename to classes/validator/validators/Validator52.php index ba9030ba..ca552f54 100644 --- a/classes/validator/validators/BAV_Validator_52.php +++ b/classes/validator/validators/Validator52.php @@ -1,10 +1,6 @@ setWeights(array(2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4)); $this->setStart(-1); $this->setEnd(0); $this->setChecknumberPosition(5); - - $this->validator20 = new BAV_Validator_20($bank); + + $this->validator20 = new Validator20($bank); } - - - public function isValid($account) { + + public function isValid($account) + { try { - return strlen($account) == 10 && $account{0} == 9 + return strlen($account) == 10 && $account[0] == 9 ? $this->validator20->isValid($account) : parent::isValid($account); - - } catch (BAV_ValidatorException_ESER $e) { + + } catch (ValidatorESERException $e) { return false; - + } } - - protected function iterationStep() { + protected function iterationStep() + { if ($this->position == $this->getEserChecknumberPosition()) { $this->checknumberWeight = $this->getWeight(); - + } else { $this->accumulator += $this->number * $this->getWeight(); - + } } - - - protected function normalizeAccount($size) { + + protected function normalizeAccount($size) + { $this->account = $this->getEser8(); } - - protected function getResult() { + protected function getResult() + { return 10 === ($this->accumulator % 11 + $this->checknumberWeight * $this->getEserChecknumber()) % 11; } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_53.php b/classes/validator/validators/Validator53.php similarity index 88% rename from classes/validator/validators/BAV_Validator_53.php rename to classes/validator/validators/Validator53.php index d6dc754c..d8d5356e 100644 --- a/classes/validator/validators/BAV_Validator_53.php +++ b/classes/validator/validators/Validator53.php @@ -1,6 +1,6 @@ account = $this->getEser9(); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_54.php b/classes/validator/validators/Validator54.php similarity index 84% rename from classes/validator/validators/BAV_Validator_54.php rename to classes/validator/validators/Validator54.php index a2e3ca45..a0edcc25 100644 --- a/classes/validator/validators/BAV_Validator_54.php +++ b/classes/validator/validators/Validator54.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 2)); $this->setEnd(2); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 11 - ($this->accumulator % 11); return substr($this->account, 0, 2) === '49' && (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_55.php b/classes/validator/validators/Validator55.php similarity index 88% rename from classes/validator/validators/BAV_Validator_55.php rename to classes/validator/validators/Validator55.php index 3f3c3eea..6e5865df 100644 --- a/classes/validator/validators/BAV_Validator_55.php +++ b/classes/validator/validators/Validator55.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8, 7, 8)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_56.php b/classes/validator/validators/Validator56.php similarity index 80% rename from classes/validator/validators/BAV_Validator_56.php rename to classes/validator/validators/Validator56.php index 21c389f6..654bd778 100644 --- a/classes/validator/validators/BAV_Validator_56.php +++ b/classes/validator/validators/Validator56.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 11 - ($this->accumulator % 11); - if ($this->account{0} == 9 && $result >= 10) { + if ($this->account[0] == 9 && $result >= 10) { $result -= 3; - + } return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_57.php b/classes/validator/validators/Validator57.php similarity index 77% rename from classes/validator/validators/BAV_Validator_57.php rename to classes/validator/validators/Validator57.php index 916481a2..6354eb2d 100644 --- a/classes/validator/validators/BAV_Validator_57.php +++ b/classes/validator/validators/Validator57.php @@ -1,9 +1,6 @@ validator09 = new BAV_Validator_09($bank); - - $this->mode1 = new BAV_Validator_00($bank); + + $this->validator09 = new Validator09($bank); + + $this->mode1 = new Validator00($bank); $this->mode1->setWeights(array(1, 2)); $this->mode1->setStart(0); $this->mode1->setEnd(-2); - - - $this->mode2 = new BAV_Validator_00($bank); + + + $this->mode2 = new Validator00($bank); $this->mode2->setWeights(array(1, 2, 0, 1, 2, 1, 2, 1, 2, 1)); $this->mode2->setChecknumberPosition(2); $this->mode2->setStart(0); $this->mode2->setEnd(-1); - - + + $this->modeMap = array( 51 => 1, 55 => 1, @@ -80,11 +78,10 @@ public function __construct(BAV_Bank $bank) { 65 => 1, 66 => 1, 70 => 1, - 73 => 1, 88 => 1, 94 => 1, 95 => 1, - + 52 => 2, 53 => 2, 54 => 2, @@ -95,7 +92,6 @@ public function __construct(BAV_Bank $bank) { 69 => 2, 71 => 2, 72 => 2, - 74 => 2, 89 => 2, 90 => 2, 92 => 2, @@ -103,92 +99,91 @@ public function __construct(BAV_Bank $bank) { 96 => 2, 97 => 2, 98 => 2, - + 40 => 3, 50 => 3, 91 => 3, 99 => 3 ); } - - - protected function validate() { + + protected function validate() + { $this->validator = null; switch ($this->getMode()) { - case 0: + case 0: $this->validator = null; break; - + case 1: switch (substr($this->account, 0, 6)) { - case 777777: case 888888: + case 777777: + case 888888: $this->validator = $this->validator09; break; - + default: $this->validator = $this->mode1; break; - + } break; - + case 2: $this->validator = $this->mode2; break; - + case 3: $this->validator = $this->validator09; break; - + case 4: $pos34 = substr($this->account, 2, 2); $pos79 = substr($this->account, 6, 3); $this->validator = $this->account === '0185125434' || ($pos34 >= 1 && $pos34 <= 12 && $pos79 <= 500) ? $this->validator09 : null; - break; + break; } } - protected function getResult() { + + protected function getResult() + { return ! is_null($this->validator) && $this->validator->isValid($this->account); } - + /** * @return int */ - private function getMode() { + private function getMode() + { $firstTwo = substr($this->account, 0, 2); - + if ($firstTwo == '00') { return 0; - + } - + if (isset($this->modeMap[$firstTwo])) { return $this->modeMap[$firstTwo]; - + } - if ($firstTwo >= 75 && $firstTwo <= 82) { + if ($firstTwo >= 73 && $firstTwo <= 82) { return 1; - + } elseif (($firstTwo >= 32 && $firstTwo <= 39) || ($firstTwo >= 41 && $firstTwo <= 49) || ($firstTwo >= 56 && $firstTwo <= 60) || ($firstTwo >= 83 && $firstTwo <= 87)) { return 2; - + } elseif ($firstTwo >= 1 && $firstTwo <= 31) { return 4; - + } else { - throw new LogicException(); - + throw new \LogicException(); + } } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_58.php b/classes/validator/validators/Validator58.php similarity index 80% rename from classes/validator/validators/BAV_Validator_58.php rename to classes/validator/validators/Validator58.php index 74566337..dfb0358d 100644 --- a/classes/validator/validators/BAV_Validator_58.php +++ b/classes/validator/validators/Validator58.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 0, 0, 0, 0)); $this->setEnd(4); } - - - public function isValid($account) { - return strlen($account) >= 6 && parent::isValid($account); - } - + public function isValid($account) + { + return strlen(ltrim($account, "0")) >= 6 && parent::isValid($account); + } } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_59.php b/classes/validator/validators/Validator59.php similarity index 64% rename from classes/validator/validators/BAV_Validator_59.php rename to classes/validator/validators/Validator59.php index 84d0b3f9..92832ee3 100644 --- a/classes/validator/validators/BAV_Validator_59.php +++ b/classes/validator/validators/Validator59.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } - - public function isValid($account) { - return ltrim($account, "0") != "" - && strlen($account) < 9 - || parent::isValid($account); + protected function getResult() + { + /* + * Es ist jedoch zu beachten, dass Kontonummern, die + * kleiner als 9-stellig sind,[…] als richtig behandelt werden. + */ + $trimedAccount = ltrim($this->account, "0"); + if (strlen($trimedAccount) < 9) { + return ! empty($trimedAccount) && true; + + } + return parent::getResult(); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_60.php b/classes/validator/validators/Validator60.php similarity index 89% rename from classes/validator/validators/BAV_Validator_60.php rename to classes/validator/validators/Validator60.php index c77126cc..3e5ff98f 100644 --- a/classes/validator/validators/BAV_Validator_60.php +++ b/classes/validator/validators/Validator60.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setEnd(2); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_61.php b/classes/validator/validators/Validator61.php similarity index 81% rename from classes/validator/validators/BAV_Validator_61.php rename to classes/validator/validators/Validator61.php index 0636720d..c9f4322f 100644 --- a/classes/validator/validators/BAV_Validator_61.php +++ b/classes/validator/validators/Validator61.php @@ -1,7 +1,6 @@ setChecknumberPosition(-3); $this->setStart(0); } - - public function init($account) { + public function init($account) + { parent::init($account); - - - if ($this->account{8} == 8) { + + + if ($this->account[8] == 8) { $this->setWeights(array(2, 1, 2, 1, 2, 1, 2, 0, 1, 2)); $this->setEnd(-1); - + } else { $this->setWeights(array(2, 1)); $this->setEnd(-4); - + } } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_62.php b/classes/validator/validators/Validator62.php similarity index 84% rename from classes/validator/validators/BAV_Validator_62.php rename to classes/validator/validators/Validator62.php index b7b3495f..1af87776 100644 --- a/classes/validator/validators/BAV_Validator_62.php +++ b/classes/validator/validators/Validator62.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setChecknumberPosition(-3); $this->setStart(-4); $this->setEnd(2); } - - - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_63.php b/classes/validator/validators/Validator63.php similarity index 80% rename from classes/validator/validators/BAV_Validator_63.php rename to classes/validator/validators/Validator63.php index 76f8998c..c916b9ab 100644 --- a/classes/validator/validators/BAV_Validator_63.php +++ b/classes/validator/validators/Validator63.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setChecknumberPosition(7); $this->setStart(6); $this->setEnd(1); } - - public function isValid($account) { + public function isValid($account) + { if (parent::isValid($account)) { return true; - + } if (substr($this->account, 0, 3) !== '000') { return false; - + } return parent::isValid(ltrim($account.'00', '0')); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; - return $this->account{0} == '0' && (string)$result === $this->getCheckNumber(); + return $this->account[0] == '0' && (string)$result === $this->getCheckNumber(); } - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_64.php b/classes/validator/validators/Validator64.php similarity index 89% rename from classes/validator/validators/BAV_Validator_64.php rename to classes/validator/validators/Validator64.php index 60313510..22616dfc 100644 --- a/classes/validator/validators/BAV_Validator_64.php +++ b/classes/validator/validators/Validator64.php @@ -1,7 +1,6 @@ setWeights(array(9, 10, 5, 8, 4, 2)); @@ -35,9 +33,4 @@ public function __construct(BAV_Bank $bank) { $this->setEnd(5); $this->setChecknumberPosition(6); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_65.php b/classes/validator/validators/Validator65.php similarity index 83% rename from classes/validator/validators/BAV_Validator_65.php rename to classes/validator/validators/Validator65.php index 5761e5a9..8080e97a 100644 --- a/classes/validator/validators/BAV_Validator_65.php +++ b/classes/validator/validators/Validator65.php @@ -1,7 +1,6 @@ setWeights(array(2, 1, 2, 1, 2, 1, 2, 0, 1, 2)); $this->setStart(0); $this->setChecknumberPosition(7); } - - - protected function init($account) { + + protected function init($account) + { parent::init($account); - - if ($this->account{8} == 9) { + + if ($this->account[8] == 9) { $this->setEnd(-1); - + } else { $this->setEnd(6); - + } } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_66.php b/classes/validator/validators/Validator66.php similarity index 74% rename from classes/validator/validators/BAV_Validator_66.php rename to classes/validator/validators/Validator66.php index 2f1581d5..91054bf9 100644 --- a/classes/validator/validators/BAV_Validator_66.php +++ b/classes/validator/validators/Validator66.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 0, 0, 7)); $this->setStart(-2); $this->setEnd(1); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } + protected function getResult() + { + // update 2014-03-03 + if ($this->account[1] == '9') { + return true; - protected function getResult() { + } $result = (11 - $this->accumulator % 11) % 10; - return $this->account{0} == '0' && (string)$result === $this->getCheckNumber(); + return $this->account[0] == '0' && (string)$result === $this->getCheckNumber(); } - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_67.php b/classes/validator/validators/Validator67.php similarity index 89% rename from classes/validator/validators/BAV_Validator_67.php rename to classes/validator/validators/Validator67.php index 2fef1ec9..4c521483 100644 --- a/classes/validator/validators/BAV_Validator_67.php +++ b/classes/validator/validators/Validator67.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setStart(-4); $this->setChecknumberPosition(-3); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/Validator68.php b/classes/validator/validators/Validator68.php new file mode 100644 index 00000000..792f721b --- /dev/null +++ b/classes/validator/validators/Validator68.php @@ -0,0 +1,82 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @package classes + * @subpackage validator + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch + */ +class Validator68 extends ValidatorChain +{ + + /** + * @var Validator10 + */ + private $validator10; + + public function __construct(Bank $bank) + { + parent::__construct($bank); + + $this->validator10 = new Validator00($bank); + $this->validator10->setEnd(3); + + $this->validators[] = new Validator00($bank); + + $this->validators[] = new Validator00($bank); + $this->validators[1]->setWeights(array(2, 1, 2, 1, 2, 0, 0, 1)); + } + + protected function init($account) + { + parent::init($account); + + // Die Kontonummern [..] enthalten keine führenden Nullen. + $this->account = ltrim($this->account, "0"); + } + + protected function getResult() + { + switch (strlen($this->account)) { + case 10: + return $this->account[3] == 9 && $this->validator10->isValid($this->account); + + case 9: + if ($this->account >= 400000000 && $this->account <= 499999999) { + return false; + + } + return parent::getResult(); + + case 6: + case 7: + case 8: + return parent::getResult(); + + default: + return false; + + } + } +} diff --git a/classes/validator/validators/BAV_Validator_69.php b/classes/validator/validators/Validator69.php similarity index 77% rename from classes/validator/validators/BAV_Validator_69.php rename to classes/validator/validators/Validator69.php index d7b2fc54..b1a17c46 100644 --- a/classes/validator/validators/BAV_Validator_69.php +++ b/classes/validator/validators/Validator69.php @@ -1,9 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_69 extends BAV_Validator_Chain { +class Validator69 extends ValidatorChain +{ - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->validators[] = new BAV_Validator_28($bank); + + $this->validators[] = new Validator28($bank); $this->validators[0]->setWeights(array(2, 3, 4, 5, 6, 7, 8)); - - $this->validators[] = new BAV_Validator_69b($bank); + + $this->validators[] = new Validator69b($bank); } - - - public function isValid($account) { + + public function isValid($account) + { return ($account >= 9300000000 && $account <= 9399999999) || parent::isValid($account); } - - + /** * @return bool */ - protected function useValidator(BAV_Validator $validator) { + protected function useValidator(Validator $validator) + { if ($validator === $this->validators[0] && ($this->account >= 9700000000 && $this->account <= 9799999999)) { return false; - + } return true; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_69b.php b/classes/validator/validators/Validator69b.php similarity index 87% rename from classes/validator/validators/BAV_Validator_69b.php rename to classes/validator/validators/Validator69b.php index c30cdae9..f96d20be 100644 --- a/classes/validator/validators/BAV_Validator_69b.php +++ b/classes/validator/validators/Validator69b.php @@ -1,7 +1,6 @@ setMatrix(array( array(0,1,5,9,3,7,4,8,2,6), array(0,1,7,6,9,8,3,2,5,4), @@ -37,14 +35,13 @@ public function __construct(BAV_Bank $bank) { array(0,1,2,3,4,5,6,7,8,9) )); } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { $result = (10 - ($this->accumulator % 10)) % 10; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_70.php b/classes/validator/validators/Validator70.php similarity index 81% rename from classes/validator/validators/BAV_Validator_70.php rename to classes/validator/validators/Validator70.php index 067175a4..412ab28e 100644 --- a/classes/validator/validators/BAV_Validator_70.php +++ b/classes/validator/validators/Validator70.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); } - - protected function iterationStep() { - if ($this->position <= 2 && ($this->account{3} == 5 || substr($this->account, 3, 2) == 69)) { + protected function iterationStep() + { + if ($this->position <= 2 && ($this->account[3] == 5 || substr($this->account, 3, 2) == 69)) { return; - + } parent::iterationStep(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_71.php b/classes/validator/validators/Validator71.php similarity index 85% rename from classes/validator/validators/BAV_Validator_71.php rename to classes/validator/validators/Validator71.php index c1f21b9f..d24a15ba 100644 --- a/classes/validator/validators/BAV_Validator_71.php +++ b/classes/validator/validators/Validator71.php @@ -1,7 +1,6 @@ setWeights(array(6, 5, 4, 3, 2, 1)); $this->setStart(1); $this->setEnd(6); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 11 - ($this->accumulator % 11); $result = $result >= 10 ? 11 - $result : $result; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_72.php b/classes/validator/validators/Validator72.php similarity index 89% rename from classes/validator/validators/BAV_Validator_72.php rename to classes/validator/validators/Validator72.php index 06df5ddb..144d82b2 100644 --- a/classes/validator/validators/BAV_Validator_72.php +++ b/classes/validator/validators/Validator72.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setEnd(3); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_73.php b/classes/validator/validators/Validator73.php similarity index 70% rename from classes/validator/validators/BAV_Validator_73.php rename to classes/validator/validators/Validator73.php index 11850cb6..e0306b31 100644 --- a/classes/validator/validators/BAV_Validator_73.php +++ b/classes/validator/validators/Validator73.php @@ -1,9 +1,6 @@ defaultValidators[] = new BAV_Validator_00($bank); + $this->defaultValidators[] = new Validator00($bank); $this->defaultValidators[0]->setEnd(3); - - $this->defaultValidators[] = new BAV_Validator_00($bank); + + $this->defaultValidators[] = new Validator00($bank); $this->defaultValidators[1]->setWeights(array(2, 1)); $this->defaultValidators[1]->setEnd(4); - - $this->defaultValidators[] = new BAV_Validator_00($bank); + + $this->defaultValidators[] = new Validator00($bank); $this->defaultValidators[2]->setWeights(array(2, 1)); $this->defaultValidators[2]->setDivisor(7); $this->defaultValidators[2]->setEnd(4); - - $this->exceptionValidators = BAV_Validator_51::getExceptionValidators($bank); + + $this->exceptionValidators = Validator51::getExceptionValidators($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - if ($this->account{2} == 9) { + + if ($this->account[2] == 9) { $this->validators = $this->exceptionValidators; - + } else { $this->validators = $this->defaultValidators; - + } } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_74.php b/classes/validator/validators/Validator74.php similarity index 74% rename from classes/validator/validators/BAV_Validator_74.php rename to classes/validator/validators/Validator74.php index edf6abc8..2006d399 100644 --- a/classes/validator/validators/BAV_Validator_74.php +++ b/classes/validator/validators/Validator74.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } - - - public function isValid($account) { + + public function isValid($account) + { return strlen($account) >= 2 && parent::isValid($account); } - - - protected function getResult() { + + protected function getResult() + { if (parent::getResult()) { return true; - + } elseif (strlen(ltrim($this->account, '0')) == 6) { - $nextDecade = (int) ($this->accumulator/10) + 1; - $nextHalfDecade = $nextDecade*10 - 5; - $check = $nextHalfDecade - $this->accumulator; + $nextHalfDecade = round($this->accumulator/10) * 10 + 5; + $check = ($nextHalfDecade - $this->accumulator) % 10; return (string) $check === $this->getChecknumber(); - + } else { return false; - + } } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_75.php b/classes/validator/validators/Validator75.php similarity index 85% rename from classes/validator/validators/BAV_Validator_75.php rename to classes/validator/validators/Validator75.php index 2cb9967a..fa279722 100644 --- a/classes/validator/validators/BAV_Validator_75.php +++ b/classes/validator/validators/Validator75.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); @@ -35,29 +33,27 @@ public function __construct(BAV_Bank $bank) { $this->setEnd(-2); } - - public function isValid($account) { + public function isValid($account) + { + $this->checkType($account); + $account = ltrim($account, '0'); $length = strlen($account); - + if ($length < 6 || $length > 9) { return false; - + } if ($length == 9) { - if ($account{0} == 9) { + if ($account[0] == 9) { $account = substr($account, 1, 6); - + } else { $account = substr($account, 0, 6); - + } - + } return parent::isValid($account); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_76.php b/classes/validator/validators/Validator76.php similarity index 77% rename from classes/validator/validators/BAV_Validator_76.php rename to classes/validator/validators/Validator76.php index 6402ea36..f4d68012 100644 --- a/classes/validator/validators/BAV_Validator_76.php +++ b/classes/validator/validators/Validator76.php @@ -1,7 +1,6 @@ setChecknumberPosition(-3); $this->setStart(-4); $this->setEnd(1); } - - - public function isValid($account) { - if (parent::isValid($account)) { + + public function isValid($account) + { + if (parent::isValid($account)) { return true; - + } $account = ltrim($account, '0') . '00'; return strlen($account) <= $this->normalizedSize && parent::isValid($account); } - - - protected function getWeight() { + + protected function getWeight() + { return $this->i + 2; } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % 11; - return array_search((int)$this->account{0}, array(0, 4, 6, 7, 8, 9)) !== false + return array_search((int)$this->account[0], array(0, 4, 6, 7, 8, 9)) !== false && $result != 10 && (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_77.php b/classes/validator/validators/Validator77.php similarity index 80% rename from classes/validator/validators/BAV_Validator_77.php rename to classes/validator/validators/Validator77.php index a306c76c..bf7d5c0f 100644 --- a/classes/validator/validators/BAV_Validator_77.php +++ b/classes/validator/validators/Validator77.php @@ -1,8 +1,6 @@ validators[] = new BAV_Validator_77a($bank); + $this->validators[] = new Validator77a($bank); $this->validators[0]->setWeights(array(1, 2, 3, 4, 5)); - - $this->validators[] = new BAV_Validator_77a($bank); + + $this->validators[] = new Validator77a($bank); $this->validators[1]->setWeights(array(5, 4, 3, 4, 5)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_77a.php b/classes/validator/validators/Validator77a.php similarity index 83% rename from classes/validator/validators/BAV_Validator_77a.php rename to classes/validator/validators/Validator77a.php index 4b26b685..1c6ece05 100644 --- a/classes/validator/validators/BAV_Validator_77a.php +++ b/classes/validator/validators/Validator77a.php @@ -1,7 +1,6 @@ setStart(-1); $this->setEnd(5); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % 11; return $result === 0; } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_78.php b/classes/validator/validators/Validator78.php similarity index 70% rename from classes/validator/validators/BAV_Validator_78.php rename to classes/validator/validators/Validator78.php index f584be98..a1ff47ee 100644 --- a/classes/validator/validators/BAV_Validator_78.php +++ b/classes/validator/validators/Validator78.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); } - - - public function isValid($account) { - return strlen($account) !== 8 && parent::isValid($account); - } + public function isValid($account) + { + // 8-stellige Kontonummern sind nicht prüfbar + $trimedAccount = ltrim($account, "0"); + if (strlen($trimedAccount) === 8) { + return true; + } + return parent::isValid($account); + } } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_79.php b/classes/validator/validators/Validator79.php similarity index 64% rename from classes/validator/validators/BAV_Validator_79.php rename to classes/validator/validators/Validator79.php index e53b0531..3b03ba0c 100644 --- a/classes/validator/validators/BAV_Validator_79.php +++ b/classes/validator/validators/Validator79.php @@ -1,8 +1,6 @@ @@ -21,65 +19,66 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_79 extends BAV_Validator { - +class Validator79 extends Validator +{ - private /** - * @var BAV_Validator_00 + * @var Validator00 */ - $validator, + private $validator; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $mode1, + private $mode1; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $mode2; - + private $mode2; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_00($bank); - $this->mode2 = new BAV_Validator_00($bank); + + $this->mode1 = new Validator00($bank); + $this->mode2 = new Validator00($bank); $this->mode2->setStart(-3); $this->mode2->setChecknumberPosition(-2); } - - protected function init($account) { + + protected function init($account) + { parent::init($account); - + $this->validator = null; } - protected function validate() { - if (array_search($this->account{0}, array(1, 2, 9)) !== false) { + + protected function validate() + { + if (array_search($this->account[0], array(1, 2, 9)) !== false) { $this->validator = $this->mode2; - - } elseif ($this->account{0} == 0) { + + } elseif ($this->account[0] == 0) { $this->validator = null; - + } else { $this->validator = $this->mode1; - + } } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return ! is_null($this->validator) && $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_80.php b/classes/validator/validators/Validator80.php similarity index 69% rename from classes/validator/validators/BAV_Validator_80.php rename to classes/validator/validators/Validator80.php index d96fea00..16f4e7be 100644 --- a/classes/validator/validators/BAV_Validator_80.php +++ b/classes/validator/validators/Validator80.php @@ -1,9 +1,6 @@ defaultValidators[] = new BAV_Validator_00($bank); + $this->defaultValidators[] = new Validator00($bank); $this->defaultValidators[0]->setEnd(4); - - $this->defaultValidators[] = new BAV_Validator_00($bank); + + $this->defaultValidators[] = new Validator00($bank); $this->defaultValidators[1]->setEnd(4); $this->defaultValidators[1]->setDivisor(7); - - $this->exceptionValidators = BAV_Validator_51::getExceptionValidators($bank); + + $this->exceptionValidators = Validator51::getExceptionValidators($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? $this->exceptionValidators : $this->defaultValidators; } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_81.php b/classes/validator/validators/Validator81.php similarity index 71% rename from classes/validator/validators/BAV_Validator_81.php rename to classes/validator/validators/Validator81.php index 72c7321f..3e8663a3 100644 --- a/classes/validator/validators/BAV_Validator_81.php +++ b/classes/validator/validators/Validator81.php @@ -1,9 +1,6 @@ defaultValidators[] = new BAV_Validator_32($bank); + $this->defaultValidators[] = new Validator32($bank); $this->defaultValidators[0]->setWeights(array(2, 3, 4, 5, 6, 7)); - - $this->exceptionValidators = BAV_Validator_51::getExceptionValidators($bank); + + $this->exceptionValidators = Validator51::getExceptionValidators($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? $this->exceptionValidators : $this->defaultValidators; } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_82.php b/classes/validator/validators/Validator82.php similarity index 70% rename from classes/validator/validators/BAV_Validator_82.php rename to classes/validator/validators/Validator82.php index e95f1703..9208ebfc 100644 --- a/classes/validator/validators/BAV_Validator_82.php +++ b/classes/validator/validators/Validator82.php @@ -1,9 +1,6 @@ @@ -26,48 +23,49 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_82 extends BAV_Validator { +class Validator82 extends Validator +{ - - private /** - * @var BAV_Validator + * @var Validator */ - $validator, + private $validator; + /** - * @var BAV_Validator_33 + * @var Validator33 */ - $mode1, + private $mode1; + /** - * @var BAV_Validator_10 + * @var Validator10 */ - $mode2; - + private $mode2; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_33($bank); + + $this->mode1 = new Validator33($bank); $this->mode1->setWeights(array(2, 3, 4, 5, 6)); - - $this->mode2 = new BAV_Validator_10($bank); + + $this->mode2 = new Validator10($bank); } - protected function validate() { - $this->validator = substr($this->account, 2 ,2) == 99 + + protected function validate() + { + $this->validator = substr($this->account, 2, 2) == 99 ? $this->mode2 : $this->mode1; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_83.php b/classes/validator/validators/Validator83.php similarity index 69% rename from classes/validator/validators/BAV_Validator_83.php rename to classes/validator/validators/Validator83.php index db8918a6..c76b3876 100644 --- a/classes/validator/validators/BAV_Validator_83.php +++ b/classes/validator/validators/Validator83.php @@ -1,10 +1,6 @@ defaultValidators[] = new BAV_Validator_32($bank); + $this->defaultValidators[] = new Validator32($bank); $this->defaultValidators[0]->setWeights(array(2, 3, 4, 5, 6, 7)); $this->defaultValidators[0]->setEnd(3); - - $this->defaultValidators[] = new BAV_Validator_33($bank); + + $this->defaultValidators[] = new Validator33($bank); $this->defaultValidators[1]->setWeights(array(2, 3, 4, 5, 6)); $this->defaultValidators[1]->setEnd(4); - - $this->modeC = new BAV_Validator_33($bank); + + $this->modeC = new Validator33($bank); $this->defaultValidators[] = $this->modeC; $this->defaultValidators[2]->setWeights(array(2, 3, 4, 5, 6)); $this->defaultValidators[2]->setEnd(4); $this->defaultValidators[2]->setDivisor(7); - - $this->exceptionValidators[] = new BAV_Validator_83x($bank); + + $this->exceptionValidators[] = new Validator83x($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - + $this->validators = substr($this->account, 2, 2) == 99 ? $this->exceptionValidators : $this->defaultValidators; } - - protected function continueValidation(BAV_Validator $validator) { - return $validator !== $this->modeC || $this->account{9} < 7; - } - + protected function continueValidation(Validator $validator) + { + return $validator !== $this->modeC || $this->account[9] < 7; + } } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_83x.php b/classes/validator/validators/Validator83x.php similarity index 84% rename from classes/validator/validators/BAV_Validator_83x.php rename to classes/validator/validators/Validator83x.php index beed64c3..cab83d97 100644 --- a/classes/validator/validators/BAV_Validator_83x.php +++ b/classes/validator/validators/Validator83x.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8)); $this->setEnd(2); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 11 - ($this->accumulator % 11); $result = $result >= 10 ? 0 : $result; return substr($this->account, 2, 2) == 99 && (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_84.php b/classes/validator/validators/Validator84.php similarity index 61% rename from classes/validator/validators/BAV_Validator_84.php rename to classes/validator/validators/Validator84.php index 99f00cc6..f69c0c9e 100644 --- a/classes/validator/validators/BAV_Validator_84.php +++ b/classes/validator/validators/Validator84.php @@ -1,10 +1,6 @@ defaultValidators[] = new BAV_Validator_33($bank); + $this->defaultValidators[0] = new Validator33($bank); $this->defaultValidators[0]->setWeights(array(2, 3, 4, 5, 6)); $this->defaultValidators[0]->setEnd(4); - - $this->defaultValidators[] = new BAV_Validator_84b($bank); - - $this->exceptionValidators = BAV_Validator_51::getExceptionValidators($bank); + + $this->defaultValidators[1] = new Validator84b($bank); + + // Bundesbank update 2013-06-03 + $this->defaultValidators[2] = new Validator06($bank); + $this->defaultValidators[2]->setWeights(array(2, 1)); + $this->defaultValidators[2]->setEnd(4); + $this->defaultValidators[2]->setDivisor(10); + + $this->exceptionValidators = Validator51::getExceptionValidators($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? $this->exceptionValidators : $this->defaultValidators; } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_84b.php b/classes/validator/validators/Validator84b.php similarity index 84% rename from classes/validator/validators/BAV_Validator_84b.php rename to classes/validator/validators/Validator84b.php index 80ef78d5..f83b3afa 100644 --- a/classes/validator/validators/BAV_Validator_84b.php +++ b/classes/validator/validators/Validator84b.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6)); $this->setEnd(4); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 7 - ($this->accumulator % 7); $result = $result == 7 ? 0 : $result; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_85.php b/classes/validator/validators/Validator85.php similarity index 71% rename from classes/validator/validators/BAV_Validator_85.php rename to classes/validator/validators/Validator85.php index 15ac3c97..42f89a0a 100644 --- a/classes/validator/validators/BAV_Validator_85.php +++ b/classes/validator/validators/Validator85.php @@ -1,10 +1,6 @@ defaultValidators[] = new BAV_Validator_06($bank); + $this->defaultValidators[] = new Validator06($bank); $this->defaultValidators[0]->setWeights(array(2, 3, 4, 5, 6, 7)); $this->defaultValidators[0]->setEnd(3); - - $this->defaultValidators[] = new BAV_Validator_33($bank); + + $this->defaultValidators[] = new Validator33($bank); $this->defaultValidators[1]->setWeights(array(2, 3, 4, 5, 6)); $this->defaultValidators[1]->setEnd(4); - - $this->modeC = new BAV_Validator_33($bank); + + $this->modeC = new Validator33($bank); $this->defaultValidators[] = $this->modeC; $this->defaultValidators[2]->setWeights(array(2, 3, 4, 5, 6)); $this->defaultValidators[2]->setEnd(4); $this->defaultValidators[2]->setDivisor(7); - - $this->exceptionValidators[] = new BAV_Validator_02($bank); + + $this->exceptionValidators[] = new Validator02($bank); $this->exceptionValidators[0]->setWeights(array(2, 3, 4, 5, 6, 7, 8)); $this->exceptionValidators[0]->setEnd(2); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - + $this->validators = substr($this->account, 2, 2) == 99 ? $this->exceptionValidators : $this->defaultValidators; } - - protected function continueValidation(BAV_Validator $validator) { - return $validator !== $this->modeC || $this->account{9} < 7; - } - + protected function continueValidation(Validator $validator) + { + return $validator !== $this->modeC || $this->account[9] < 7; + } } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_86.php b/classes/validator/validators/Validator86.php similarity index 71% rename from classes/validator/validators/BAV_Validator_86.php rename to classes/validator/validators/Validator86.php index 3ff7440c..a6ef0286 100644 --- a/classes/validator/validators/BAV_Validator_86.php +++ b/classes/validator/validators/Validator86.php @@ -1,10 +1,6 @@ defaultValidators[] = new BAV_Validator_00($bank); + $this->defaultValidators[] = new Validator00($bank); $this->defaultValidators[0]->setWeights(array(2, 1)); $this->defaultValidators[0]->setEnd(3); - - $this->defaultValidators[] = new BAV_Validator_32($bank); + + $this->defaultValidators[] = new Validator32($bank); $this->defaultValidators[1]->setWeights(array(2, 3, 4, 5, 6, 7)); $this->defaultValidators[1]->setEnd(3); - - $this->exceptionValidators = BAV_Validator_51::getExceptionValidators($bank); + + $this->exceptionValidators = Validator51::getExceptionValidators($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? $this->exceptionValidators : $this->defaultValidators; } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_87.php b/classes/validator/validators/Validator87.php similarity index 63% rename from classes/validator/validators/BAV_Validator_87.php rename to classes/validator/validators/Validator87.php index 2d6020d0..3cbd8a0f 100644 --- a/classes/validator/validators/BAV_Validator_87.php +++ b/classes/validator/validators/Validator87.php @@ -1,11 +1,6 @@ defaultValidators[] = new BAV_Validator_87a($bank); - - $this->defaultValidators[] = new BAV_Validator_33($bank); + $this->defaultValidators[] = new Validator87a($bank); + + $this->defaultValidators[] = new Validator33($bank); $this->defaultValidators[1]->setWeights(array(2, 3, 4, 5, 6)); $this->defaultValidators[1]->setEnd(4); - - $this->defaultValidators[] = new BAV_Validator_87c($bank); - - $this->exceptionValidators = BAV_Validator_51::getExceptionValidators($bank); + + $this->defaultValidators[] = new Validator87c($bank); + + // Method D + $this->defaultValidators[3] = new Validator06($bank); + $this->defaultValidators[3]->setEnd(3); + + $this->exceptionValidators = Validator51::getExceptionValidators($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? $this->exceptionValidators : $this->defaultValidators; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_87a.php b/classes/validator/validators/Validator87a.php similarity index 84% rename from classes/validator/validators/BAV_Validator_87a.php rename to classes/validator/validators/Validator87a.php index e97ef965..673e160e 100644 --- a/classes/validator/validators/BAV_Validator_87a.php +++ b/classes/validator/validators/Validator87a.php @@ -1,8 +1,6 @@ - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_87a extends BAV_Validator { +class Validator87a extends Validator +{ - - protected function validate() { + protected function validate() + { } + /** - * @return bool - */ - protected function getResult() { + * @return bool + */ + protected function getResult() + { $accountID = $this->account; $i = 0; $c2 = 0; @@ -49,7 +50,7 @@ protected function getResult() { $konto = array(); for ($i = 0; $i < strlen($accountID); $i++) { - $konto[$i+1] = $accountID{$i}; + $konto[$i+1] = $accountID[$i]; } $i = 4; @@ -59,15 +60,19 @@ protected function getResult() { $c2 = $i % 2; - while($i < 10) { + while ($i < 10) { switch ($konto[$i]) { - case 0: $konto[$i] = 5; + case 0: + $konto[$i] = 5; break; - case 1: $konto[$i] = 6; + case 1: + $konto[$i] = 6; break; - case 5: $konto[$i] = 10; + case 5: + $konto[$i] = 10; break; - case 6: $konto[$i] = 1; + case 6: + $konto[$i] = 1; break; } @@ -134,7 +139,6 @@ protected function getResult() { return true; } else { if ($konto[4] == 0) { - if ($p > 4) { $p = $p - 5; } else { @@ -149,9 +153,4 @@ protected function getResult() { return false; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_87c.php b/classes/validator/validators/Validator87c.php similarity index 84% rename from classes/validator/validators/BAV_Validator_87c.php rename to classes/validator/validators/Validator87c.php index 380adafd..7c85bf00 100644 --- a/classes/validator/validators/BAV_Validator_87c.php +++ b/classes/validator/validators/Validator87c.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6)); $this->setEnd(4); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 7 - ($this->accumulator % 7); $result = $result == 7 ? 0 : $result; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_88.php b/classes/validator/validators/Validator88.php similarity index 80% rename from classes/validator/validators/BAV_Validator_88.php rename to classes/validator/validators/Validator88.php index e2dc5eae..180bd38a 100644 --- a/classes/validator/validators/BAV_Validator_88.php +++ b/classes/validator/validators/Validator88.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 8)); - - } - - - protected function init($account) { - parent::init($account); - - $this->setEnd($this->account{2} == 9 ? 2: 3); + } + protected function init($account) + { + parent::init($account); + $this->setEnd($this->account[2] == 9 ? 2: 3); + } } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_89.php b/classes/validator/validators/Validator89.php similarity index 78% rename from classes/validator/validators/BAV_Validator_89.php rename to classes/validator/validators/Validator89.php index ede6465f..45654c8e 100644 --- a/classes/validator/validators/BAV_Validator_89.php +++ b/classes/validator/validators/Validator89.php @@ -1,8 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); $this->setEnd(3); - - $this->validator10 = new BAV_Validator_10($bank); + + $this->validator10 = new Validator10($bank); } - - - protected function iterationStep() { + + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - - public function isValid($account) { + + public function isValid($account) + { $length = strlen(ltrim($account, '0')); return (($length == 8 || $length == 9) && $this->validator10->isValid($account)) || ($length == 7 && parent::isValid($account)); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_90.php b/classes/validator/validators/Validator90.php similarity index 54% rename from classes/validator/validators/BAV_Validator_90.php rename to classes/validator/validators/Validator90.php index 5f674903..e10c46b4 100644 --- a/classes/validator/validators/BAV_Validator_90.php +++ b/classes/validator/validators/Validator90.php @@ -1,11 +1,6 @@ defaultValidators[] = new BAV_Validator_06($bank); - $this->defaultValidators[0]->setWeights(array(2, 3, 4, 5, 6, 7)); - $this->defaultValidators[0]->setEnd(3); - - $this->defaultValidators[] = new BAV_Validator_06($bank); - $this->defaultValidators[1]->setWeights(array(2, 3, 4, 5, 6)); - $this->defaultValidators[1]->setEnd(4); - - $this->defaultValidators[] = new BAV_Validator_90c($bank); - $this->defaultValidators[] = new BAV_Validator_90d($bank); - $this->defaultValidators[] = new BAV_Validator_90e($bank); - - $this->modeF = new BAV_Validator_06($bank); + + $this->defaultValidators["a"] = new Validator06($bank); + $this->defaultValidators["a"]->setWeights(array(2, 3, 4, 5, 6, 7)); + $this->defaultValidators["a"]->setEnd(3); + + $this->defaultValidators["b"] = new Validator06($bank); + $this->defaultValidators["b"]->setWeights(array(2, 3, 4, 5, 6)); + $this->defaultValidators["b"]->setEnd(4); + + $this->defaultValidators["c"] = new Validator90c($bank); + $this->defaultValidators["d"] = new Validator90d($bank); + $this->defaultValidators["e"] = new Validator90e($bank); + $this->defaultValidators["g"] = new Validator90g($bank); + + $this->modeF = new Validator06($bank); $this->modeF->setWeights(array(2, 3, 4, 5, 6, 7, 8)); $this->modeF->setEnd(2); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? array($this->modeF) : $this->defaultValidators; } - - } - - -?> diff --git a/classes/validator/validators/BAV_Validator_90c.php b/classes/validator/validators/Validator90c.php similarity index 80% rename from classes/validator/validators/BAV_Validator_90c.php rename to classes/validator/validators/Validator90c.php index 5406bc77..a9f6f7d3 100644 --- a/classes/validator/validators/BAV_Validator_90c.php +++ b/classes/validator/validators/Validator90c.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6)); $this->setEnd(4); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 7 - $this->accumulator % 7; $result = $result == 7 ? 0 : $result % 10; - return $this->account{9} < 7 && (string)$result === $this->getCheckNumber(); + return $this->account[9] < 7 && (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_90d.php b/classes/validator/validators/Validator90d.php similarity index 80% rename from classes/validator/validators/BAV_Validator_90d.php rename to classes/validator/validators/Validator90d.php index 3728b3f0..f1868eb0 100644 --- a/classes/validator/validators/BAV_Validator_90d.php +++ b/classes/validator/validators/Validator90d.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6)); $this->setEnd(4); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 9 - $this->accumulator % 9; $result = $result == 9 ? 0 : $result % 10; - return $this->account{9} != 9 && (string)$result === $this->getCheckNumber(); + return $this->account[9] != 9 && (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_90e.php b/classes/validator/validators/Validator90e.php similarity index 83% rename from classes/validator/validators/BAV_Validator_90e.php rename to classes/validator/validators/Validator90e.php index 4bd503f6..43e0b6d7 100644 --- a/classes/validator/validators/BAV_Validator_90e.php +++ b/classes/validator/validators/Validator90e.php @@ -1,7 +1,6 @@ setWeights(array(2, 1)); $this->setEnd(4); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = (10 - $this->accumulator % 10) % 10; return (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/Validator90g.php b/classes/validator/validators/Validator90g.php new file mode 100644 index 00000000..c4e3cad8 --- /dev/null +++ b/classes/validator/validators/Validator90g.php @@ -0,0 +1,51 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +class Validator90g extends WeightedIterationValidator +{ + + public function __construct(Bank $bank) + { + parent::__construct($bank); + + $this->setWeights(array(2, 1)); + + /* + * The specification is not clear about 4 or 3. + * see https://github.com/malkusch/bav/issues/14 + */ + $this->setEnd(3); + } + + protected function iterationStep() + { + $this->accumulator += $this->number * $this->getWeight(); + } + + protected function getResult() + { + $rest = $this->accumulator % 7; + $checknumber = $rest == 0 ? 0 : (7 - $rest); + return (string)$checknumber === $this->getCheckNumber(); + } +} diff --git a/classes/validator/validators/BAV_Validator_91.php b/classes/validator/validators/Validator91.php similarity index 87% rename from classes/validator/validators/BAV_Validator_91.php rename to classes/validator/validators/Validator91.php index 1631e40b..3c447af9 100644 --- a/classes/validator/validators/BAV_Validator_91.php +++ b/classes/validator/validators/Validator91.php @@ -1,8 +1,6 @@ validators[] = new BAV_Validator_06($bank); + $this->validators[] = new Validator06($bank); $this->validators[$i]->setChecknumberPosition(6); $this->validators[$i]->setStart(5); } - + $this->validators[0]->setWeights(array(2, 3, 4, 5, 6, 7)); $this->validators[1]->setWeights(array(7, 6, 5, 4, 3, 2)); $this->validators[2]->setWeights(array(2, 3, 4, 0, 5, 6, 7, 8, 9, 10)); $this->validators[3]->setWeights(array(2, 4, 8, 5, 10, 9)); - + $this->validators[2]->setStart(-1); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_92.php b/classes/validator/validators/Validator92.php similarity index 89% rename from classes/validator/validators/BAV_Validator_92.php rename to classes/validator/validators/Validator92.php index a1718531..b65923ae 100644 --- a/classes/validator/validators/BAV_Validator_92.php +++ b/classes/validator/validators/Validator92.php @@ -1,7 +1,6 @@ setWeights(array(3, 7, 1)); $this->setEnd(3); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_93.php b/classes/validator/validators/Validator93.php similarity index 78% rename from classes/validator/validators/BAV_Validator_93.php rename to classes/validator/validators/Validator93.php index 60ed5dcd..21fc719b 100644 --- a/classes/validator/validators/BAV_Validator_93.php +++ b/classes/validator/validators/Validator93.php @@ -1,8 +1,6 @@ validators[] = new BAV_Validator_06($bank); + + $this->validators[] = new Validator06($bank); $this->validators[0]->setWeights(array(2, 3, 4, 5, 6)); $this->validators[0]->setEnd(4); - - $this->validators[] = new BAV_Validator_06($bank); + + $this->validators[] = new Validator06($bank); $this->validators[1]->setWeights(array(2, 3, 4, 5, 6)); $this->validators[1]->setEnd(4); $this->validators[1]->setDivisor(7); } - - + /** - * @throws BAV_ValidatorException_OutOfBounds + * @throws ValidatorOutOfBoundsException * @param int $int */ - protected function normalizeAccount($size) { + protected function normalizeAccount($size) + { parent::normalizeAccount($size); if (substr($this->account, 0, 4) !== '0000') { $this->account = '0000'.substr($this->account, 0, 6); - + } } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_94.php b/classes/validator/validators/Validator94.php similarity index 88% rename from classes/validator/validators/BAV_Validator_94.php rename to classes/validator/validators/Validator94.php index 2b53f275..edf89a5f 100644 --- a/classes/validator/validators/BAV_Validator_94.php +++ b/classes/validator/validators/Validator94.php @@ -1,7 +1,6 @@ setWeights(array(1, 2)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_95.php b/classes/validator/validators/Validator95.php similarity index 80% rename from classes/validator/validators/BAV_Validator_95.php rename to classes/validator/validators/Validator95.php index 9132cac0..132ea195 100644 --- a/classes/validator/validators/BAV_Validator_95.php +++ b/classes/validator/validators/Validator95.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); } - - - public function isValid($account) { + + public function isValid($account) + { return parent::isValid($account) || $this->isBetween(1, 1999999) || $this->isBetween(9000000, 25999999) || $this->isBetween(396000000, 499999999) - || $this->isBetween(700000000, 799999999); + || $this->isBetween(700000000, 799999999) + || $this->isBetween(910000000, 989999999); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_96.php b/classes/validator/validators/Validator96.php similarity index 78% rename from classes/validator/validators/BAV_Validator_96.php rename to classes/validator/validators/Validator96.php index 80dfa1a9..c6ac31a3 100644 --- a/classes/validator/validators/BAV_Validator_96.php +++ b/classes/validator/validators/Validator96.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_19($bank); + + $this->validators[] = new Validator19($bank); $this->validators[0]->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 1)); - - $this->validators[] = new BAV_Validator_00($bank); + + $this->validators[] = new Validator00($bank); $this->validators[1]->setWeights(array(2, 1)); } - - - public function isValid($account) { + + public function isValid($account) + { return parent::isValid($account) || $this->isBetween(1300000, 99399999); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_97.php b/classes/validator/validators/Validator97.php similarity index 84% rename from classes/validator/validators/BAV_Validator_97.php rename to classes/validator/validators/Validator97.php index 90385868..597a03e2 100644 --- a/classes/validator/validators/BAV_Validator_97.php +++ b/classes/validator/validators/Validator97.php @@ -1,7 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_97 extends BAV_Validator { +class Validator97 extends Validator +{ - - private /** * @var int */ - $result = 0; + private $result = 0; - - protected function validate() { + protected function validate() + { $account = (int) ltrim(substr($this->account, 0, -1), '0'); $this->result = $account - (int)($account / 11) * 11; - + } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return strlen(ltrim($this->account, '0')) >= 5 && $this->result === (int) $this->getChecknumber(); } - - - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_98.php b/classes/validator/validators/Validator98.php similarity index 79% rename from classes/validator/validators/BAV_Validator_98.php rename to classes/validator/validators/Validator98.php index ea4e244b..35bb94b8 100644 --- a/classes/validator/validators/BAV_Validator_98.php +++ b/classes/validator/validators/Validator98.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_01($bank); + + $this->validators[] = new Validator01($bank); $this->validators[0]->setWeights(array(3, 1, 7)); $this->validators[0]->setEnd(2); - - $this->validators[] = new BAV_Validator_32($bank); - } - + $this->validators[] = new Validator32($bank); + } } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_99.php b/classes/validator/validators/Validator99.php similarity index 86% rename from classes/validator/validators/BAV_Validator_99.php rename to classes/validator/validators/Validator99.php index c5b6249c..dd287470 100644 --- a/classes/validator/validators/BAV_Validator_99.php +++ b/classes/validator/validators/Validator99.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7)); } - - - public function isValid($account) { + + public function isValid($account) + { return parent::isValid($account) || $this->isBetween(396000000, 499999999); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A0.php b/classes/validator/validators/ValidatorA0.php similarity index 85% rename from classes/validator/validators/BAV_Validator_A0.php rename to classes/validator/validators/ValidatorA0.php index 507de19d..2e118f0a 100644 --- a/classes/validator/validators/BAV_Validator_A0.php +++ b/classes/validator/validators/ValidatorA0.php @@ -1,7 +1,6 @@ setWeights(array(2, 4, 8, 5, 10, 0, 0, 0, 0)); $this->setDivisor(11); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->divisor - $this->accumulator % $this->divisor; $result = $result == $this->divisor ? 0 : $result % 10; return substr($this->account, 0, 7) == '0000000' || (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A1.php b/classes/validator/validators/ValidatorA1.php similarity index 87% rename from classes/validator/validators/BAV_Validator_A1.php rename to classes/validator/validators/ValidatorA1.php index e53370df..03e2443e 100644 --- a/classes/validator/validators/BAV_Validator_A1.php +++ b/classes/validator/validators/ValidatorA1.php @@ -1,7 +1,6 @@ setWeights(array(2, 1, 2, 1, 2, 1, 2, 0, 0)); } - - - protected function getResult() { + + protected function getResult() + { $length = strlen(ltrim($this->account, '0')); return ($length == 8 || $length == 10) && parent::getResult(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A2.php b/classes/validator/validators/ValidatorA2.php similarity index 80% rename from classes/validator/validators/BAV_Validator_A2.php rename to classes/validator/validators/ValidatorA2.php index e606fac0..7e27d39c 100644 --- a/classes/validator/validators/BAV_Validator_A2.php +++ b/classes/validator/validators/ValidatorA2.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_00($bank); + $this->validators[] = new Validator00($bank); $this->validators[0]->setWeights(array(2, 1)); - - $this->validators[] = new BAV_Validator_04($bank); + + $this->validators[] = new Validator04($bank); $this->validators[1]->setWeights(array(2, 3, 4, 5, 6, 7)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A3.php b/classes/validator/validators/ValidatorA3.php similarity index 80% rename from classes/validator/validators/BAV_Validator_A3.php rename to classes/validator/validators/ValidatorA3.php index 5d1dca15..866db5ec 100644 --- a/classes/validator/validators/BAV_Validator_A3.php +++ b/classes/validator/validators/ValidatorA3.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_00($bank); + $this->validators[] = new Validator00($bank); $this->validators[0]->setWeights(array(2, 1)); - - $this->validators[] = new BAV_Validator_10($bank); + + $this->validators[] = new Validator10($bank); $this->validators[1]->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A4.php b/classes/validator/validators/ValidatorA4.php similarity index 75% rename from classes/validator/validators/BAV_Validator_A4.php rename to classes/validator/validators/ValidatorA4.php index e0b525be..1eaa58c3 100644 --- a/classes/validator/validators/BAV_Validator_A4.php +++ b/classes/validator/validators/ValidatorA4.php @@ -1,10 +1,6 @@ validators[] = new BAV_Validator_06($bank); + $this->validators[] = new Validator06($bank); $this->validators[0]->setWeights(array(2, 3, 4, 5, 6, 7, 0, 0, 0)); $this->validators[0]->setEnd(3); - - $this->validators[] = new BAV_Validator_A4b($bank); - - $this->validators[] = new BAV_Validator_06($bank); + + $this->validators[] = new ValidatorA4b($bank); + + $this->validators[] = new Validator06($bank); $this->validators[2]->setWeights(array(2, 3, 4, 5, 6, 0, 0, 0, 0)); $this->validators[2]->setEnd(4); - - $this->validators[] = new BAV_Validator_93($bank); + + $this->validators[] = new Validator93($bank); } - - + /** * Decide if you really want to use this validator * * @return bool */ - protected function useValidator(BAV_Validator $validator) { + protected function useValidator(Validator $validator) + { if (substr($this->account, 2, 2) == '99') { return $validator === $this->validators[2] || $validator === $this->validators[3]; - + } else { return $validator !== $this->validators[2]; - + } } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A4b.php b/classes/validator/validators/ValidatorA4b.php similarity index 84% rename from classes/validator/validators/BAV_Validator_A4b.php rename to classes/validator/validators/ValidatorA4b.php index 97d53759..a96cc620 100644 --- a/classes/validator/validators/BAV_Validator_A4b.php +++ b/classes/validator/validators/ValidatorA4b.php @@ -1,7 +1,6 @@ setWeights(array(2, 3, 4, 5, 6, 7, 0, 0, 0)); $this->setEnd(3); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = 7 - $this->accumulator % 7; $result = $result == 7 ? 0 : $result % 10; return (string)$result === $this->getCheckNumber(); } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A5.php b/classes/validator/validators/ValidatorA5.php similarity index 74% rename from classes/validator/validators/BAV_Validator_A5.php rename to classes/validator/validators/ValidatorA5.php index d19ddfdb..4ee2e283 100644 --- a/classes/validator/validators/BAV_Validator_A5.php +++ b/classes/validator/validators/ValidatorA5.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_00($bank); + $this->validators[] = new Validator00($bank); $this->validators[0]->setWeights(array(2, 1)); - - $this->validators[] = new BAV_Validator_10($bank); + + $this->validators[] = new Validator10($bank); $this->validators[1]->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); } - - - protected function continueValidation(BAV_Validator $validator) { + + protected function continueValidation(Validator $validator) + { if ($validator === $this->validators[1]) { - return $this->account{0} !== '9'; - + return $this->account[0] !== '9'; + } return true; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A6.php b/classes/validator/validators/ValidatorA6.php similarity index 64% rename from classes/validator/validators/BAV_Validator_A6.php rename to classes/validator/validators/ValidatorA6.php index c1a43dde..84787eed 100644 --- a/classes/validator/validators/BAV_Validator_A6.php +++ b/classes/validator/validators/ValidatorA6.php @@ -1,9 +1,6 @@ @@ -22,53 +19,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_A6 extends BAV_Validator { - +class ValidatorA6 extends Validator +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_01 + * @var Validator01 */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_00($bank); + + $this->mode1 = new Validator00($bank); $this->mode1->setWeights(array(2, 1)); - - $this->mode2 = new BAV_Validator_01($bank); + + $this->mode2 = new Validator01($bank); $this->mode2->setWeights(array(3, 7, 1)); } - protected function validate() { - $this->validator = $this->account{1} === '8' + + protected function validate() + { + $this->validator = $this->account[1] === '8' ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A7.php b/classes/validator/validators/ValidatorA7.php similarity index 78% rename from classes/validator/validators/BAV_Validator_A7.php rename to classes/validator/validators/ValidatorA7.php index d8567dae..a0d51614 100644 --- a/classes/validator/validators/BAV_Validator_A7.php +++ b/classes/validator/validators/ValidatorA7.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_00($bank); + $this->validators[] = new Validator00($bank); $this->validators[0]->setWeights(array(2, 1)); - - $this->validators[] = new BAV_Validator_03($bank); - } - + $this->validators[] = new Validator03($bank); + } } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A8.php b/classes/validator/validators/ValidatorA8.php similarity index 66% rename from classes/validator/validators/BAV_Validator_A8.php rename to classes/validator/validators/ValidatorA8.php index 2c3f7fe9..3eb79fa5 100644 --- a/classes/validator/validators/BAV_Validator_A8.php +++ b/classes/validator/validators/ValidatorA8.php @@ -1,10 +1,6 @@ - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_A8 extends BAV_Validator_Chain { - +class ValidatorA8 extends ValidatorChain +{ - private /** * @var array */ - $defaultValidators = array(), + private $defaultValidators = array(); + /** * @var array */ - $exceptionValidators = array(); - - - public function __construct(BAV_Bank $bank) { + private $exceptionValidators = array(); + + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->defaultValidators[] = new BAV_Validator_06($bank); + + $this->defaultValidators[] = new Validator06($bank); $this->defaultValidators[0]->setEnd(3); $this->defaultValidators[0]->setWeights(array(2, 3, 4, 5, 6, 7)); - - $this->defaultValidators[] = new BAV_Validator_00($bank); + + $this->defaultValidators[] = new Validator00($bank); $this->defaultValidators[1]->setEnd(3); $this->defaultValidators[1]->setWeights(array(2, 1)); - - - $this->exceptionValidators = BAV_Validator_51::getExceptionValidators($bank); + + + $this->exceptionValidators = Validator51::getExceptionValidators($bank); } - - + /** */ - protected function init($account) { + protected function init($account) + { parent::init($account); - - $this->validators = $this->account{2} == 9 + + $this->validators = $this->account[2] == 9 ? $this->exceptionValidators : $this->defaultValidators; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_A9.php b/classes/validator/validators/ValidatorA9.php similarity index 80% rename from classes/validator/validators/BAV_Validator_A9.php rename to classes/validator/validators/ValidatorA9.php index f7ae005b..f8a65743 100644 --- a/classes/validator/validators/BAV_Validator_A9.php +++ b/classes/validator/validators/ValidatorA9.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_01($bank); + $this->validators[] = new Validator01($bank); $this->validators[0]->setWeights(array(3, 7, 1)); - - $this->validators[] = new BAV_Validator_06($bank); + + $this->validators[] = new Validator06($bank); $this->validators[1]->setWeights(array(2, 3, 4, 5, 6, 7)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B0.php b/classes/validator/validators/ValidatorB0.php similarity index 63% rename from classes/validator/validators/BAV_Validator_B0.php rename to classes/validator/validators/ValidatorB0.php index 9dda2fde..3681cfd0 100644 --- a/classes/validator/validators/BAV_Validator_B0.php +++ b/classes/validator/validators/ValidatorB0.php @@ -1,9 +1,6 @@ @@ -22,54 +19,54 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_B0 extends BAV_Validator { - +class ValidatorB0 extends Validator +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_09 + * @var Validator09 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_06 + * @var Validator06 */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_09($bank); - - $this->mode2 = new BAV_Validator_06($bank); + + $this->mode1 = new Validator09($bank); + + $this->mode2 = new Validator06($bank); $this->mode2->setWeights(array(2, 3, 4, 5, 6, 7)); } - protected function validate() { - $this->validator = array_search($this->account{7}, array(1, 2, 3, 6)) !== false + + protected function validate() + { + $this->validator = array_search($this->account[7], array(1, 2, 3, 6)) !== false ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return strlen(ltrim($this->account, '0')) === 10 - && $this->account{0} !== '8' + && $this->account[0] !== '8' && $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B1.php b/classes/validator/validators/ValidatorB1.php similarity index 79% rename from classes/validator/validators/BAV_Validator_B1.php rename to classes/validator/validators/ValidatorB1.php index 10ec8cb6..f9d4f053 100644 --- a/classes/validator/validators/BAV_Validator_B1.php +++ b/classes/validator/validators/ValidatorB1.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_05($bank); + $this->validators[] = new Validator05($bank); $this->validators[0]->setWeights(array(7, 3, 1)); - - $this->validators[] = new BAV_Validator_01($bank); + + $this->validators[] = new Validator01($bank); $this->validators[1]->setWeights(array(3, 7, 1)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B2.php b/classes/validator/validators/ValidatorB2.php similarity index 64% rename from classes/validator/validators/BAV_Validator_B2.php rename to classes/validator/validators/ValidatorB2.php index ecabb160..315c532c 100644 --- a/classes/validator/validators/BAV_Validator_B2.php +++ b/classes/validator/validators/ValidatorB2.php @@ -1,9 +1,6 @@ @@ -22,53 +19,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_B2 extends BAV_Validator { - +class ValidatorB2 extends Validator +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_02 + * @var Validator02 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_02($bank); + + $this->mode1 = new Validator02($bank); $this->mode1->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9)); - - $this->mode2 = new BAV_Validator_00($bank); + + $this->mode2 = new Validator00($bank); $this->mode2->setWeights(array(2, 1)); } - protected function validate() { - $this->validator = $this->account{0} <= 7 + + protected function validate() + { + $this->validator = $this->account[0] <= 7 ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B3.php b/classes/validator/validators/ValidatorB3.php similarity index 64% rename from classes/validator/validators/BAV_Validator_B3.php rename to classes/validator/validators/ValidatorB3.php index dd2b988b..7bf5e5d5 100644 --- a/classes/validator/validators/BAV_Validator_B3.php +++ b/classes/validator/validators/ValidatorB3.php @@ -1,9 +1,6 @@ @@ -22,53 +19,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_B3 extends BAV_Validator { +class ValidatorB3 extends Validator +{ - - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_32 + * @var Validator32 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_06 + * @var Validator06 */ - $mode2; - + protected $mode2; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_32($bank); + + $this->mode1 = new Validator32($bank); $this->mode1->setWeights(array(2, 3, 4, 5, 6, 7)); - - $this->mode2 = new BAV_Validator_06($bank); + + $this->mode2 = new Validator06($bank); $this->mode2->setWeights(array(2, 3, 4, 5, 6, 7)); } - protected function validate() { - $this->validator = $this->account{0} != 9 + + protected function validate() + { + $this->validator = $this->account[0] != 9 ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B4.php b/classes/validator/validators/ValidatorB4.php similarity index 64% rename from classes/validator/validators/BAV_Validator_B4.php rename to classes/validator/validators/ValidatorB4.php index 11a4936b..a508173b 100644 --- a/classes/validator/validators/BAV_Validator_B4.php +++ b/classes/validator/validators/ValidatorB4.php @@ -1,9 +1,6 @@ @@ -22,53 +19,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_B4 extends BAV_Validator { - +class ValidatorB4 extends Validator +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_02 + * @var Validator02 */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_00($bank); + + $this->mode1 = new Validator00($bank); $this->mode1->setWeights(array(2, 1)); - - $this->mode2 = new BAV_Validator_02($bank); + + $this->mode2 = new Validator02($bank); $this->mode2->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 10)); } - protected function validate() { - $this->validator = $this->account{0} == 9 + + protected function validate() + { + $this->validator = $this->account[0] == 9 ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B5.php b/classes/validator/validators/ValidatorB5.php similarity index 75% rename from classes/validator/validators/BAV_Validator_B5.php rename to classes/validator/validators/ValidatorB5.php index f60573e1..1f56eca8 100644 --- a/classes/validator/validators/BAV_Validator_B5.php +++ b/classes/validator/validators/ValidatorB5.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_01($bank); + $this->validators[] = new Validator01($bank); $this->validators[0]->setWeights(array(7, 3, 1)); - - $this->validators[] = new BAV_Validator_00($bank); + + $this->validators[] = new Validator00($bank); $this->validators[1]->setWeights(array(2, 1)); } + /** * @return bool */ - protected function continueValidation(BAV_Validator $validator) { + protected function continueValidation(Validator $validator) + { if ($validator === $this->validators[1]) { - return $this->account{0} < 8; - + return $this->account[0] < 8; + } return true; } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B6.php b/classes/validator/validators/ValidatorB6.php similarity index 64% rename from classes/validator/validators/BAV_Validator_B6.php rename to classes/validator/validators/ValidatorB6.php index b09245c5..f4dcbeb5 100644 --- a/classes/validator/validators/BAV_Validator_B6.php +++ b/classes/validator/validators/ValidatorB6.php @@ -1,10 +1,6 @@ @@ -23,56 +19,56 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_B6 extends BAV_Validator implements BAV_Validator_BankDependent { - +class ValidatorB6 extends Validator implements ValidatorBankDependent +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_20 + * @var Validator20 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_53 + * @var Validator53 */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_20($bank); + + $this->mode1 = new Validator20($bank); $this->mode1->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 3)); - - $this->mode2 = new BAV_Validator_53($bank); + + $this->mode2 = new Validator53($bank); $this->mode2->setWeights(array(2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4)); } - protected function validate() { - if ($this->account{0} !== '0' || preg_match("/^0269[1-9]/", $this->account)) { + + protected function validate() + { + if ($this->account[0] !== '0' || preg_match("/^0269[1-9]/", $this->account)) { $this->validator = $this->mode1; } else { $this->validator = $this->mode2; } } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account, '0'); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B7.php b/classes/validator/validators/ValidatorB7.php similarity index 79% rename from classes/validator/validators/BAV_Validator_B7.php rename to classes/validator/validators/ValidatorB7.php index 8bb2a99d..05857463 100644 --- a/classes/validator/validators/BAV_Validator_B7.php +++ b/classes/validator/validators/ValidatorB7.php @@ -1,7 +1,6 @@ setWeights(array(3, 7, 1)); } - - - protected function getResult() { - return ($this->isBetween(1000000, 5999999) || $this->isBetween(700000000, 899999999)) + + protected function getResult() + { + return ($this->isBetween(1000000, 5999999) || $this->isBetween(700000000, 899999999)) ? parent::getResult() : true; } - - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B8.php b/classes/validator/validators/ValidatorB8.php similarity index 67% rename from classes/validator/validators/BAV_Validator_B8.php rename to classes/validator/validators/ValidatorB8.php index 79ecf6ad..5ba9ac28 100644 --- a/classes/validator/validators/BAV_Validator_B8.php +++ b/classes/validator/validators/ValidatorB8.php @@ -1,10 +1,6 @@ validators[] = new BAV_Validator_20($bank); + $this->validators[] = new Validator20($bank); $this->validators[0]->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 3)); - - $this->validators[] = new BAV_Validator_29($bank); - - $this->_validator9 = new BAV_Validator_09($bank); - $this->validators[] = $this->_validator9; + + $this->validators[] = new Validator29($bank); + + $this->validator9 = new Validator09($bank); + $this->validators[] = $this->validator9; } /** - * Limits Validator_09 to the accounts + * Limits Validator09 to the accounts * * @return bool */ - protected function useValidator(BAV_Validator $validator) { - if ($validator !== $this->_validator9) { + protected function useValidator(Validator $validator) + { + if ($validator !== $this->validator9) { return true; } @@ -63,9 +58,4 @@ protected function useValidator(BAV_Validator $validator) { return ($set1 >= 51 && $set1 <= 59) || ($set2 >= 901 && $set2 <= 910); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B9.php b/classes/validator/validators/ValidatorB9.php similarity index 74% rename from classes/validator/validators/BAV_Validator_B9.php rename to classes/validator/validators/ValidatorB9.php index dde0d48a..e5e5b8e1 100644 --- a/classes/validator/validators/BAV_Validator_B9.php +++ b/classes/validator/validators/ValidatorB9.php @@ -1,9 +1,6 @@ @@ -26,55 +23,52 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_B9 extends BAV_Validator { +class ValidatorB9 extends Validator +{ - - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_B9a + * @var ValidatorB9a */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_B9b + * @var ValidatorB9b */ - $mode2; - + protected $mode2; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_B9a($bank); - $this->mode2 = new BAV_Validator_B9b($bank); + + $this->mode1 = new ValidatorB9a($bank); + $this->mode2 = new ValidatorB9b($bank); } - - - protected function validate() { + + protected function validate() + { if (! preg_match('~^000?[^0]~', $this->account)) { $this->validator = null; return; - + } $this->validator = substr($this->account, 0, 3) === '000' ? $this->mode2 : $this->mode1; } - - + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return ! is_null($this->validator) && $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B9a.php b/classes/validator/validators/ValidatorB9a.php similarity index 84% rename from classes/validator/validators/BAV_Validator_B9a.php rename to classes/validator/validators/ValidatorB9a.php index 625d1e77..433fed3d 100644 --- a/classes/validator/validators/BAV_Validator_B9a.php +++ b/classes/validator/validators/ValidatorB9a.php @@ -1,7 +1,6 @@ setWeights(array(1, 3, 2)); $this->setEnd(2); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += ($this->number * $this->getWeight() + $this->getWeight()) % 11; } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % 10; if ((string) $result === $this->getCheckNumber()) { return true; - + } $result += 5; if ($result >= 10) { $result -= 10; - + } return (string) $result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_B9b.php b/classes/validator/validators/ValidatorB9b.php similarity index 84% rename from classes/validator/validators/BAV_Validator_B9b.php rename to classes/validator/validators/ValidatorB9b.php index b756eaf5..ae81cc70 100644 --- a/classes/validator/validators/BAV_Validator_B9b.php +++ b/classes/validator/validators/ValidatorB9b.php @@ -1,7 +1,6 @@ setWeights(array(1, 2, 3, 4, 5, 6)); $this->setEnd(3); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->number * $this->getWeight(); } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % 11; if ((string) $result === $this->getCheckNumber()) { return true; - + } $result += 5; if ($result >= 10) { $result -= 10; - + } return (string) $result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C0.php b/classes/validator/validators/ValidatorC0.php similarity index 76% rename from classes/validator/validators/BAV_Validator_C0.php rename to classes/validator/validators/ValidatorC0.php index 369d73ba..ddfacd7e 100644 --- a/classes/validator/validators/BAV_Validator_C0.php +++ b/classes/validator/validators/ValidatorC0.php @@ -1,10 +1,6 @@ validators[] = new BAV_Validator_52($bank); + $this->validators[] = new Validator52($bank); $this->validators[0]->setWeights(array(2, 4, 8, 5, 10, 9, 7, 3, 6, 1, 2, 4)); - - $this->validators[] = new BAV_Validator_20($bank); + + $this->validators[] = new Validator20($bank); $this->validators[1]->setWeights(array(2, 3, 4, 5, 6, 7, 8, 9, 3)); } - - - public function useValidator(BAV_Validator $validator) { + + public function useValidator(Validator $validator) + { return $validator !== $this->validators[0] || preg_match('~^00[^0]~', $this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C1.php b/classes/validator/validators/ValidatorC1.php similarity index 63% rename from classes/validator/validators/BAV_Validator_C1.php rename to classes/validator/validators/ValidatorC1.php index fc1d1fd7..4855b0a5 100644 --- a/classes/validator/validators/BAV_Validator_C1.php +++ b/classes/validator/validators/ValidatorC1.php @@ -1,9 +1,6 @@ @@ -22,52 +19,52 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_Validator_C1 extends BAV_Validator { - +class ValidatorC1 extends Validator +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_17 + * @var Validator17 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_C1b + * @var ValidatorC1b */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_17($bank); + + $this->mode1 = new Validator17($bank); $this->mode1->setWeights(array(1, 2)); - - $this->mode2 = new BAV_Validator_C1b($bank); + + $this->mode2 = new ValidatorC1b($bank); } - protected function validate() { - $this->validator = $this->account{0} != '5' + + protected function validate() + { + $this->validator = $this->account[0] != '5' ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C1b.php b/classes/validator/validators/ValidatorC1b.php similarity index 84% rename from classes/validator/validators/BAV_Validator_C1b.php rename to classes/validator/validators/ValidatorC1b.php index fdc3c83a..5a99a9d8 100644 --- a/classes/validator/validators/BAV_Validator_C1b.php +++ b/classes/validator/validators/ValidatorC1b.php @@ -1,7 +1,6 @@ setWeights(array(1, 2)); $this->setStart(0); $this->setEnd(-2); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - protected function getResult() { + protected function getResult() + { $result = (10 - (($this->accumulator - 1) % 11)) % 10; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C2.php b/classes/validator/validators/ValidatorC2.php similarity index 79% rename from classes/validator/validators/BAV_Validator_C2.php rename to classes/validator/validators/ValidatorC2.php index bd70ce85..b79b50c6 100644 --- a/classes/validator/validators/BAV_Validator_C2.php +++ b/classes/validator/validators/ValidatorC2.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_22($bank); + $this->validators[] = new Validator22($bank); $this->validators[0]->setWeights(array(3, 1)); - - $this->validators[] = new BAV_Validator_00($bank); + + $this->validators[] = new Validator00($bank); $this->validators[1]->setWeights(array(2, 1)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C3.php b/classes/validator/validators/ValidatorC3.php similarity index 64% rename from classes/validator/validators/BAV_Validator_C3.php rename to classes/validator/validators/ValidatorC3.php index deafab9c..78a8bc78 100644 --- a/classes/validator/validators/BAV_Validator_C3.php +++ b/classes/validator/validators/ValidatorC3.php @@ -1,9 +1,6 @@ @@ -22,53 +19,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2007 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2007 Markus Malkusch */ -class BAV_Validator_C3 extends BAV_Validator { - +class ValidatorC3 extends Validator +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_58 + * @var Validator58 */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_00($bank); + + $this->mode1 = new Validator00($bank); $this->mode1->setWeights(array(2, 1)); - - $this->mode2 = new BAV_Validator_58($bank); + + $this->mode2 = new Validator58($bank); $this->mode2->setWeights(array(2, 3, 4, 5, 6, 0, 0, 0, 0)); } - protected function validate() { - $this->validator = $this->account{0} != '9' + + protected function validate() + { + $this->validator = $this->account[0] != '9' ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C4.php b/classes/validator/validators/ValidatorC4.php similarity index 64% rename from classes/validator/validators/BAV_Validator_C4.php rename to classes/validator/validators/ValidatorC4.php index 48a73876..072ad121 100644 --- a/classes/validator/validators/BAV_Validator_C4.php +++ b/classes/validator/validators/ValidatorC4.php @@ -1,9 +1,6 @@ @@ -22,53 +19,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2007 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2007 Markus Malkusch */ -class BAV_Validator_C4 extends BAV_Validator { - +class ValidatorC4 extends Validator +{ - protected /** - * @var BAV_Validator + * @var Validator */ - $validator, + protected $validator; + /** - * @var BAV_Validator_15 + * @var Validator15 */ - $mode1, + protected $mode1; + /** - * @var BAV_Validator_58 + * @var Validator58 */ - $mode2; + protected $mode2; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->mode1 = new BAV_Validator_15($bank); + + $this->mode1 = new Validator15($bank); $this->mode1->setWeights(array(2, 3, 4, 5)); - - $this->mode2 = new BAV_Validator_58($bank); + + $this->mode2 = new Validator58($bank); $this->mode2->setWeights(array(2, 3, 4, 5, 6, 0, 0, 0, 0)); } - protected function validate() { - $this->validator = $this->account{0} != '9' + + protected function validate() + { + $this->validator = $this->account[0] != '9' ? $this->mode1 : $this->mode2; } + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/ValidatorC5.php b/classes/validator/validators/ValidatorC5.php new file mode 100644 index 00000000..726c02c2 --- /dev/null +++ b/classes/validator/validators/ValidatorC5.php @@ -0,0 +1,115 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @package classes + * @subpackage validator + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2007 Markus Malkusch + */ +class ValidatorC5 extends Validator +{ + + /** + * @var Validator + */ + protected $validator; + + /** + * @var Validator75 + */ + protected $mode1; + + /** + * @var Validator29 + */ + protected $mode2; + + /** + * @var Validator00 + */ + protected $mode3; + + /** + * @var Validator09 + */ + protected $mode4; + + public function __construct(Bank $bank) + { + parent::__construct($bank); + + $this->mode1 = new Validator75($bank); + $this->mode2 = new Validator29($bank); + $this->mode3 = new Validator00($bank); + $this->mode4 = new Validator09($bank); + } + + protected function validate() + { + $account = ltrim($this->account, '0'); + $length = strlen($account); + + switch ($length) { + case 6: + case 9: + if ($account[0] < 9) { + $this->validator = $this->mode1; + } + break; + + case 8: + if ($account[0] >= 3 && $account[0] <= 5) { + $this->validator = $this->mode4; + + } + break; + + case 10: + if ($account[0] == 1 || $account[0] >= 4 && $account[0] <= 6 || $account[0] == 9) { + $this->validator = $this->mode2; + + } elseif ($account[0] == 3) { + $this->validator = $this->mode3; + + } else { + $circle = substr($account, 0, 2); + if ($circle == 70 || $circle == 85) { + $this->validator = $this->mode4; + + } + } + break; + + default: + $this->validator = null; + break; + } + } + + /** + * @return bool + */ + protected function getResult() + { + return ! is_null($this->validator) && $this->validator->isValid($this->account); + } +} diff --git a/classes/validator/validators/BAV_Validator_C6.php b/classes/validator/validators/ValidatorC6.php similarity index 60% rename from classes/validator/validators/BAV_Validator_C6.php rename to classes/validator/validators/ValidatorC6.php index a264d262..bedd6886 100644 --- a/classes/validator/validators/BAV_Validator_C6.php +++ b/classes/validator/validators/ValidatorC6.php @@ -1,8 +1,6 @@ @@ -21,66 +19,64 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2007 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2007 Markus Malkusch */ -class BAV_Validator_C6 extends BAV_Validator { - - - static private - /** - * @var Array - */ - $transformation = array( +class ValidatorC6 extends Validator +{ + + /** + * @var Array + */ + private static $transformation = array( 0 => 4451970, 1 => 4451981, 2 => 4451992, 3 => 4451993, + 4 => 4344992, 5 => 4344990, 6 => 4344991, 7 => 5499570, + 8 => 4451994, 9 => 5499579 - ); + ); - - protected /** * @var String */ - $transformedAccount = '', + protected $transformedAccount = ''; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $validator; - + protected $validator; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->validator = new BAV_Validator_00($bank); + + $this->validator = new Validator00($bank); } - - - protected function validate() { - $transformation = array_key_exists($this->account{0}, self::$transformation) - ? self::$transformation[$this->account{0}] - : ''; + + protected function validate() + { + $transformation = array_key_exists($this->account[0], self::$transformation) + ? self::$transformation[$this->account[0]] + : ''; $this->transformedAccount = $transformation . substr($this->account, 1); $this->validator->setNormalizedSize(9 + strlen($transformation)); } - - + /** * @return bool */ - protected function getResult() { - return in_array($this->account{0}, array_keys(self::$transformation)) + protected function getResult() + { + return in_array($this->account[0], array_keys(self::$transformation)) ? $this->validator->isValid($this->transformedAccount) : false; } - - -} \ No newline at end of file +} diff --git a/classes/validator/validators/BAV_Validator_C7.php b/classes/validator/validators/ValidatorC7.php similarity index 79% rename from classes/validator/validators/BAV_Validator_C7.php rename to classes/validator/validators/ValidatorC7.php index 3be58992..de9c4d09 100644 --- a/classes/validator/validators/BAV_Validator_C7.php +++ b/classes/validator/validators/ValidatorC7.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_63($bank); + $this->validators[] = new Validator63($bank); - $this->validators[] = new BAV_Validator_06($bank); + $this->validators[] = new Validator06($bank); $this->validators[1]->setWeights(array(2, 3, 4, 5, 6, 7)); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C8.php b/classes/validator/validators/ValidatorC8.php similarity index 74% rename from classes/validator/validators/BAV_Validator_C8.php rename to classes/validator/validators/ValidatorC8.php index 117ec5fe..6432e626 100644 --- a/classes/validator/validators/BAV_Validator_C8.php +++ b/classes/validator/validators/ValidatorC8.php @@ -1,10 +1,6 @@ validators[] = new BAV_Validator_00($bank); - $this->validators[] = new BAV_Validator_04($bank); - $this->validators[] = new BAV_Validator_07($bank); + $this->validators[] = new Validator00($bank); + $this->validators[] = new Validator04($bank); + $this->validators[] = new Validator07($bank); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_C9.php b/classes/validator/validators/ValidatorC9.php similarity index 78% rename from classes/validator/validators/BAV_Validator_C9.php rename to classes/validator/validators/ValidatorC9.php index fa450107..da53f18f 100644 --- a/classes/validator/validators/BAV_Validator_C9.php +++ b/classes/validator/validators/ValidatorC9.php @@ -1,9 +1,6 @@ validators[] = new BAV_Validator_00($bank); - $this->validators[] = new BAV_Validator_07($bank); + $this->validators[] = new Validator00($bank); + $this->validators[] = new Validator07($bank); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_D0.php b/classes/validator/validators/ValidatorD0.php similarity index 74% rename from classes/validator/validators/BAV_Validator_D0.php rename to classes/validator/validators/ValidatorD0.php index 7272b57f..5a207f5e 100644 --- a/classes/validator/validators/BAV_Validator_D0.php +++ b/classes/validator/validators/ValidatorD0.php @@ -1,9 +1,6 @@ @@ -26,42 +23,36 @@ * @package classes * @subpackage validator * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2008 Markus Malkusch */ -class BAV_Validator_D0 extends BAV_Validator { - +class ValidatorD0 extends Validator +{ const SWITCH_PREFIX = '57'; - - private /** - * @var BAV_Validator + * @var Validator */ - $validator; + private $validator; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); } - - - protected function validate() { + + protected function validate() + { $this->validator = substr($this->account, 0, 2) !== self::SWITCH_PREFIX - ? new BAV_Validator_20($this->bank) - : new BAV_Validator_09($this->bank); + ? new Validator20($this->bank) + : new Validator09($this->bank); } - - + /** * @return bool */ - protected function getResult() { + protected function getResult() + { return $this->validator->isValid($this->account); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_D1.php b/classes/validator/validators/ValidatorD1.php similarity index 57% rename from classes/validator/validators/BAV_Validator_D1.php rename to classes/validator/validators/ValidatorD1.php index 0bb32c7c..a6b1c8d8 100644 --- a/classes/validator/validators/BAV_Validator_D1.php +++ b/classes/validator/validators/ValidatorD1.php @@ -1,9 +1,6 @@ @@ -22,20 +19,19 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * - * @package classes + * @package classes * @subpackage validator - * @author Markus Malkusch - * @copyright Copyright (C) 2010 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2010 Markus Malkusch */ -class BAV_Validator_D1 extends BAV_Validator { - +class ValidatorD1 extends Validator +{ - static private - /** - * @var Array - */ - $_transformation = array( + /** + * @var Array + */ + private static $transformation = array( 0 => 4363380, 1 => 4363381, 2 => 4363382, @@ -43,61 +39,59 @@ class BAV_Validator_D1 extends BAV_Validator { 4 => 4363384, 5 => 4363385, 6 => 4363386, + 7 => 4363387, 9 => 4363389 - ); + ); - - protected /** * @var String */ - $transformedAccount = '', + protected $transformedAccount = ''; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $validator; - - - public function __construct(BAV_Bank $bank) { + protected $validator; + + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->validator = new BAV_Validator_00($bank); - } + $this->validator = new Validator00($bank); + } - protected function validate() { - $transformationIndex = $this->_getTransformationIndex(); - if (! array_key_exists($transformationIndex, self::$_transformation)) { + protected function validate() + { + $transformationIndex = $this->getTransformationIndex(); + if (! array_key_exists($transformationIndex, self::$transformation)) { return; } - $transformationPrefix = self::$_transformation[$transformationIndex]; + $transformationPrefix = self::$transformation[$transformationIndex]; $this->validator->setNormalizedSize(10 + strlen($transformationPrefix)); - $this->transformedAccount + $this->transformedAccount = $transformationPrefix . substr($this->account, 1); } - - + /** * @return bool */ - protected function getResult() { - return + protected function getResult() + { + return array_key_exists( - $this->_getTransformationIndex(), - self::$_transformation + $this->getTransformationIndex(), + self::$transformation ) && $this->validator->isValid($this->transformedAccount); } - /** * @return int */ - private function _getTransformationIndex() { - return $this->account{0}; + private function getTransformationIndex() + { + return $this->account[0]; } - - -} \ No newline at end of file +} diff --git a/classes/validator/validators/BAV_Validator_D2.php b/classes/validator/validators/ValidatorD2.php similarity index 70% rename from classes/validator/validators/BAV_Validator_D2.php rename to classes/validator/validators/ValidatorD2.php index e9dec290..1fb60cd3 100644 --- a/classes/validator/validators/BAV_Validator_D2.php +++ b/classes/validator/validators/ValidatorD2.php @@ -1,10 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2010 Markus Malkusch */ -class BAV_Validator_D2 extends BAV_Validator_Chain { - - - protected - /** - * @var bool - */ - $doNormalization = false; +class ValidatorD2 extends ValidatorChain +{ + /** + * @var bool + */ + protected $doNormalization = false; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - $this->validators[] = new BAV_Validator_95($bank); - $this->validators[] = new BAV_Validator_00($bank); - $this->validators[] = new BAV_Validator_68($bank); + $this->validators[] = new Validator95($bank); + $this->validators[] = new Validator00($bank); + $this->validators[] = new Validator68($bank); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_D3.php b/classes/validator/validators/ValidatorD3.php similarity index 77% rename from classes/validator/validators/BAV_Validator_D3.php rename to classes/validator/validators/ValidatorD3.php index 0b9ab7d0..287197e6 100644 --- a/classes/validator/validators/BAV_Validator_D3.php +++ b/classes/validator/validators/ValidatorD3.php @@ -1,9 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2010 Markus Malkusch */ -class BAV_Validator_D3 extends BAV_Validator_Chain { - +class ValidatorD3 extends ValidatorChain +{ - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - $this->validators[] = new BAV_Validator_00($bank); - $this->validators[] = new BAV_Validator_27($bank); + $this->validators[] = new Validator00($bank); + $this->validators[] = new Validator27($bank); } - - } - - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_D4.php b/classes/validator/validators/ValidatorD4.php similarity index 68% rename from classes/validator/validators/BAV_Validator_D4.php rename to classes/validator/validators/ValidatorD4.php index 355954ba..36201af7 100644 --- a/classes/validator/validators/BAV_Validator_D4.php +++ b/classes/validator/validators/ValidatorD4.php @@ -1,8 +1,6 @@ - * @copyright Copyright (C) 2010 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2010 Markus Malkusch */ -class BAV_Validator_D4 extends BAV_Validator { - +class ValidatorD4 extends Validator +{ - protected /** * @var String */ - $transformedAccount = '', + protected $transformedAccount = ''; + /** - * @var BAV_Validator_00 + * @var Validator00 */ - $validator; - - const TRANSFORMATION = 428259; + protected $validator; + const TRANSFORMATION = 428259; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->validator = new BAV_Validator_00($bank); + + $this->validator = new Validator00($bank); $this->validator->setNormalizedSize(10 + strlen(self::TRANSFORMATION)); } - - - protected function validate() { + + protected function validate() + { $this->transformedAccount = self::TRANSFORMATION.$this->account; } - - + /** * @return bool */ - protected function getResult() { - return $this->account{0} != 0 + protected function getResult() + { + return $this->account[0] != 0 && $this->validator->isValid($this->transformedAccount); } - - -} \ No newline at end of file +} diff --git a/classes/validator/validators/BAV_Validator_D5.php b/classes/validator/validators/ValidatorD5.php similarity index 59% rename from classes/validator/validators/BAV_Validator_D5.php rename to classes/validator/validators/ValidatorD5.php index dd7e1bba..a39997b5 100644 --- a/classes/validator/validators/BAV_Validator_D5.php +++ b/classes/validator/validators/ValidatorD5.php @@ -1,8 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2010 Markus Malkusch */ -class BAV_Validator_D5 extends BAV_Validator { +class ValidatorD5 extends Validator +{ - - private /** - * @var BAV_Validator + * @var Validator */ - $_validator, + private $validator; + /** - * @var BAV_Validator_06 + * @var Validator06 */ - $_validator1, + private $validator1; + /** - * @var BAV_Validator_Chain + * @var ValidatorChain */ - $_validatorChain; + private $validatorChain; - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - $this->_validator1 = new BAV_Validator_06($bank); - $this->_validator1->setWeights(array(2, 3, 4, 5, 6, 7, 8, 0, 0)); + $this->validator1 = new Validator06($bank); + $this->validator1->setWeights(array(2, 3, 4, 5, 6, 7, 8, 0, 0)); - $this->_validatorChain = new BAV_Validator_Chain($bank); + $this->validatorChain = new ValidatorChain($bank); - $validator2 = new BAV_Validator_06($bank); + $validator2 = new Validator06($bank); $validator2->setWeights(array(2, 3, 4, 5, 6, 7, 0, 0, 0)); - $this->_validatorChain->addValidator($validator2); + $this->validatorChain->addValidator($validator2); - $validator3 = new BAV_Validator_06($bank); + $validator3 = new Validator06($bank); $validator3->setWeights(array(2, 3, 4, 5, 6, 7, 0, 0, 0)); $validator3->setDivisor(7); - $this->_validatorChain->addValidator($validator3); + $this->validatorChain->addValidator($validator3); - $validator4 = new BAV_Validator_06($bank); + $validator4 = new Validator06($bank); $validator4->setWeights(array(2, 3, 4, 5, 6, 7, 0, 0, 0)); $validator4->setDivisor(10); - $this->_validatorChain->addValidator($validator4); + $this->validatorChain->addValidator($validator4); } - /** * Uses the validator * * @return bool */ - protected function getResult() { - return $this->_validator->isValid($this->account); + protected function getResult() + { + return $this->validator->isValid($this->account); } - /** * decide which validators are used * * @return void */ - protected function validate() { - $this->_validator + protected function validate() + { + $this->validator = substr($this->account, 2, 2) == 99 - ? $this->_validator1 - : $this->_validatorChain; + ? $this->validator1 + : $this->validatorChain; } - - -} \ No newline at end of file +} diff --git a/classes/validator/validators/BAV_Validator_D6.php b/classes/validator/validators/ValidatorD6.php similarity index 74% rename from classes/validator/validators/BAV_Validator_D6.php rename to classes/validator/validators/ValidatorD6.php index b564df00..617c5dc0 100644 --- a/classes/validator/validators/BAV_Validator_D6.php +++ b/classes/validator/validators/ValidatorD6.php @@ -1,10 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2010 Markus Malkusch */ -class BAV_Validator_D6 extends BAV_Validator_Chain { - +class ValidatorD6 extends ValidatorChain +{ - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - $this->validators[] = new BAV_Validator_07($bank); - $this->validators[] = new BAV_Validator_03($bank); - $this->validators[] = new BAV_Validator_00($bank); + $this->validators[] = new Validator07($bank); + $this->validators[] = new Validator03($bank); + $this->validators[] = new Validator00($bank); } - - -} \ No newline at end of file +} diff --git a/classes/validator/validators/BAV_Validator_D7.php b/classes/validator/validators/ValidatorD7.php similarity index 82% rename from classes/validator/validators/BAV_Validator_D7.php rename to classes/validator/validators/ValidatorD7.php index 8f226fd4..90fd298f 100644 --- a/classes/validator/validators/BAV_Validator_D7.php +++ b/classes/validator/validators/ValidatorD7.php @@ -1,7 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2011 Markus Malkusch */ -class BAV_Validator_D7 extends BAV_Validator_Iteration_Weighted { +class ValidatorD7 extends WeightedIterationValidator +{ - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); $this->setWeights(array(2, 1)); $this->setDivisor(10); } - - protected function iterationStep() { + protected function iterationStep() + { $this->accumulator += $this->crossSum($this->number * $this->getWeight()); } - - protected function getResult() { + protected function getResult() + { $result = $this->accumulator % $this->divisor; return (string)$result === $this->getCheckNumber(); } - } - -?> \ No newline at end of file diff --git a/classes/validator/validators/BAV_Validator_D8.php b/classes/validator/validators/ValidatorD8.php similarity index 64% rename from classes/validator/validators/BAV_Validator_D8.php rename to classes/validator/validators/ValidatorD8.php index 9693082a..032d2d22 100644 --- a/classes/validator/validators/BAV_Validator_D8.php +++ b/classes/validator/validators/ValidatorD8.php @@ -1,8 +1,6 @@ - * @copyright Copyright (C) 2011 Markus Malkusch + * @author Markus Malkusch + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @copyright Copyright (C) 2011 Markus Malkusch */ -class BAV_Validator_D8 extends BAV_Validator { - +class ValidatorD8 extends Validator +{ - private /** - * @var BAV_Validator_00 + * @var Validator00 */ - $_validator; + private $validator; - - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - - $this->_validator = new BAV_Validator_00($bank); - } + $this->validator = new Validator00($bank); + } - protected function validate() { + protected function validate() + { } - - + /** * @return bool */ - protected function getResult() { - if ($this->account{0} != 0) { - return $this->_validator->isValid($this->account); + protected function getResult() + { + if ($this->account[0] != 0) { + return $this->validator->isValid($this->account); } $set = (int) substr($this->account, 0, 3); return $set >= 1 && $set <= 9; } - - -} \ No newline at end of file +} diff --git a/classes/validator/validators/BAV_Validator_D9.php b/classes/validator/validators/ValidatorD9.php similarity index 74% rename from classes/validator/validators/BAV_Validator_D9.php rename to classes/validator/validators/ValidatorD9.php index 0e09d848..50060503 100644 --- a/classes/validator/validators/BAV_Validator_D9.php +++ b/classes/validator/validators/ValidatorD9.php @@ -1,10 +1,6 @@ + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations * @copyright Copyright (C) 2012 Markus Malkusch */ -class BAV_Validator_D9 extends BAV_Validator_Chain { - +class ValidatorD9 extends ValidatorChain +{ - public function __construct(BAV_Bank $bank) { + public function __construct(Bank $bank) + { parent::__construct($bank); - $this->validators[] = new BAV_Validator_00($bank); - $this->validators[] = new BAV_Validator_10($bank); - $this->validators[] = new BAV_Validator_18($bank); + $this->validators[] = new Validator00($bank); + $this->validators[] = new Validator10($bank); + $this->validators[] = new Validator18($bank); } - - -} \ No newline at end of file +} diff --git a/classes/validator/validators/ValidatorE0.php b/classes/validator/validators/ValidatorE0.php new file mode 100644 index 00000000..bd21e41a --- /dev/null +++ b/classes/validator/validators/ValidatorE0.php @@ -0,0 +1,34 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @author hhilbert 2013-03-12 added + */ +class ValidatorE0 extends Validator00 +{ + + protected function validate() + { + parent::validate(); + $this->accumulator += 7; + } +} diff --git a/classes/validator/validators/ValidatorE1.php b/classes/validator/validators/ValidatorE1.php new file mode 100644 index 00000000..5c582fd3 --- /dev/null +++ b/classes/validator/validators/ValidatorE1.php @@ -0,0 +1,55 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * This class was strong inspired by the class SystemE1 of Jan Schädlich + * https://github.com/jschaedl/Bav/blob/master/library/Bav/Validator/De/SystemE1.php + */ + +class ValidatorE1 extends WeightedIterationValidator +{ + + private static $subsitutions = array(48, 49, 50, 51, 52, 53, 54, 55, 56, 57); + + public function __construct(Bank $bank) + { + parent::__construct($bank); + + $this->setWeights(array(1, 2, 3, 4, 5, 6, 11, 10, 9)); + $this->setDivisor(11); + } + + protected function iterationStep() + { + $this->accumulator += self::$subsitutions[$this->number] * $this->getWeight(); + } + + protected function getResult() + { + $result = $this->accumulator % $this->divisor; + if ($result == 10) { + return false; + + } + return (string) $result === $this->getCheckNumber(); + } +} diff --git a/classes/validator/validators/ValidatorE2.php b/classes/validator/validators/ValidatorE2.php new file mode 100644 index 00000000..8fc16d53 --- /dev/null +++ b/classes/validator/validators/ValidatorE2.php @@ -0,0 +1,63 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +class ValidatorE2 extends Validator +{ + + /** + * @var int[] The addition map. + */ + private static $prefixes = [ + 0 => 4383200, + 1 => 4383201, + 2 => 4383202, + 3 => 4383203, + 4 => 4383204, + 5 => 4383205, + ]; + + /** + * @var bool The validation result. + */ + private $result; + + protected function validate() + { + if (in_array($this->account[0], [6, 7, 8, 9])) { + $this->result = false; + return; + } + + $validator = new Validator00($this->bank); + $validator->doNormalization = false; + + $prefixedAccount = self::$prefixes[$this->account[0]] . substr($this->account, 1); + + $this->result = $validator->isValid($prefixedAccount); + } + + protected function getResult() + { + return $this->result; + } +} diff --git a/classes/validator/validators/ValidatorE3.php b/classes/validator/validators/ValidatorE3.php new file mode 100644 index 00000000..b4636e95 --- /dev/null +++ b/classes/validator/validators/ValidatorE3.php @@ -0,0 +1,34 @@ +bank); + $this->result = $validator->isValid($this->account); + + if(!$this->result) { + $validator = new Validator21($this->bank); + $this->result = $validator->isValid($this->account); + } + } + + protected function getResult() + { + return $this->result; + } +} diff --git a/classes/validator/validators/ValidatorE4.php b/classes/validator/validators/ValidatorE4.php new file mode 100644 index 00000000..8326fb84 --- /dev/null +++ b/classes/validator/validators/ValidatorE4.php @@ -0,0 +1,36 @@ +bank); + $validator->setWeights([2, 3, 4, 5, 6, 7, 8, 9, 2]); + $validator->setDivisor(11); + + $this->result = $validator->isValid($this->account); + + if(!$this->result) { + $validator = new Validator00($this->bank); + $this->result = $validator->isValid($this->account); + } + } + + protected function getResult() + { + return $this->result; + } +} diff --git a/classes/verify/BAV_VerifyImport.php b/classes/verify/BAV_VerifyImport.php deleted file mode 100644 index cc8fdca2..00000000 --- a/classes/verify/BAV_VerifyImport.php +++ /dev/null @@ -1,212 +0,0 @@ -. - * - * Copyright (C) 2006 Markus Malkusch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * BAV_DataBackend - * - * @package classes - * @subpackage verify - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_VerifyImport extends BAV { - - - private - /** - * @var Array Numbers which are valid - */ - $validNumbers = array(), - /** - * @var Array Numbers which aren't valid - */ - $invalidNumbers = array(), - /** - * @var BAV_DataBackend - */ - $dataBackend; - - - /** - * @param BAV_DataBackend $dataBackend The backend is needed to get the validation algorithm. - */ - public function __construct(BAV_DataBackend $dataBackend) { - $this->dataBackend = $dataBackend; - } - /** - * @return String - */ - private function getFile($file) { - return is_null($file) - ? __DIR__.'/../../data/verify.ini' - : $file; - } - /** - * Imports an existing verify.ini. - * - * @param string $file - * @throws BAV_VerifyException - */ - public function importVerifyFile($file = NULL) { - $file = $this->getFile($file); - $verify = parse_ini_file($file, true); - if (! $verify) { - throw new BAV_VerifyException("couldn't parse $file"); - - } - - $this->mergeVerifyArray($verify['valid'], $this->validNumbers); - $this->mergeVerifyArray($verify['invalid'], $this->invalidNumbers); - } - /** - * Merges a string array of an existing verify.ini - */ - private function mergeVerifyArray($verifyArray, & $targetArray) { - if (! is_array($verifyArray)) { - return; - - } - foreach ($verifyArray as $type => $string) { - $type = (strlen($type) < 2 ? '0' : '').$type; - $accountIDs = preg_split('~\D+~', $string); - foreach ($accountIDs as $accountID) { - $accountID = $this->normalize($accountID); - $targetArray[$type][] = $accountID; - - } - - } - } - /** - * @param string $bankID - * @param string $accountID - * @param bool $isValid if $accountID should be valid or not. Defaults to TRUE for valid. - * @throws BAV_DataBackendException_BankNotFound - * @throws BAV_DataBackendException - */ - public function import($bankID, $accountID, $isValid = true) { - $bankID = $this->normalize($bankID); - $accountID = $this->normalize($accountID); - $bank = $this->dataBackend->getBank($bankID); - $type = $bank->getValidator() instanceof BAV_Validator_BankDependent - ? $bankID - : $bank->getValidationType(); - if ($isValid) { - $this->validNumbers[$type][] = $accountID; - - } else { - $this->invalidNumbers[$type][] = $accountID; - - } - } - /** - * Removes all none numeric characters from $id. - * - * @param string $id - * @return string - */ - private function normalize($id) { - return (string) preg_replace('~\D+~', '', $id); - } - /** - * @param string $filePath The file where the arrays are saved (default's to ../../data/verify.ini) - * @throws BAV_VerifyException_IO - */ - public function save($file = null) { - $file = $this->getFile($file); - $fp = fopen($file, 'w'); - if (! is_resource($fp)) { - throw new BAV_VerifyException_IO("Could not open $file."); - - } - try { - $this->saveArray($fp, $this->invalidNumbers, 'invalid'); - $this->saveArray($fp, $this->validNumbers, 'valid'); - fclose($fp); - - } catch (BAV_VerifyException_IO $e) { - fclose($fp); - throw $e; - - } - } - /** - * @param Resource $fp Filepointer - * @param Array $array Array with bank IDs - * @param String $name Name of the section - * @throws BAV_VerifyException_IO - */ - private function saveArray($fp, Array $array, $name) { - if (! fwrite($fp, "\n\n".'['.$name.']')) { - throw new BAV_VerifyException_IO(); - - } - ksort($array); - foreach ($array as $type => $numbers) { - $type = ltrim($type, '0'); - if (empty($type)) { - $type = '0'; - - } - if (! fwrite($fp, "\n".' '.$type.' = ')) { - throw new BAV_VerifyException_IO(); - - } - $line = implode(', ', array_unique($numbers)); - if (fwrite($fp, $line, strlen($line)) !== strlen($line)) { - throw new BAV_VerifyException_IO(); - - } - - } - } - /** - * @param String $bankID - * @return String - * @throws BAV_DataBackendException_BankNotFound - * @throws BAV_DataBackendException - */ - private function bankIDToType($bankID) { - return $this->dataBackend->getBank($bankID)->getValidationType(); - } - - -} - - -?> \ No newline at end of file diff --git a/classes/verify/exception/BAV_VerifyException.php b/classes/verify/exception/BAV_VerifyException.php deleted file mode 100644 index f0fcf461..00000000 --- a/classes/verify/exception/BAV_VerifyException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage verify - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_VerifyException extends RuntimeException { - - -} - - -?> \ No newline at end of file diff --git a/classes/verify/exception/BAV_VerifyException_IO.php b/classes/verify/exception/BAV_VerifyException_IO.php deleted file mode 100644 index b8c033d2..00000000 --- a/classes/verify/exception/BAV_VerifyException_IO.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * @package classes - * @subpackage verify - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - */ -class BAV_VerifyException_IO extends BAV_VerifyException { - - -} - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/BAV_TestAPI.php b/classes/verify/testAPI/BAV_TestAPI.php deleted file mode 100644 index 6fc32a47..00000000 --- a/classes/verify/testAPI/BAV_TestAPI.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package classes - * @subpackage verify - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ -abstract class BAV_TestAPI extends BAV { - - - private - /** - * @var String - */ - $name = ''; - - - /** - * @param int $account - * @return bool - * @throws BAV_TestAPIException_Validation - */ - abstract protected function isValid(BAV_Bank $bank, $account); - - - public function __construct() { - $this->setName(get_class($this)); - } - - - /** - * @param string $name - */ - protected function setName($name) { - $this->name = $name; - } - - /** - * @param int $account - * @return BAV_TestAPIResult - */ - public function getResult(BAV_Bank $bank, $account) { - try { - $result = $this->isValid($bank, $account) - ? BAV_TestAPIResult::VALID - : BAV_TestAPIResult::INVALID; - return new BAV_TestAPIResult($this, $result); - - } catch (Exception $e) { - return new BAV_TestAPIResult_Error( - $this, - BAV_TestAPIResult::ERROR, - $e->getMessage() - ); - - } - } - - - /** - * @return String - */ - public function getName() { - return $this->name; - } - - -} - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/BAV_TestAPI_Kontocheck.php b/classes/verify/testAPI/BAV_TestAPI_Kontocheck.php deleted file mode 100644 index 5140c24e..00000000 --- a/classes/verify/testAPI/BAV_TestAPI_Kontocheck.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package classes - * @subpackage verify - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ -class BAV_TestAPI_Kontocheck extends BAV_TestAPI { - - - const NOT_INITIALIZED = -40; - const BANK_NOT_FOUND = -4; - const INVALID_NULL = -12; - const INVALID_KTO = -3; - const INVALID_FALSE = 0; - - - /** - * @param String $lutFile - * @param int $lutVersion - * @throws BAV_TestAPIException - */ - public function __construct($lutFile, $lutVersion) { - parent::__construct(); - - $this->setName("kc"); - - if (! lut_init($lutFile, $lutVersion)) { - throw new BAV_TestAPIException("Could not initialize LUT."); - - } - } - - - /** - * @param int $bank - * @param int $account - * @return bool - * @throws BAV_TestAPIException_Validation - * @throws BAV_TestAPIException_Validation_NotInitialized - * @throws BAV_TestAPIException_Validation_BankNotFound - */ - protected function isValid(BAV_Bank $bank, $account) { - $isValid = kto_check_blz($bank->getBankID(), $account); - - switch ($isValid) { - - case self::NOT_INITIALIZED: - throw new BAV_TestAPIException_Validation_NotInitialized("LUT not initialized"); - - case self::BANK_NOT_FOUND: - throw new BAV_TestAPIException_Validation_BankNotFound($bank->getBankID()); - - case self::INVALID_NULL: - case self::INVALID_KTO: - case self::INVALID_FALSE: - return false; - - default: - if ($isValid < 0) { - throw new BAV_TestAPIException_Validation("unknown code $isValid"); - - } - return true; - - } - } - - -} - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/BAV_TestAPI_Ktoblzcheck.php b/classes/verify/testAPI/BAV_TestAPI_Ktoblzcheck.php deleted file mode 100644 index c8f86675..00000000 --- a/classes/verify/testAPI/BAV_TestAPI_Ktoblzcheck.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package classes - * @subpackage verify - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ -class BAV_TestAPI_Ktoblzcheck extends BAV_TestAPI { - - - const BINARY = "ktoblzcheck"; - const VALID = 0; - const INVALID = 2; - const BANK_NOT_FOUND = 3; - - - - private - /** - * @var String - */ - $binary = '', - /** - * @var String - */ - $bankdata = ''; - - - /** - * @param String $bankdata - * @param String $binary - * @throws BAV_TestAPIException - */ - public function __construct($bankdata, $binary = null) { - parent::__construct(); - - $this->setName("ktoblzcheck"); - - $this->bankdata = realpath($bankdata); - $this->binary = is_null($binary) ? self::BINARY : realpath($binary); - } - - - /** - * @param int $account - * @return bool - * @throws BAV_TestAPIException_Validation - * @throws BAV_TestAPIException_Validation_NotInitialized - * @throws BAV_TestAPIException_Validation_BankNotFound - */ - protected function isValid(BAV_Bank $bank, $account) { - exec( - "$this->binary --file=$this->bankdata {$bank->getBankID()} $account", - $out, - $result - ); - - switch ($result) { - - case self::VALID: - return true; - - case self::INVALID: - return false; - - case self::BANK_NOT_FOUND: - throw new BAV_TestAPIException_Validation_BankNotFound("Bank not found: {$bank->getBankID()}"); - - default: - throw new BAV_TestAPIException_Validation("unknown code $result: " . implode("\n", $out)); - - } - } - - -} - - -?> \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..c75ea6ba --- /dev/null +++ b/composer.json @@ -0,0 +1,42 @@ +{ + "name": "bmdevel/bav", + "type": "library", + "description": "BAV provides validation for German Bank Accounts (Konto)", + "keywords": ["bank", "account", "bankaccount", "validation", "check", "konto"], + "homepage": "http://bav.malkusch.de/", + "license": "WTFPL", + "authors": [ + { + "name": "Markus Malkusch", + "email": "markus@malkusch.de", + "homepage": "http://markus.malkusch.de", + "role": "Developer" + } + ], + "autoload": { + "files": ["autoloader/autoloader.php"] + }, + "require": { + "php": ">=7.2", + "bmdevel/php-index": "~0.3" + }, + "suggest": { + "ext-PDO": "Allows storing bank information in a database", + "ext-mbstring": "Enables UTF-8 support", + "ext-dom": "Enables picking the download URI by xpath", + "lib-curl": "Enables API for downloading the bank file", + "doctrine/orm": "Support for Doctrine ORM data backend" + }, + "require-dev": { + "phpunit/phpunit": "^8.4", + "doctrine/orm": "^2", + "phpcompatibility/php-compatibility": "^9.3" + }, + "archive": { + "exclude": ["/tests"] + }, + "bin": [ + "bin/bav-update.php", + "bin/bav-install.php" + ] +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..dd731f87 --- /dev/null +++ b/composer.lock @@ -0,0 +1,2830 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "c1a122894cb268152f5e2a6c51cee137", + "packages": [ + { + "name": "bmdevel/php-index", + "version": "0.3", + "source": { + "type": "git", + "url": "https://github.com/bmdevel/php-index.git", + "reference": "6a6b476f1706b9524bfb34f6ce0963b1aea91259" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bmdevel/php-index/zipball/6a6b476f1706b9524bfb34f6ce0963b1aea91259", + "reference": "6a6b476f1706b9524bfb34f6ce0963b1aea91259", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "files": [ + "autoloader/autoloader.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "WTFPL" + ], + "authors": [ + { + "name": "Markus Malkusch", + "email": "markus@malkusch.de", + "homepage": "http://markus.malkusch.de", + "role": "Developer" + } + ], + "description": "This library provides an API to perform binary search operations on a sorted index. The index can be a XML document, a CSV document, or an arbitrary text file where the key has a fixed position. You can easily implement your own index. This API comes handy on any sorted data structure where realtime search operations are necessary without the detour of a DBS import.", + "homepage": "https://github.com/bmdevel/php-index", + "keywords": [ + "binary search", + "index" + ], + "time": "2018-09-19T09:54:10+00:00" + } + ], + "packages-dev": [ + { + "name": "doctrine/annotations", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc", + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2019-10-01T18:55:10+00:00" + }, + { + "name": "doctrine/cache", + "version": "1.9.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "c15dcd24b756f9e52ea7c3ae8227354f3628f11a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/c15dcd24b756f9e52ea7c3ae8227354f3628f11a", + "reference": "c15dcd24b756f9e52ea7c3ae8227354f3628f11a", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "doctrine/coding-standard": "^6.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "riak", + "xcache" + ], + "time": "2019-11-11T10:31:52+00:00" + }, + { + "name": "doctrine/collections", + "version": "1.6.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "6b1e4b2b66f6d6e49983cebfe23a21b7ccc5b0d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/6b1e4b2b66f6d6e49983cebfe23a21b7ccc5b0d7", + "reference": "6b1e4b2b66f6d6e49983cebfe23a21b7ccc5b0d7", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan-shim": "^0.9.2", + "phpunit/phpunit": "^7.0", + "vimeo/psalm": "^3.2.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.", + "homepage": "https://www.doctrine-project.org/projects/collections.html", + "keywords": [ + "array", + "collections", + "iterators", + "php" + ], + "time": "2019-11-13T13:07:11+00:00" + }, + { + "name": "doctrine/common", + "version": "v2.11.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "b8ca1dcf6b0dc8a2af7a09baac8d0c48345df4ff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/b8ca1dcf6b0dc8a2af7a09baac8d0c48345df4ff", + "reference": "b8ca1dcf6b0dc8a2af7a09baac8d0c48345df4ff", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.0", + "doctrine/cache": "^1.0", + "doctrine/collections": "^1.0", + "doctrine/event-manager": "^1.0", + "doctrine/inflector": "^1.0", + "doctrine/lexer": "^1.0", + "doctrine/persistence": "^1.1", + "doctrine/reflection": "^1.0", + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "^1.0", + "phpstan/phpstan": "^0.11", + "phpstan/phpstan-phpunit": "^0.11", + "phpunit/phpunit": "^7.0", + "squizlabs/php_codesniffer": "^3.0", + "symfony/phpunit-bridge": "^4.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, persistence interfaces, proxies, event system and much more.", + "homepage": "https://www.doctrine-project.org/projects/common.html", + "keywords": [ + "common", + "doctrine", + "php" + ], + "time": "2019-09-10T10:10:14+00:00" + }, + { + "name": "doctrine/dbal", + "version": "v2.10.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "0c9a646775ef549eb0a213a4f9bd4381d9b4d934" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/0c9a646775ef549eb0a213a4f9bd4381d9b4d934", + "reference": "0c9a646775ef549eb0a213a4f9bd4381d9b4d934", + "shasum": "" + }, + "require": { + "doctrine/cache": "^1.0", + "doctrine/event-manager": "^1.0", + "ext-pdo": "*", + "php": "^7.2" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "jetbrains/phpstorm-stubs": "^2019.1", + "phpstan/phpstan": "^0.11.3", + "phpunit/phpunit": "^8.4.1", + "symfony/console": "^2.0.5|^3.0|^4.0|^5.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.10.x-dev", + "dev-develop": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlanywhere", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "time": "2019-11-03T16:50:43+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "629572819973f13486371cb611386eb17851e85c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/629572819973f13486371cb611386eb17851e85c", + "reference": "629572819973f13486371cb611386eb17851e85c", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "conflict": { + "doctrine/common": "<2.9@dev" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "time": "2019-11-10T09:48:07+00:00" + }, + { + "name": "doctrine/inflector", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/ec3a55242203ffa6a4b27c58176da97ff0a7aec1", + "reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2019-10-30T19:59:35+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2019-10-21T16:45:58+00:00" + }, + { + "name": "doctrine/lexer", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "time": "2019-10-30T14:39:59+00:00" + }, + { + "name": "doctrine/orm", + "version": "v2.6.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/orm.git", + "reference": "b52ef5a1002f99ab506a5a2d6dba5a2c236c5f43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/orm/zipball/b52ef5a1002f99ab506a5a2d6dba5a2c236c5f43", + "reference": "b52ef5a1002f99ab506a5a2d6dba5a2c236c5f43", + "shasum": "" + }, + "require": { + "doctrine/annotations": "~1.5", + "doctrine/cache": "~1.6", + "doctrine/collections": "^1.4", + "doctrine/common": "^2.7.1", + "doctrine/dbal": "^2.6", + "doctrine/instantiator": "~1.1", + "ext-pdo": "*", + "php": "^7.1", + "symfony/console": "~3.0|~4.0" + }, + "require-dev": { + "doctrine/coding-standard": "^5.0", + "phpunit/phpunit": "^7.5", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" + }, + "bin": [ + "bin/doctrine" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\ORM\\": "lib/Doctrine/ORM" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "Object-Relational-Mapper for PHP", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "orm" + ], + "time": "2019-09-20T14:30:26+00:00" + }, + { + "name": "doctrine/persistence", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/persistence.git", + "reference": "43526ae63312942e5316100bb3ed589ba1aba491" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/persistence/zipball/43526ae63312942e5316100bb3ed589ba1aba491", + "reference": "43526ae63312942e5316100bb3ed589ba1aba491", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.0", + "doctrine/cache": "^1.0", + "doctrine/collections": "^1.0", + "doctrine/event-manager": "^1.0", + "doctrine/reflection": "^1.0", + "php": "^7.1" + }, + "conflict": { + "doctrine/common": "<2.10@dev" + }, + "require-dev": { + "doctrine/coding-standard": "^5.0", + "phpstan/phpstan": "^0.8", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.", + "homepage": "https://doctrine-project.org/projects/persistence.html", + "keywords": [ + "mapper", + "object", + "odm", + "orm", + "persistence" + ], + "time": "2019-04-23T12:39:21+00:00" + }, + { + "name": "doctrine/reflection", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/reflection.git", + "reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/reflection/zipball/02538d3f95e88eb397a5f86274deb2c6175c2ab6", + "reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.0", + "ext-tokenizer": "*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "^4.0", + "doctrine/common": "^2.8", + "phpstan/phpstan": "^0.9.2", + "phpstan/phpstan-phpunit": "^0.9.4", + "phpunit/phpunit": "^7.0", + "squizlabs/php_codesniffer": "^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "Doctrine Reflection component", + "homepage": "https://www.doctrine-project.org/projects/reflection.html", + "keywords": [ + "reflection" + ], + "time": "2018-06-14T14:45:07+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.9.3", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2019-08-09T12:45:53+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" + }, + { + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "~6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2018-08-07T13:53:10+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "shasum": "" + }, + "require": { + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "doctrine/instantiator": "^1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2019-09-12T14:27:41+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "shasum": "" + }, + "require": { + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2019-08-22T18:11:29+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.9.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8.x-dev" + } + }, + "autoload": { + "psr-4": { + "Prophecy\\": "src/Prophecy" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2019-10-03T11:07:50+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "7.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "aa0d179a13284c7420fc281fc32750e6cc7c9e2f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa0d179a13284c7420fc281fc32750e6cc7c9e2f", + "reference": "aa0d179a13284c7420fc281fc32750e6cc7c9e2f", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.1.1", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^4.2.2", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1.3" + }, + "require-dev": { + "phpunit/phpunit": "^8.2.2" + }, + "suggest": { + "ext-xdebug": "^2.7.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2019-09-17T06:24:36+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "050bedf145a257b1ff02746c31894800e5122946" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2018-09-13T20:33:42+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "2.1.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2019-06-07T04:22:29+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "abandoned": true, + "time": "2019-09-17T06:23:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "8.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "67f9e35bffc0dd52d55d565ddbe4230454fd6a4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/67f9e35bffc0dd52d55d565ddbe4230454fd6a4e", + "reference": "67f9e35bffc0dd52d55d565ddbe4230454fd6a4e", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.2.0", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.1", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.2", + "phpspec/prophecy": "^1.8.1", + "phpunit/php-code-coverage": "^7.0.7", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.2", + "sebastian/exporter": "^3.1.1", + "sebastian/global-state": "^3.0.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0.1", + "sebastian/type": "^1.1.3", + "sebastian/version": "^2.0.1" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*", + "phpunit/php-invoker": "^2.0.0" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "8.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2019-11-06T09:42:23+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" + }, + { + "name": "sebastian/comparator", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "shasum": "" + }, + "require": { + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2018-07-12T15:12:46+00:00" + }, + { + "name": "sebastian/diff", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "time": "2019-02-04T06:01:07+00:00" + }, + { + "name": "sebastian/environment", + "version": "4.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2019-05-05T09:05:15+00:00" + }, + { + "name": "sebastian/exporter", + "version": "3.1.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2019-09-14T09:02:43+00:00" + }, + { + "name": "sebastian/global-state", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "shasum": "" + }, + "require": { + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^8.0" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2019-02-01T05:30:01+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-08-03T12:35:26+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2017-03-03T06:23:57+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2018-10-04T04:07:39+00:00" + }, + { + "name": "sebastian/type", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "time": "2019-07-02T08:10:15+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.6", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "e97627871a7eab2f70e59166072a6b767d5834e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e97627871a7eab2f70e59166072a6b767d5834e0", + "reference": "e97627871a7eab2f70e59166072a6b767d5834e0", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2020-08-10T04:50:15+00:00" + }, + { + "name": "symfony/console", + "version": "v4.3.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "831424efae0a1fe6642784bd52aae14ece6538e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/831424efae0a1fe6642784bd52aae14ece6538e6", + "reference": "831424efae0a1fe6642784bd52aae14ece6538e6", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/service-contracts": "^1.1" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<4.3", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "^4.3", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0", + "symfony/var-dumper": "^4.3" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2019-11-13T07:29:07+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.12.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.12-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-08-06T08:03:45+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.12.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.12-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2019-08-06T08:03:45+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.12.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188", + "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.12-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2019-08-06T08:03:45+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/container": "^1.0" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-10-14T12:27:06+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2019-06-13T22:48:21+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^7.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2019-08-24T08:43:50+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.2" + }, + "platform-dev": [], + "plugin-api-version": "1.1.0" +} diff --git a/data/verify.ini b/data/verify.ini deleted file mode 100644 index af6e8793..00000000 --- a/data/verify.ini +++ /dev/null @@ -1,225 +0,0 @@ -; This file is used by checkValidators.php. -; -; Here are explicitly valid or invalid accounts for validation types -; listet. ValidatorTest.php will recognize if a validator behaves not -; as this file expect him to. -; -; Copyright (C) 2010 Markus Malkusch -; -; This program is free software; you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation; either version 2 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -[invalid] - 0 = 51181008, 71214205, 6414241, 179751314, 1600166307, 1600176485, 1600201934 - 5 = 1151043211 - 57 = 5302707782, 6412121212, 1813499124, 2206735010 - A1 = 0110030005, 0010030998, 0000030005 - A2 = 1234567890, 0123456789 - A3 = 6543217890, 0543216789 - A4 = 0000399443, 0000553313, 6099702031 - A5 = 9941510002, 9961230020, 0000251438, 000798345 - A6 = 860000817, 810033652, 305888, 200071280 - A7 = 209010893 - A8 = 7436666, 7436677, 3199500502, 3503391, 1340966, 99345678, 9934567, 99100110, 199100040 - A9 = 86724, 292497, 30767208 - B0 = 8137423260, 600000606, 51234309, 1000000405, 1035791539, 8035791532, 535791830, 51234901 - B1 = 0123456789, 2345678901, 5678901234 - B2 = 0020012399, 0080012347, 0080012370, 0932100027, 3310123454, 8000990057, 8011000126, 9000481800, 9980480111 - B3 = 2799899, 1000000111, 9635100101, 9730300100 - B4 = 9941510002, 9961230020, 251438, 7948345, 159590 - B5 = 0159004165, 0023456787, 0056789018, 3045000333, 7414398260, 8347251693, 2345678901, 5678901234, 9000293707 - B6 = 9111000000, 0269456780 - B7 = 0001057886, 0003815570, 0005620516, 0740912243, 0893524479 - B8 = 0132572975, 9000412340, 9310305011 - B9 = 88034023, 43025432, 86521362, 61256523, 54352684, 2356412, 5435886, 9435414 - C1 = 5432112341, 5543223458, 5654334565, 5765445672, 5876556780, 0446786240, 0478046340, 0701625730, 0701625440, 0882095130 - C2 = 0328705282, 9024675131 - C3 = 17002, 123451, 122448, 9000734028, 9000733227, 9000731120 - C4 = 0000000017, 0000292933, 0000094459, 9000726558, 9001733457, 9000732000 - C5 = 0000302589, 0000507336, 0302555000, 0302589000, 1000061457, 1000061498, 4864446015, 4865038012, 5000001028, 5000001075, 6450008150, 6542812818, 9000110012, 9000300310, 3081000783, 3081308871 - C6 = 0525111212, 0091423614, 1082311275, 1000118821, 2004306518, 2016001206, 3462816371, 3622548632, 4232300145, 4000456126, 4642847318, 5002684526, 5564123850, 6295473774, 6640806317, 7000062022, 7006003027, 7003306026, 7001501029, 8348300005, 7006003027, 8654216984, 9000641509, 9000260986 - C7 = 1234517892, 987614325 - C8 = 1234567890, 9012345678 - C9 = 3456789012, 1234567890, 9012345678 - D0 = 6100272885, 6100273377, 6100274012 - D1 = 0000260986, 1062813622, 2000000000, 2001501026, 2256412314, 3012084101, 4006003027, 5814500990, 6128462594, 7000000000, 7000062025, 8000000000, 8003306026, 9000641509 - D2 = 6414241, 179751314 - D3 = 6025017009, 6028267003, 6019835001 - D4 = 0359432843, 1000062023, 2204271250, 3051681017, 4000123456, 5212744564, 6286420010, 7859103459, 8003306026, 9916524534 - D5 = 3299632008, 1999204293, 0399242139, 8623420004, 0001123458, 0000100084, 0000100085 - D6 = 33394, 595795, 16400501, 3615071237, 6039267013, 6039316014, 7004017653, 9002720007, 9017483524 - D7 = 0501006102, 0231307867, 0301005331, 0330034104, 0420001302, 0135638809, 0202005939, 0601006977 - D8 = 0009999999, 0100000000, 3012084101, 1062813622, 0000260986 - D9 = 6543217890, 0543216789, 1100789043, 1100914032 - 51 = 0099345678, 0099100110, 0199100040 - 57 = 5302707782, 6412121212, 1813499124, 2206735010 - 68 = 6414241, 179751314 - 73 = 0099345678, 0099100110, 0199100040, 121212, 987654321 - 74 = 1011, 26265, 18002118, 6160000024 - 80 = 0099345678, 0099100110, 0199100040 - 81 = 0099345678, 0099100110, 0199100040 - 84 = 0099345678, 0099100110, 0199100040 - 86 = 0099345678, 0099100110, 0199100040 - 87 = 0099345678, 0099100110, 0199100040 - 91 = 8840011000, 8840010000, 8840014000, 8840025000, 8840026000, 8840057000, 8840062000 - 95 = 4455667784, 1234567897, 51181008, 71214205 6414241, 179751314 - - ; B6 - 80053762 = 467310018, 9111000000 - ; B6 - 80053772 = 477310018 - ; ?? (C0) - 13051172 = 82335729, 29837521 - ; C0 - 86055462 = 0132572975, 3038752371 - -[valid] - 0 = 1600169591, 1600189151, 1800084079, 4455667784, 1234567897, 9290701, 539290858, 1501824, 1501832, 877415, 6945661, 1081034751, 1036751418, 100165075, 107147530, 111165775, 128293081, 130027014, 117069658, 1327489009, 3007405610, 188002877, 17202219, 1395490087, 6408454, 135430734, 741074, 673665, 161080007, 45572336, 7502982, 105097729, 27341080, 1382515706, 101909075, 157052416, 1205473901, 100631993, 1026313013, 20005492, 1029189261, 300036944, 166009415, 59104307, 424010, 578971, 165012022, 134447309, 1519701, 432245, 12509717, 805655, 150496917, 1022817678, 6443436, 117076737, 20131850, 43399641, 101058832, 154026751, 334664, 1011138870, 133378299, 364497, 9830951, 106726680, 72893175, 4077210, 240768507, 134013366, 155743149, 8173544, 190967, 11153392, 136253648, 551226, 2005074204, 238881, 93034403, 421321, 65615502, 7574700, 71353098, 71863419, 103042503, 109125005, 7416662, 150582500, 100624733, 1235500830, 32102774, 50084193, 106021744, 174076349, 3504255, 100049832, 100907245, 60518321, 10678670, 101902070, 135032365, 79233755, 210524385, 1032100693, 2002829808, 681403, 2737674, 139071120, 1059762755, 90332, 109153049, 5143987, 140651928, 8026098, 44161677, 190020172, 10699650, 9324997, 0032112906, 301032348, 6651137, 3307576, 124398561, 101956167, 50105865, 0114106727, 1152775092, 165013020, 118128354, 651190, 1305494021, 33104456, 109064444, 805424, 5526439, 3900404, 17346701, 1009853704, 332965, 5288683, 1278501653, 2002621601, 966895, 301039749, 59681296, 14283394, 679910, 1200292595, 240086439, 71111801, 10756690, 133349472, 8846230, 100630052, 138715594, 47233432, 620690, 7068125, 1048750440, 2003202302, 301015319, 602995, 1397462332, 0043774819, 148009764, 60406329, 101133478, 251348, 100083641, 3627064, 1166413243, 31112121, 1100018124, 107805491, 110319969, 769521, 3287141, 966689, 3007622420, 8105488, 1999515, 6100556, 138438767, 3148350, 100025709, 1281444693, 3001134703, 6100549, 425157, 43504760, 29323086, 46515441, 2001032610, 131035560, 1160878, 200223659, 145013876, 1512029735, 50045749, 1010794129, 835058, 7260284, 3187853, 121313316, 25006891, 688424, 1336459050, 107557555, 220143903, 7325137, 1050004, 89234884, 646901, 134111244, 100756055, 100043959, 1233573516, 315051540, 1238500886, 12722245, 69300945, 37585908, 613349, 60813839, 7845803, 1112213374, 4281374, 240091231, 91563197, 483404, 3119138, 8244014, 1058771302, 63144281, 145887048, 1046374, 23106420, 70078951, 411827, 22595649, 199695, 1795798, 7760861, 59110940, 117076794, 0590214789, 301000550, 719054, 1505002889, 100744382, 5680939, 542043, 38313607, 2211944, 50127091, 141332767, 10280170, 46535555, 6723563, 485755896, 135211613, 12405304, 903147817, 47235197, 711200, 683219, 783332, 620422014, 1484538846, 8099962, 161708011, 0128104320, 901219618, 21021167, 300012812, 1019763612, 591842, 33033820, 407437, 47254115, 140639220, 1034784551, 105535934, 124030131, 219018660, 5678198, 1282504925, 1100112646, 793885, 117070870, 6851984, 733113, 5057393, 0105100812, 14520118, 1000687127, 0134225697, 8724643, 127077311, 52753506, 120751268, 1352483315, 100654888, 151274362, 74233511, 5691225, 215885336, 50007723, 1043777, 2003895303, 302109954, 65495921, 2138030, 13136874, 464602, 134202654, 1397469733, 0134241199, 666677, 113414601, 1004989305, 8896847, 36228831, 209876606, 0029150471, 5030481, 2539021, 105302491, 47844964, 22053920, 5241948, 1238454696, 75952, 2193860, 2240505, 3823010, 9271842, 10661916, 637348, 1386494882, 603274, 1043762655, 30279251, 1813500, 59177535, 47457825, 2007961, 115348112, 10108124, 1011312814, 171709504, 1022790016, 4418851, 1127125, 43861434, 5779814, 7722036, 1670868, 5435623, 8749541, 1216016004, 100220854, 1052923693, 129627832, 30604664, 742338, 80143530, 1012137129, 103500534, 82733197, 760434043, 1049782558, 2167484, 51169357, 133309252, 637439, 82561721, 121234538, 1224456879, 11145596, 87134813, 80150436, 630541, 616029, 6752992, 10643161, 9435140, 22044010, 103104121, 0030658983, 333286, 13139811, 1005097983, 100197144, 2192193, 1623259734, 285643, 5959531, 102685120, 330205154, 86114667, 1247329, 5236021, 33003856, 8735987, 105507297, 19609361, 409839, 353813, 107532020, 67412486, 109435990, 7728819, 101249837, 5112065, 113476915, 117213348, 300220720, 100759158, 889733, 1636232, 904748, 15017775, 1042869956, 0160016010, 430494930, 624148, 226304616, 5526371, 1251466643, 7471469, 155072036, 2251460, 5123682, 1224506178, 360289, 1111773402, 2060127, 33299876, 334007754, 640409, 4243283, 0001173780, 170720114, 22231062, 106760457, 5018312, 3292190, 430563122, 1512033299, 1011223797, 488544, 641779, 5120605, 12570602, 0000324350, 30594576, 105014237, 228750634, 100078484, 4224473, 22731145, 174027284, 16013666, 20506986, 2277275, 120015474, 1385491970, 247841, 369231, 639005, 8620148, 104241401, 31500598, 102105145, 741769, 5116207, 130285679, 550218937, 130304306, 2542850, 269919254, 1263607, 20242418, 5333141, 36223766, 43528348, 140305061, 38564621, 135409001, 101586543, 150544906, 1100636867, 1100242328, 1006626079, 276002722, 0109101980, 919274, 614578, 431148, 0134574292, 240310698, 104140280, 149447773, 112046610, 0620217885, 1081807057, 1352498966, 50023936, 149007130, 100243765, 103235982, 642744, 4446779, 100143585, 10777712, 104981147, 103454252, 1827682, 124111667, 43225283, 249653411, 115057580, 1810662, 487306, 1046754220, 74593732, 40125494, 1234493284, 1000213676, 3485083, 107090649, 1000371292, 1398504371, 92013820, 107119992, 23650781, 8723546, 178183893, 5219662, 101060390, 1301514, 48479869, 134581826, 1512813, 57542169, 0017185273, 100696251, 161004635, 1059789840, 112180450, 380614420, 2933125, 134251644, 3743465, 11415270, 100720374, 104350111, 1000444446, 291148161, 44323871, 724302, 7261290, 22443337, 1044953659, 1139793036, 1502129, 102305265, 124643107, 1165315, 44389385, 111163325, 25634858, 16026320, 111048682, 7130065, 27643063, 1247461542, 170104616, 1550025017, 309000867, 137316246, 43753318, 8060873, 101543379, 78253176, 12265658, 52108610, 57273633, 20535969, 68568039, 760975, 9233081, 11283702, 5515812, 50139831, 854406, 100195544, 454413, 1268512900, 430780536, 667022, 100094382, 18507426, 630434, 201076676, 10337046, 105214316, 133923086, 22053730, 7541337, 129208716, 1206317, 5108402, 130009285, 100483031, 620997, 143147536, 14033138, 1060012414, 6145643, 647339, 47017868, 9370511, 110322468, 1242470613, 8395212, 565697, 41921, 10859296, 832196, 109677245, 735423, 663799, 1216519767, 7249444, 157003591, 1015827148, 4497921, 20154985, 31453186, 240994699, 10575124, 28107464, 0064608540, 194018479, 122202369, 791095, 122802390, 13017132, 47224027, 16026528, 1051782363, 512657, 573691, 1717222, 353001274, 314024670, 2890929, 20511770, 561563, 500178470, 55119754, 357913, 145114831, 47174248, 100683424, 747998, 45103504, 4129490, 0008192007, 105541767, 1266470861, 7140858, 134147693, 1423813, 41532045, 1009183276, 2159846, 33449, 240431403, 380843912, 335009247, 158501, 140021197, 380833608, 90140039, 162037733, 100610344, 10291177, 111199279, 9204967, 5993951, 43906320, 1870179, 1129790, 1015819939, 913707, 1386474413, 290056506, 35118850, 103393955, 106232762, 710301, 100091511, 1043741816, 4520052, 3621182, 080167497, 2698595, 198024267, 1560101782, 50297449, 11132743, 1133822898, 120026695, 130331184, 5610126, 2052587, 299099, 2095602, 1300066899, 283895, 15727, 244729505, 48006993, 1012840706, 2007458, 380414870, 6254189, 1077781761, 943928, 741496, 1554658, 1750529941, 307043653, 60601861, 370068256, 5304118, 102142148, 129416723, 124101932, 769364, 5658687, 5341557, 1247450537, 110104874, 52955119, 1087779706, 215006131, 5973722, 129929485, 23427602, 3160538, 102070778, 47523170, 8552580, 4178570, 110030590, 675801, 570611681, 363945, 2206068, 901124792, 100218197, 0164033557, 18201780, 204478143, 18568683 - 1 = 805134315, 560047950, 993007, 10203567, 3234938, 110450911, 930060543, 28105413, 118014957, 113069, 658830, 1928693, 969419, 5023109, 781879, 3757707, 48298599, 48298434, 5547159, 79024598, 1410565, 9766864, 718079, 1323456, 7820035928, 9792780, 6818100, 3697283, 10092747, 3854930, 8701497, 8167770, 131429, 8152266, 210931, 1794717, 407665, 745420, 2069733, 7817001288, 2434375, 10003468, 1728972, 9155138, 7850004503, 34115796, 21153833, 400154680, 5035135, 3920936, 7808006261, 15069225, 48519319, 715058, 7257519, 2204505, 11431431, 800097402, 48069182, 3734775, 3128264, 2746654, 2166997, 717544, 48288925, 1068106, 8321619, 6309035, 1895984, 8097479, 15129983, 675909, 7307005, 2854759, 5535408, 120193, 20407456, 11549608, 400257769, 36110926, 440696483, 2038654, 2701651, 3441855, 2288318, 687052, 757968, 613765, 1713750, 520020663, 7700396, 2669377, 440005517, 650005558, 7894005393, 1409095, 11375047, 2602097, 6448460, 6402925, 2118299, 314181, 203261, 7855006269, 11105372, 11534974, 0019191924, 5253285, 10006630, 785710, 2202703, 3092716, 0049510771, 3360046, 1452183, 970323226, 227003, 7676334, 6026662, 8207764, 10118607, 3829130, 5302710, 3739732, 11011583, 2015639, 872180, 2157731, 8517083, 8575805, 8220806, 5773349, 5289424, 5833588, 110073075, 43107290, 6271527, 11610616, 111042854, 6404538, 7870026509, 7487014533, 79225878, 798305, 746395, 11506713, 11179274, 680034142, 2660792, 757614, 6247111, 2144201, 725938, 5334764, 7895008588, 0012003624, 20459772, 368883, 2645432, 3240379, 7932085, 10331453, 111039922, 7502635, 2168476, 8388920, 10600933, 1943465, 5249457, 2711098, 10902246, 2155984, 158048, 26084 - 2 = 837547, 1207253, 228036623, 281042020, 206110073 - 3 = 11091519, 10556853, 1324235, 10583749, 10627894, 18512188, 21045481, 10310431, 10311421, 10309905, 21265980, 16081482, 21019866, 171066238, 29516145, 201061140, 10635582, 3524411, 10061406, 10180769, 0011578088, 10530419, 10295401, 91204231, 88900850, 0001552183, 16075071 - 4 = 132102120, 101123944, 121089335, 285024684, 26038154, 189055382, 509017468, 100074389, 1004626229, 452424, 129030054, 258133560, 170109716, 112054960, 118058925, 106215383, 112020500, 135011479, 483110731, 138040461, 0132055440, 120039954, 352194565, 120069004, 461095011, 100272431, 183001213 - 5 = 1243105910, 1143002210, 1190015933, 707332, 1119059815, 1334003727, 1252001199, 1151024604, 715450, 1143020991, 1000158676, 1204112751, 1133076023, 1000155103, 1203108096, 74451368, 1325042959, 1191050683, 1205017813, 1395136604, 20602488, 1122020909, 1000232770 - 6 = 94012341, 5073321010, 397806, 22073001, 464958657, 10038219, 60006059, 7504535015, 18050714, 102123921, 21525308, 2838010, 1011056489, 33103409, 3320502, 26129400, 22550608, 4401416736, 3806419000, 102094816, 6011306, 21287008, 2434709, 800693012, 1000141077, 6889719000, 6306209, 30093801, 71466019, 3684954, 5500226015, 110596600, 9082107, 1110016782, 139098609, 10391741, 5582407, 3608074014, 7101991002, 140933007, 472028030, 1010017900, 4273366011, 76138125, 4366018, 33439377, 31143306, 6715561008, 1070019317, 600449010, 108053429, 162099949, 5263530, 912049876, 4369939, 70004755, 102115783, 4194446, 65448017, 167522807, 4805013007, 126229402, 4217071904, 455643694, 63961906, 1104002621, 5910849001, 1505051013, 150204402, 1005719018, 0076940576, 1151022525, 4833333, 132491909, 14179704, 502350013, 1202318025, 20009578, 870501, 101981908, 77373608, 1658565, 932062453, 868108, 11731317, 2501392017, 604534011, 4398408, 129115408, 5395704, 1445308, 4030490202, 0822132146, 4286502, 212123153, 8705406007, 3901322006, 3574512, 7016101006, 1306812, 75034202, 22184202, 78411910, 2206102, 37082805, 1404594016, 1007510019, 704151012, 763608, 1004455017, 300257488, 3027527018, 2300528018, 70959003, 33276591, 402626020, 1557750, 7800903003, 6205208, 54785208, 5847010, 0151014615, 454761, 38005642, 1017551007, 2700165011, 6194605, 148015120, 1401197016, 3084786003, 12128800, 5948188009, 23605600, 1012057918, 113087005, 7022656001, 1017984000, 4563492, 3611790200, 3301012011, 316025803, 5110904, 400978344, 4031242300, 15253401, 2420600, 5071411003, 195502, 74157920, 2103064018, 0136091204, 12036701, 032017711, 1160016996, 2406608, 4190203, 753084, 142081059, 1440553024, 3190874000, 7168541001, 60789401, 3500818017, 3151468, 352029106, 5203248018, 315508, 107794018, 1000401621, 501905, 2200194015, 481742, 18090171, 7029259008, 11312012, 58451304, 4007409, 100677580, 107743103, 37098302, 1305964014, 201677009, 106269807, 704903, 122009440, 10987, 7042509005, 1070908, 60010501, 1002002694, 42912808, 9602494036, 3380009, 1604360010, 10041007, 38121405, 38105, 21221805, 4543378, 5417939000, 707104, 6014607, 2657406, 6406300, 60561702, 34222665, 7018052002, 442087725, 302284016, 22208802, 2087715, 8214910200, 151327, 124058384, 33250266, 7087604009, 3081702, 2009420, 17600010, 700894010, 102029305, 1011058627, 202102301, 106036080, 11142907, 0332061151, 20095601, 79118508, 1000076917, 120313100, 64132407, 5220009 - 7 = 114082618, 100529704, 100521509 - 9 = 1542321, 851194900, 363935500, 3012082935, 2825252001, 348754, 076187, 0601803230, 1501525610, 5344401, 1716002, 0827910430, 13263033, 289388600, 534684, 532061, 1500807210, 0365090255, 0224032555, 0010487098, 0603545730 - A0 = 521003287, 54500, 3287, 18761, 28290 - A1 = 0010030005, 0010030997, 1010030054 - A2 = 3456789019, 5678901231, 6789012348, 3456789012, 461954, 215108716, 170017107, 100059583, 111017588, 118010529 - A3 = 1234567897, 0123456782, 9876543210, 1234567890, 0123456789, 134164664, 14490706, 22943145, 139011761, 107341166, 30181232, 12835781, 1142995800, 119284073, 1155783002, 22721142, 103338646, 106300569, 15895793, 16474511, 2110641665, 111354734, 12106810, 18952178, 29804108 - A4 = 0004711173, 0007093330, 0004711172, 0007093335, 1199503010, 8499421235, 0000862342, 8997710000, 0664040000, 0000905844, 5030101099, 0001123458, 1299503117 - A5 = 9941510001, 9961230019, 9380027210, 9932290910, 0000251437, 0007948344, 0000159590, 0000051640, 750176844 - A6 = 800048548, 0855000014, 17, 55300030, 150178033, 600003555, 900291823 - A7 = 19010008, 19010438, 19010660, 19010876, 209010892 - A8 = 7436661, 7436670, 1359100, 3199500501, 7436660, 7436678, 3388344, 2812584, 6906028, 8911428, 5177022, 7015798, 3066045, 5645956, 3173283, 3560279, 3464075, 3122972, 3503398, 1340967, 199100002, 199100004, 2599100003, 3199204090 - A9 = 5043608, 86725, 504360, 822035, 32577083, 5114348, 87700 - B0 = 1197423162, 1197423460, 1000000606, 1000000406, 1035791538, 1126939724 - B1 = 1434253150, 2746315471, 7414398260, 8347251693 - B2 = 0020012357, 0080012345, 0926801910, 1002345674, 8000990054, 9000481805, 21086079, 23006358, 21284318 - B3 = 1000000060, 140, 19, 1002798417, 8409915001, 9635000101, 9730200100 - B4 = 9941510001, 9961230019, 9380027210, 9932290910, 251437, 7948344, 51640 - B5 = 0123456782, 0130098767, 1045000252, 0159006955, 2000123451, 1151043216, 9000939033 - B6 = 9110000000, 0269876545 - B7 = 0700001529, 0730000019, 0001001008, 0001057887, 0001007222, 0810011825, 0800107653, 0005922372 - B8 = 0734192657, 6932875274, 3145863029, 2938692523, 5432198760, 9070873333 - B9 = 87920187, 41203755, 81069577, 61287958, 58467232, 7125633, 1253657, 4353631 - C1 = 0446786040, 0478046940, 0701625830, 0701625840, 0882095630, 5432112349, 5543223456, 5654334563, 5765445670, 5876556788 - C2 = 2394871426, 4218461950, 7352569148, 5127485166, 8738142564 - C3 = 9294182, 4431276, 19919, 9000420530, 9000010006, 9000577650 - C4 = 0000000019, 0000292932, 0000094455, 9000420530, 9000010006, 9000577650 - C5 = 0000301168, 0000302554, 0300020050, 0300566000, 1000061378, 1000061412, 4450164064, 4863476104, 5000000028, 5000000391, 6450008149, 6800001016, 9000100012, 9000210017, 3060188103, 3070402023 - C6 = 0000065516, 0203178249, 1031405209, 1082012201, 2003455189, 2004001016, 3110150986, 3068459207, 5035105948, 5286102149, 6028426119, 6861001755, 7008199027, 7002000023, 7000202027, 9000430223, 9000781153 - C7 = 3500022, 38150900, 600103660, 39101181, 94012341, 5073321010 - C8 = 3456789019, 5678901231, 3456789012, 0022007130, 0123456789, 0552071285 - C9 = 3456789019, 5678901231, 0123456789 - D0 = 6100272324, 6100273479, 5700000000, 5710000000, 5799999999 - D1 = 0082012203, 1452683581, 2129642505, 3002000027, 4230001407, 5000065514, 6001526215, 9000430223 - D2 = 51181008, 71214205, 4455667784, 1234567897, 189912137, 235308215 - D3 = 1600169591, 1600189151, 1800084079, 6019937007, 6021354007, 6030642006 - D4 = 1112048219, 2024601814, 3000005012, 4143406984, 5926485111, 6286304975, 7900256617, 8102228628, 9002364588 - D5 = 0000100062, 0000100088, 0004711172, 0007093335, 0004711173, 0007093330, 0000127787, 5999718138, 1799222116, 0099632004 - D6 = 3409, 585327, 1650513, 3601671056, 4402001046, 6100268241, 7001000681, 9000111105, 9001291005 - D7 = 0500018205, 0230103715, 0301000434, 0330035104, 0420001202, 0134637709, 0201005939, 0602006999 - D8 = 0010000000, 0010000001, 0099999998, 0099999999, 1403414848, 6800000439, 6899999954 - D9 = 1234567897, 0123456782, 9876543210, 1234567890, 0123456789, 1100132044, 1100669030 - 10 = 12345008, 87654008, 31251005, 86504002, 3157008, 34247009, 0672453002, 82319006, 405221, 370509005, 2190869, 65383206, 31741002, 4927397, 25168177, 624107000, 41683005, 8783004, 2740001, 302329005, 0013702017, 146468007, 141508108, 274018004, 61007404, 46199004, 0013711008, 4064224, 59083000, 255658001, 28396006, 452586003, 209611006, 1066889, 132623005, 71089004, 7219008, 172570000, 382813006, 81424000, 58583009, 653792000, 71934006, 29342007, 434894001, 139350004, 74509004, 110145003, 69748004, 77823001, 62248502, 65421000, 431361002, 7305001, 0011313005, 114126003, 63919001, 62320009, 13692003, 66933005, 100919200, 1249754, 268100, 67427006, 50018906, 77126009, 58032002, 85355003, 141401001, 15977005, 32710011, 30177383, 14088002, 104064005, 72769009, 115634002, 34409009, 183699009, 2055007, 21564000, 0709427000, 93107501, 36757004, 4322740006, 265281008, 88279707, 344455009, 341294004, 62162004 - 11 = 769010, 5661730, 3059227, 7761619, 7547927 - 13 = 2220267, 8107260, 1159656, 3301736, 180449101, 6824817, 2519056600, 1311521, 2675906200, 6815211, 887051100, 2476822200, 2928208, 1495035, 0008107260, 2803120, 8020083, 61895598, 5020946, 8018129, 7103260, 4440400, 8962060, 2737450, 6739064, 3319423, 420499600, 2923239800, 3992781, 7253032, 0247387, 1058056, 640575700, 3150679, 2781243, 1182468, 2456073600, 3004058, 2722320, 2872984, 2014660, 7455223, 6333868, 8913790, 2199099, 2602258, 6101851, 5272943, 8255754, 871638301, 6189559, 2586066300, 5262282, 1055292, 1039767, 7682065, 8844011, 1002054, 7013998, 2758889000, 1201375, 5715966, 8674285, 4301313, 4528493, 1194398, 5637707, 363743600, 800317000, 291176600, 458348000, 5712369, 0225524, 6412365, 8983447, 2035269000, 8327694, 2628892200, 2609531900, 1934264, 2915288, 6402671, 2052828100, 2053809, 183613900, 8279374, 5885082, 5502448, 2120061, 6557557, 6284244, 2501728000, 360460001, 1503861, 654143700, 1258318, 300574100, 3409083, 2762219, 1005628, 2205524, 1268275, 2007763, 2510678600, 4261285, 7307630, 3610011, 4500435, 8491714, 3657020, 7396302, 2226579, 414410102, 169622800, 1049568, 7917495, 142400100, 6183636, 2107597, 1615384, 1501055, 2332294, 8656654, 1413574 - 14 = 0105451078, 0301360175, 0005534550, 0102385015, 0002212269, 0005405858 - 17 = 0446786040 - 19 = 0240334000, 0200520016 - 20 = 2105426096, 1770007225, 1640002142, 1600040434, 2623445373, 120044099, 4017076870, 1112141061, 4611022329, 1384012946, 1560027149, 4616000854, 4504025855, 930220650, 970106041, 2020173223, 4074027998, 1800081215, 1801587961, 4050029788, 480891508, 1210424386, 1000288044, 1370017720, 1210444506, 1440102879, 4111124548, 479381, 4011104871, 4000078416, 1455022361, 4134472240, 1450118832, 4134486896, 4010033245, 1642902205, 4709008839, 2334006796, 320321924, 574805036, 1800887937, 4521024268, 4000120463, 1320002834, 4000009449, 1800277241, 1320244773, 1220039973, 1420186740, 4120172525, 114013560, 4516061002, 4020393996, 4550132634, 4509009300, 1231080236, 0104029366, 2159902, 730014240, 230253873, 780125037, 1220128160, 1801244940, 54514800, 1369725, 4521015633, 4110254243, 1240147500, 4532004433, 1525023892, 1700189260, 2194929749, 1440116306, 4210070896, 1440255519, 1000162962, 4134457470, 104029633, 4040119059, 4150092520, 1899325, 1180020266, 1010201480, 4120581727, 1450066506, 2322323, 1770003149, 1490182744, 1800858686, 4517017260, 1205186871, 1220132523, 1120106911, 1654694769, 4000514887, 4001159169, 1320019990, 1220251492, 2060200442, 640272290, 240293274, 2623714, 1704007417, 4110265164, 2303032698, 4000665222, 1000110709, 4043081630, 1795109285, 240370147, 1878755486, 940165139, 1564041421, 1801802145, 4573023866, 1040114438, 1160163274, 4000780242, 4611018860, 4002288760, 44412827, 8055335, 4538017561, 1231085270, 1802124094, 2334024638, 1320084253, 2030269606, 2804376802, 1800813658, 1210254677, 310192048, 2639092, 810392216, 310284317, 54547881, 4505017864, 1360159289, 1420025844, 2194924089, 320335895, 1520054455, 1714079690, 4134477781, 240317220, 181026384, 2325640, 2301484389, 4329021167, 54518890, 4506021067, 1273426, 4211162638, 4074018794, 170154270, 1420005622, 4081029577, 824305, 4134478788, 4814031187, 4810013486, 1154257, 4740039686, 1130170400, 4046047734, 2101438910, 1010131024, 4116181949, 4110268384, 1410142732, 4000014523, 0544531612, 1100016011, 610113003, 1705150698, 4000873780, 4505059532, 4124535177, 820158089, 990356221, 1400032837, 4636004502 - 21 = 1003000905 - 24 = 138301, 1306118605, 3307118608, 9307118603, 872698209, 294453309, 400435609, 429603103, 395379808, 250957205, 523324465, 312990467, 382158757, 163663707, 893849100, 420549466, 541037309, 0674808207, 0924938309, 376977706, 769190208, 317000302, 397829304, 391181603, 477489500, 822181103, 37508101, 128062504, 656888800, 594760436, 335891752, 223608502, 707906603, 289996202, 689825603, 853913605, 380945509, 817070108, 221590752, 19930102, 20722857, 393451100, 97325461, 172260109, 428720804, 396143755, 222634101, 658759801, 924004808, 370155702, 149072705, 159847662, 679178803, 619757433, 661216804, 506077201, 862839201, 875801858, 948020200, 994574203, 615312806, 609110807, 636860205, 245559463, 354485809, 172733703, 478534602, 75355664, 225190902, 615669100, 0259545855, 351588305, 621493462, 489812106, 476474805, 58033469, 549391804, 857366204, 243892469, 935340904, 643090307, 871362908, 211454501, 883517467, 358419756, 682845800, 87347466, 630364305, 549458463, 0054539709, 371201755, 161217609, 104314104, 373120600, 15784605, 612677805, 245570906, 189685304, 535455805, 881293200, 512418804, 620882307, 12012805, 826645800, 407944107, 972353801, 623310806, 2654808, 619987466, 0484872103, 642856201, 6654802, 962622805, 919329609, 938127804, 341082808, 942404205, 207866608, 891832433, 567307467, 995556208, 696038306, 808330206, 687280608, 836159809, 961883807, 367494465, 147889708, 266106306, 858630208, 868388461, 857088677, 0303960501, 574440461, 641340801, 252751203, 470512207, 536429309, 0008312466, 932805200, 773147304, 507396309 - 25 = 521382181, 201189283, 215160754, 260322814 - 26 = 0520309001, 1111118111, 0005501024 - 27 = 2847169488, 105478820, 24022022, 6438071, 7234313, 2417855, 2529915, 1998640, 3436169, 2288363, 8348336, 1026251, 311068, 6506448, 1168228, 2949741 - 28 = 19999000, 9130000201, 14180100, 90051600, 86817500, 81972700, 207806600, 16062800, 1003320300, 14701000, 4202778000, 128460600, 109083600, 3000134000, 25712500, 13962900, 281545100, 802350600, 1025100, 31672500, 94383500, 356055400, 500076900, 706799200, 2613786000, 704899800, 417539500, 146438800, 11172400, 134365300, 4804373700, 1300379800, 185539500, 712864900, 4804141600, 32767000, 422851000, 965291400, 108927700, 120234000, 12161400, 30037300, 1701922200, 1500945900, 1301472200 - 29 = 3145863029 - 31 = 0263160165, 1000000524, 1000000583 - 32 = 747564, 9141405, 1709107983, 0122116979, 0121114867, 9030101192, 9245500460, 157260, 413640, 4389670, 2738252, 6190, 17191, 2480794, 2466570, 3573060, 2213060, 2002124, 6818501, 457442, 7380119, 5822181, 4629124, 2142562, 3009807, 4027000, 200070947, 5412200, 72621, 4557298, 536938, 128821, 1113402, 27944, 2551918, 4256484, 405868, 1408518, 4793706, 5028256, 4028554, 232254, 4575288, 6020879, 8637725, 5870488, 5944724, 7909497, 40215, 26930, 5951917, 4046463, 3024547, 12610, 39772, 44644, 4610202, 4328663, 2034069, 72699, 100133361, 2721155, 5534348, 82872, 4517385, 43583, 24384, 611050, 8286035, 4840151, 3945138, 2872269, 1870181 - 33 = 48658, 84956, 76058, 388874, 414603, 243604 - 34 = 9913000700, 9914001000, 5021301200, 5226472900, 2267965900, 5155223500, 69111201, 109522400, 23269600, 4100063000, 10395800, 2197900, 8556900, 5547400, 24680119, 3604813700, 25998701, 1719500, 8703609900, 8805374700, 4019966700, 87344200, 1402578600, 91230900, 17733200, 61681700, 4484700, 1102503503, 657944700, 300457600, 110375700, 912976700, 704449500, 2205169300, 1303805900, 67255200, 4556700, 6102129400, 6003572300, 8740184200, 62232801, 462687900, 51010701, 44289600, 831599801, 428759800, 108128700, 6159335600, 751781100, 151497800, 2385868300, 5801714701, 255603700, 211211000, 3302596800, 7666200, 17223211 - 35 = 108443, 101599, 107451, 102921, 102349, 101709 - 36 = 113178, 146666 - 37 = 624315, 632500 - 38 = 191919, 1100660, 915024, 1938842, 2376159, 302519, 1128073, 1307258, 1009082, 1609627 - 39 = 200205, 10019400 - 40 = 1258345, 3231963, 6215820003 - 41 = 4013410024, 4016660195, 0166805317, 4019310079, 4019340829, 4019151002 - 42 = 59498, 59510 - 43 = 6135244, 9516893476, 2033552 - 44 = 889006, 2618040504 - 45 = 3545343232, 4013410024, 0994681254, 0000012340, 1000199999, 0100114240 - 46 = 0235468612, 0837890901, 1041447600 - 47 = 1018000, 1003554450 - 48 = 93703660, 2959730 - 49 = 4152679, 4928024, 1826128, 1121799, 190388439, 3374520, 1444160, 2195865, 3278482 - 50 = 4000005001, 4444442001, 6144837000, 5850797000, 6142451000 - 51 = 0001156071, 0001156136, 0000156078, 0000156071, 3199500501, 0199100002, 0099100010, 2599100002, 0199100004, 2599100003, 3199204090, 592242, 164670, 270350, 458966 - 54 = 4964137395, 4900010987 - 56 = 0290545005, 9718304037 - 57 = 7500021766, 9400001734, 7800028282, 8100244186, 7777778800, 5001050352, 5045090090, 1909700805, 0105781645, 0203861428, 1209752022, 1509701720, 0610784275, 0803732716, 2410781111, 0802713267, 2208483021, 1702772364, 1004731551, 2802752203, 1702770213, 2910751345, 3101752218, 0408720610, 2901554056, 2811722469, 3007762732, 1801810233, 3003711345, 0405542767, 1506801596, 1609751400, 1407781403, 0208762720, 0112762973, 0804841115, 1805761311, 1204762751, 2603784092, 1412720611, 2210811386, 2204762175, 1706812524, 0508750313, 1907791678, 1906721722, 2908752583, 0210772314, 1110742116, 1201760575, 1711764016, 2204840420, 0905712134, 2911792113, 2205812216, 1105812120, 2901784132, 3251080371, 3891234567, 9322111030, 2804540670 - 58 = 1800293377, 180881120, 9200654108, 1015222224, 3703169668, 1000870595 - 59 = 115075806, 110105152 - 61 = 2063099200, 0260760481, 0260760282, 7806114000, 1146720600 - 62 = 5029076701 - 63 = 123456600, 0001234566, 1331537, 4938494, 167908, 7721244, 5518816, 503458, 830307, 2714202, 0200196, 268515400, 1756006, 0781831, 1079318, 7850134, 4079059, 3505708, 549157600, 5461587, 0231720, 971982400, 875344, 0322982, 6710750, 1038538, 3722410, 0912642, 8736779, 1094846, 5609581, 4301842, 0257063, 1488493, 6018774, 0433243, 3201076, 5441407, 7669807, 1720176, 5726963, 9974601, 0226555, 2421618, 5425483, 3742186, 9777228, 2081693, 348160300, 1543271, 3513132, 284753100, 5080510, 4687786, 3020757, 2114650, 0100230, 7602394, 5000849, 1267970, 3035292, 1214535, 1095843, 0173948, 040766800, 5861901, 2243178, 0341222, 2021764, 4441622, 3779238, 2043255, 7004690, 0516369, 5014600, 0630541, 6373492, 4517736, 0195123, 0477927, 4106712, 3237625, 5052360, 1195718, 4397790, 492134200, 8911299, 0272476, 654272400, 3076072, 3946829, 0282194, 9838244, 2750578, 4000808, 382011501, 8606568, 0400572, 2000263, 7046014, 0806786, 0473876, 3991031, 2385631, 1416288, 1561067, 2224533, 1741115, 8003998, 1857523, 1743855, 0260653, 6399653, 6409015, 7133101, 4816542, 075023200, 6911648, 6310692, 953647500, 446031700, 0150870, 4381604, 4474573, 9185737, 5019336, 0382390, 1305457, 2504660, 1564897, 0149955, 0853093, 2440071, 8832701, 2015741, 5415484, 0522268, 4904413, 1335355, 2222883, 0323535, 8041378, 2768208, 105405500, 020725800, 0145862, 3024387, 2343788, 033075301, 0409060, 4001152, 6465744, 5386792, 032341001, 200882900, 4792560, 2352573, 5434709, 2435600, 5137534, 1810621, 4679429, 1453216, 199577800, 2108033, 3980224, 8015208, 0308015, 0222380, 0303016, 5019211, 9540774, 8038523, 0411421, 183688100, 2137552, 0506758, 2242717, 400635900, 2512929, 989686100, 1028273, 0858688, 1216266, 7839293, 5104070, 7580012, 173605700, 0100206, 1335587, 0122135, 030367701, 7414402, 1214527, 5379367, 2130953, 8500555, 1587401, 0496273, 3172269, 7012297, 8816498, 8898389, 518427000, 684461700, 1053198, 5183710, 4255410, 3390010, 0119008, 3466521, 0602656, 4623245, 2038222, 0356758, 3015773, 781787700, 2523793, 0715417, 339102600, 8765711, 6606024, 6101331, 3945037, 376629200, 0521666, 6648802, 419723200, 0250936, 0312439, 3029766, 0709568, 520717000, 4111068, 3900388, 1238765, 0162065, 5916226, 4389698, 1941723, 8415432, 5051719, 1993898, 629314600, 5085204, 0245811, 7931926, 0210666, 1919588, 2303253, 1268044, 4009684, 0415372, 2813095, 0187823, 0432575, 5402177, 7367204, 3510849, 0156265, 0123927, 0131185, 0916445, 297518300, 0823419, 0246579, 8317349, 212612600, 2116127, 3900628, 1231315, 9167172, 126598200, 1239797, 1716026, 0430629, 0115055, 6082515, 025168600, 127129500, 6648349, 1130194, 6687628, 8446908, 0323410, 4212205, 1212877, 3206083, 3838000, 5605993, 0966663, 0208405, 3916293, 0223537, 1076710, 1301407, 445628100, 6472518, 0401943, 0401273, 0520486, 5146360, 6418735, 0444638, 015414600, 6967103, 4608105, 6967715, 1977206, 8002966, 3380243, 3912441, 2885325, 3228889, 4757076, 6072599, 7241896, 0001869791, 8174344, 4914123, 4472700, 6342208, 7591902, 7124746, 606530400, 2051357, 12305900, 271161200, 364094300, 140763400, 0750752, 1801661, 6018022, 4383501, 3631231, 5040928, 4999918, 0330183, 3214384, 0900019, 200019800, 010645000, 3985082, 4905857, 6301469, 3127594, 4662078, 1134345, 1134675, 0252247, 1225911, 0324376, 3588928, 0342451, 2515641, 0541698, 4303913, 1750017, 1841907, 2776011, 0138271, 5214564, 0366633, 0134312, 4750212, 3614401, 4017067, 0232140, 3743978, 2817369, 6609689, 0325191, 1011071, 8563553, 700305600, 4512505, 5710678, 2777076, 0177840, 9530908, 0403493, 8988149, 1991017, 651866600, 516460300, 6428684, 0979864, 0611798, 740613500, 3947322, 1992015, 7758808, 9636499, 5364823, 0511535, 5064159, 1164359, 0169631, 166180000, 6002349, 0212092, 0304345, 3807401, 1722834, 2439594, 012280400, 6229231, 3260759, 2506210, 1013887, 3220050, 141742700, 9616046, 3580487, 0291864, 501471700, 2717932, 4254181, 5729553, 0188037 - 64 = 1206473010, 5016511020, 7129309000 - 65 = 1234567400, 1234567590 - 66 = 100150502, 100154508, 101154508, 100154516, 101154516 - 68 = 51181008, 71214205, 8889654328, 987654324, 987654328, 2056760, 8606147, 19807727, 63206300, 71240804, 2011740, 412718, 6210801, 5030817, 76545806, 8406316, 53101527, 7322472, 7922792, 5477724, 6743173 - 69 = 9721134869, 1234567900, 1234567006, 0192735300, 4633049600, 6820735200, 3429127000, 9993327600, 2676152100 - 70 = 6790160566 - 71 = 7101234007 - 73 = 3503398, 3503391, 3503392, 7899100003, 0003503398, 0199100002, 0099100010, 2599100002, 0199100004, 2599100003, 3199204090, 3157179, 4356770, 1340966, 1340967, 1340968 - 74 = 1016, 26260, 242243, 242248, 18002113, 1821200043, 239314, 239319, 16139552, 2166429, 2180800, 23162183, 2191583, 25342700, 21156690, 19188812, 2212686, 11183027, 21164306, 12150645, 24158198, 29250677, 3126166 - 76 = 0012345600, 0000123456, 0006543200, 9012345600, 7876543100, 105873300, 0568021900, 276322900, 0229277400, 683597100, 192650000, 829419700, 0508685100, 0636079800, 0711523400, 0626028700, 0189463800, 8414580, 4545908400, 0172758800, 0848425900, 0170935500, 0113304400, 4301338800, 0607777800, 0591994000, 0120566300, 0890570800, 0587902400, 0582180000, 0961376600, 0465112100, 0671404300, 564428800, 0479894600, 0360341600, 0443942900, 0362792500, 0210575500, 0125787000, 0355884800, 4274556200, 0382556500, 262121600, 475407400, 0283431500, 0104328600, 257924800, 0330385800, 827270000, 4039882200, 0550006000, 0580959900, 05809599, 0622059900, 4366681500, 132511500, 0100800600, 0934153500, 0543222400, 0527717600, 0910652200, 752765200, 0497179600, 0521968100, 0572497100, 600201800, 720670700, 0196647900, 6123004, 0601755100, 0887238700, 591024900, 0770541400, 0923303900, 0304816000, 755343200, 4170214200, 0376111300, 0412751100, 0300691800, 0474515200, 0702319400, 06915620, 0770751400, 0377432600, 0601346600, 0834822400, 500126200, 4366759500, 0112634900, 0661830300, 0586390900, 0450002700, 4013888500, 0208896400, 0307135200, 0601782400, 631049700, 758549400, 818739300, 0198032400, 0540112400, 0128125200, 0463287400, 0615188700, 0722974400, 0242439300, 703070800, 0921624800, 0595377700, 0442018400, 0128706000, 0402954900, 4096323900, 0104860000, 0738194300, 4041862600, 0932650900, 120240600, 0550423500, 0803082000, 0601711300, 0192100900, 0231661400, 4093425200, 0275041700, 0423584800, 0584789800, 0949667100, 0452113400, 380269300, 0755268300, 0217797300, 0705479800, 0644103800, 0719079700, 300634700, 0121637500, 979219300, 616217400, 6531994 - 77 = 0000054321, 0000047671, 10338, 13844, 69258 - 78 = 7581499, 9999999981, 2268316, 5083688, 5561311, 8707069, 2431302, 2516888, 4334181, 2418697, 6573331, 8920555, 2443018, 4629739, 8717050 - 79 = 3230012688, 9011200140, 5440001898, 6330001063, 7000149349, 8000003577, 1550167850 - 80 = 340968, 340966, 3199500501, 0199100002, 0099100010, 2599100002, 0199100004, 2599100003, 3199204090 - 81 = 0646440, 1359100, 3199500501, 0199100002, 0099100010, 2599100002, 0199100004, 2599100003, 3199204090, 7296770, 7491751, 100587427, 7033249, 7117663, 7023650, 526800, 467405, 2636310, 3524450, 1114000, 7168802, 1105027, 2369010, 300900, 544825, 2656370, 7568231, 7622090, 960306, 7612192 - 82 = 123897, 3199500501 - 83 = 0001156071, 0001156136, 0000156078, 0000156071, 0099100002 - 84 = 100005, 393814, 950360, 3199500501, 0199100002, 0099100010, 2599100002, 0199100004, 2599100003, 3199204090, 634484, 371394, 506869, 703176, 197284 - 85 = 0001156071, 0001156136, 0000156078, 0000156071, 3199100002, 316764, 0326816 - 86 = 123897, 340968, 1001171, 1009588, 3199500501, 340960, 0199100002, 0099100010, 2599100002, 0199100004, 2599100003, 3199204090, 1136845, 946150, 972323, 833371, 1293406 - 87 = 406, 51768, 10701590, 10720185, 100005, 393814, 950360, 3199500501, 0199100002, 0099100010, 2599100002, 0199100004, 2599100003, 3199204090, 2266057, 223175, 3186646, 1311349, 34715, 542655, 3011810, 1298310, 973356, 3467504 - 88 = 2525259, 1000500, 90013000, 92525253, 99913003, 16284, 100263036, 89060, 227897, 582840, 78239, 303674, 3302989, 2628910, 7174918, 1694219, 929913, 4840968, 222348, 5729114, 923222, 3227103, 1057162, 126314, 50741, 818526, 1112, 27146, 320897, 5916941, 7178441, 66877, 1807323, 3221016, 72222, 4207289, 9710213, 40100, 6124593, 707899, 32700, 5195039, 152846, 727610, 483192, 100007960, 3501523, 2680696, 1064827, 3241599, 3603377, 2704900, 1825526, 1069080, 363910, 7425511, 317098, 179426, 319988, 1431188, 1202090, 704890, 614491, 11410, 67067, 119890, 37834, 1073796, 1807536, 36765, 2807220, 215490, 2569906, 1920103, 1190571, 2508508 - 89 = 1098506, 32028008, 218433000, 507072006, 254024009 - 90 = 982507293, 0001156136, 0000156132, 0000156071, 0001156132, 0000156073, 0000156077, 0099100002, 3921000, 259413, 0006073093, 737577, 4569164, 3140482, 2451050, 415176, 2426013 - 91 = 2974117000, 5281770000, 8840012000, 8840019000, 8840050000, 8840055000, 8840087000, 8840045000, 8840080000, 9952812000 - 92 = 4129654921, 4139507456, 4079604146, 4239680359, 4349555862, 4069613759, 4069634518, 4239653647, 4149555848, 4359725290, 4149578179 - 93 = 6714790000, 0000671479, 1277830000, 0000127783, 1277910000, 0000127791, 3067540000, 0000306754 - 94 = 6782533003 - 95 = 0068007003, 0847321750, 6450060494, 6454000003, 657550590, 3180376878, 5800607576, 6340241892, 6130421618, 48256538, 6410681216, 5300100, 658311255, 4320265385, 38794531, 46599730, 33739966, 659110580, 2594811, 34239185, 45333655, 44212463, 654502633, 43917056, 189912137, 235308215 - 96 = 0000254100, 9421000009, 0000000208, 0101115152, 0301204301, 1251705004, 388816198, 1201255242, 345807936, 1200996087, 1200571353, 1251063924, 1251325481, 394225724, 1251763837, 1251088153, 315811340, 1200161570, 313808651, 1251112070, 1251673102, 319812057, 378000624, 1251027898, 329807382, 371824206, 1201674709, 1251495190, 1251258300, 1251199940, 0318093154, 1251272795, 1251424030, 115018954, 1201413450, 1251178780, 1251721832, 0385014384, 161022942 - 97 = 24010019 - 98 = 9619439213, 9619509976, 9619319999, 3009800016, 5989800173, 6719430018 - 99 = 0068007003, 0847321750, 6720348169, 9424474, 2456737, 0005559707, 7746504, 8003157, 311303740, 326605174, 2509822, 47313937, 3123707, 4950117929, 303800468, 2686821, 8788871, 3523004, 6750164135, 6710948, 6790147721, 1490152756, 1290255151, 2610153499, 3426610, 6258468, 1464558, 7071159, 2689901, 326800139, 6660243192, 5180163834, 1598783, 4481488, 85302353, 9081178, 6947719, 5480158891, 2409097, 6810215281, 6260239897, 1458264 - ; 52 - 13051052 = 49750996, 46310653, 42200908 - 13051172 = 43001500, 48726458 - 81053132 = 41084332 - ; 53 - 16052072 = 382432256 - 85055142 = 345033997 - ; C0 - 81053272 = 42279904, 49279640, 0082335729, 0734192657, 6932875274, 48074470 - ; (B6) - 80053782 = 487310018 - ; (B6) - 80053762 = 9110000000 diff --git a/docs/changelog.txt b/docs/changelog.txt deleted file mode 100644 index 55e8d1b0..00000000 --- a/docs/changelog.txt +++ /dev/null @@ -1,533 +0,0 @@ -Version 0.27 - not yet released -------------------------------- - - replaced the autoloader with http://php-autoloader.malkusch.de - - -Version 0.26 - June 3, 2012 ---------------------------- - - Repaired Bundesbank download - - -Version 0.25 - April 2, 2012 ------------------------------ - - New Validators: D9 - - - Changed Validators: B6, D1 - - - repaired Bundesbank download - - -Version 0.24 - March 30, 2011 ------------------------------ - - Changed Validators: B8, C6, D4 - - - New Validators: D7, D8 - - -Version 0.23 - December 31, 2010 --------------------------------- - - Changed Validators: D1 - - - New Validators: D6 - - -Version 0.22 - October 28, 2010 -------------------------------- - - Changed Validators: C6, D1 - - - New Validators: D4, D5 - - - Repaired Validators: 90 - https://sourceforge.net/projects/bav/forums/forum/405655/topic/3758753 - - - fixed shortTerm-Bug - https://sourceforge.net/projects/bav/forums/forum/405655/topic/3798274 - - -Version 0.21 - March 27, 2010 ------------------------------ - - Support for InnoDB tables. - - - blz_20100308.txt is not ordered. - see http://sourceforge.net/projects/bav/forums/forum/405655/topic/3568342 - - - filesize() in BAV_FileParser::init() returns sometimes 0. - - -Version 0.20 - September 2, 2009 --------------------------------- - - 0 is always invalid - - - fixed Validators: 16 (again) - - - removed error supressings (@) - - - ZIP-support disabled in BAV_DataBackend_File - see http://sourceforge.net/forum/message.php?msg_id=7555232 - - -Version 0.19 - March 7, 2009 ----------------------------- - - changed validator C6 - - - fixed bug in BAV_Validator_Iteration - - - fixed validators: 17, B9, D1, 23 (fixed in 16), 65 - - - BAV_DataBackend_File->getTempdir() works also if sys_get_temp_dir() - doesn't exist. - - - BAV_Autoloader works also in a Windows environment (untested) - - -Version 0.18 - October 2, 2008 ------------------------------- - - implemented validators D2, D3 - - -Version 0.17 - June 30, 2008 ----------------------------- - - https://sourceforge.net/forum/message.php?msg_id=4908493 - - - implemented validators C8, C9, D0, D1 - - -Version 0.16 - January 16, 2008 -------------------------------- - - [API 2.3] BAV_DataBackend_PDO->getAgencies($sql) - - - [API 2.3] BAV_DataBackend_PDO->getPrefix() - - - [API 2.3] BAV_Agency->isMainAgency() - - - fixed Validators 75 - - - implemented validators C5, C6, C7 - - -Version 0.15 - April 8, 2007 ----------------------------- - - [API 2.2] BAV_Encoding->__construct throws BAV_EncodingException_Unsupported - - - [API 2.2] BAV_Encoding::isSupported($encoding) - - - Default encoding is UTF-8; if wether mb_* nor iconv_* is present then it is latin9; - - - implemented validators C3, C4 - - - changed validator 74 - - -Version 0.14 - December 28, 2006 --------------------------------- - - [API 2.1] added BAV_DataBackend->bankExists($bankID); - - - [API 2.1] Encoding of BAV can be configured by BAV::setEncoding(); - - - BAV_Autoloader improved error handling when working in a stack; - - - BAV_Autoloader->loadDirectly() removes itself from the autoloader stack; - - - BAV_Autoloader uses Reflection API to decide if a class constructor is present; - - -Version 0.13 - December 18, 2006 --------------------------------- - - reimplemented all Validators; implemented missing Validators - - - [API 2.0] changed complete API to version 2.0 - - - uses PHP5 specific syntax and features - - - provide information about a bank - - - removed the CLI script bav.php - - -Version 0.12b - November 20, 2006 ---------------------------------- - - fixed Validators 07, B4 - - -Version 0.12a - November 19, 2006 ---------------------------------- - - fixed Validator C0 - - -Version 0.12 - November 17, 2006 --------------------------------- - - applied patch for new format - - - fixed Validators B6, 22 - - - [API 1.2] renamed HTTPHeader::getVersion() and setVersion() to getHTTPVersion() - and setHTTPVersion() - - - changed validator 57 - - - implemented validators B9, C0, C1, C2 - - -Version 0.11 - December 4, 2005 -------------------------------- - - added optional constant BAV_UPDATE_TMP to enter a writable directory for - temporary files. - - - Bundesbank thinks that's a good idea to terminate a line by \n *or* by \r\n. - So BAV_BUNDESBANK_LINE_LENGTH was removed, as BAV_BankFactory_BinarySearch has - to find it automatically. - - -Version 0.10 - October 5, 2005 ------------------------------- - - implemented new validators: B6, B7, B8 - - - moved test/SQL.php to test/sql/*.php - - - added BAV_Version. - - - [API 1.1] BAV::getVersion() and BAV::getAPIVersion() are returning BAV_Version objects. - - - [API 1.1] corrected the typo "weight" in validator classes. - - - BAV_BankSaver_Bundesbank::save() uses rename() which doesn't work on PHP before 4.3.3 on - different partitions. This is fixed now. - - -Version 0.9 - May 29, 2005 --------------------------- - - renamed BAV_Bank::getNewAccount() to BAV_Bank::getAccount() - - - renamed BAV_Validator::validate() to BAV_Validator::getValidatorResult() - - - renamed BAV_Account::validate() to BAV_Account::getValidatorResult() - - - renamed BAV_Controller::validate() to BAV_Controller::getValidatorResult() - - - BAV_Bank::validate() is deprecated, BAV_Bank::getValidatorResult() added - - - removed BAV_Bank::getBLZ(), which is since some versions marked as deprecated - - - added BAV::getVersion() and BAV::getAPIVersion() - - - added some more tests - - - added BAV_SQL_PearDB - - - added -v option in bav.php - - - added BAV_SQL_Connection which is the parent class for all DBS which work with connections. - So the ancient classes BAV_SQL_MySQL, BAV_SQL_Postgres and BAV_SQL_SQLite moved to - connection/BAV_SQL_Connection_*.php - - - moved sql configuration to config/sql/* - - - All BAV_SQL_Connection classes can now be initialized by an existing connection - - - the Bundesbank released a new bank file - - - added protected method BAV_Validator::isValidType() - - - changed BAV_BankSaver - - - deleted scripts/bav_install.php - - - added scripts/update.php - - - added BAV_SQL::replaceTable() - - -Version 0.8 - April 24, 2005 ----------------------------- - - Bundesbank changed validator 90 - - - Bundesbank added validator B5 - I'm not sure if it's correct, as it says that 1151043211 is valid, but the Bundesbank says - it should be wrong at the first validator. It is wrong at the first validator, but the - second validator says it's valid and so it's valid for the complete B5. - - - Added a new BankFactory which works on the Bundesbank file. The new factory is fast, as it - uses a binary search (it even may be improved by better handling of the '00000000' exception). - And it needs only an unmodified file of the Bundesbank. So it became the new default factory. - - - Changed BAV_BankFactory_File_Hashtable and BAV_BankFactory_File_Bundesbank to - BAV_BankFactory_Hashtable and BAV_BankFactory_Hashtable_Bundesbank. - - - added new directory test/ and moved scripts/checkValidators.php to it. - - -Version 0.7e - April 4, 2005 ----------------------------- - - BAV_BankFactory_File::bankExists() and BAV_BankFactory_SQL::bankExists() were overwritten. - BAV_SQL gets a getFoundRows(). - - - Repaired validators: 44, 90 - - - added test to find missing require_onces. - - - added require_once BAV_CLASS_PATH.'validator/BAV_Validator.php': - 88, A6, 93_Aux - - - My SQLite Version doesn't understand LIMIT in UPDATE. So a statement changed. - - - Implemented specification change of A8 - - - Implemented B4 - - -Version 0.7d - November 29, 2004 --------------------------------- - - Bundesbank changed 73 - - - Bundesbank specified B0 and B3. - - -Version 0.7c - October 20, 2004 -------------------------------- - - changed the shebang line from /usr/local/bin/php to /usr/bin/php. - If you use the scripts you should modify it anyway! - - - fixed validator 52 again - Thanks to Enrico Stahn - - - fixed 53, but there seems to be one bug left - - - checkValidators.php was rewritten and supports now bank IDs in the - verify.ini - - - reimplemented validators: 20 - - - reimplemented because of specification change: 51, 73, 80, 81, 84, 86, 87 - - - little change of the verify.ini: PHP5 treats text with a leading '0' like - '09' as an octal number, which we cannot use. - - -Version 0.7b - September 5, 2004 --------------------------------- - - updated bank list - - - fixed validators: 88, 52 - - - implemented validators: B1, B2 - - -Version 0.7a - August 16, 2004 ------------------------------- - - reimplemented validator: 05 - - - fixed validators: 24, 61 - - -Version 0.7 - August 2, 2004 ----------------------------- - - BAV_Bank::getBLZ() is deprecated. Use BAV_Bank::getID() instead. - - - reimplemented validator because of notices: 22 - - - dropped XML support as there is really no need at the moment - - - added PHPDoc documentation - - - added a layer for Postgresql - - - changed the implementation of BAV_BankSaver_SQL::_save(), - because Postgres doesn't know REPLACE - - - The BankID index has to be quoted, as Postgres should cast - it to fit to an index. - - - Every SQL Query uses now ' instead of " as quotes. - - - added ANALYZE and VACUUM to installation - - - README was updated. - - - added BAV_Controller::isInvalid() - - - added BAV_Bank_Extended and removed it again. I hope it has - been removed completely. - - - replaced import_* and install* with bav_install.php - - - fixed unimportant bug in BAV_Validator_KontoCheck - - - fixed BUG with static table in BAV_Validator_KontoCheck, - which affected PHP 4.3.0. - - - BAV_Validator_KontoCheck does a preNulls() on the validated IDs. This - is a workaround for the old validators, which expected to validate - normalized bank IDs. - - -Version 0.6a - July 1, 2004 ---------------------------- - - fixed Validators: 13, 50, 87 - - - added verifyImport.php - - - checkValidators.php searches also for verfahren_* calls. - There seems to be no more. - - -Version 0.6 - June 28, 2004 ---------------------------- - - fixed Validators: 93 - - - The install_* scripts don't print "#!/usr/local/bin/php" now. - - - The Factory for the file of the Bundesbank doesn't use file() anymore, - so the memory amount is still below the 8 MB limit. - - - Changed the SQL structure for the tables. - - - the install_* scripts will now print error messages from the import_* scripts - - - Because of the few changes (which aren't very serious) this release - might be one of the last beta releases. - - - update of the banklist.txt - - -Version 0.5 - May 1, 2004 -------------------------- - - bav.php reads interactively also the \n which made the bank unknown. - - - fixed Validators: 00, 10, 25, 28, 29, 32, 35, 36, 37, 38, 39, 43, 44, 47, 51, - 73, 78, 81, 88, A0, A1 - - - implemented Validators: 52, 53, 54, 58, 66, 71, 72, 74, 75, 80, 83, 84, 85, 86, 87 - 89, 90, 92, 93, 96, 97, 98, A2, A3, A4, A5, A6, A7, A8 - - - reimplemented because of Notices: 14, 16, 23, 26, 40, 64, 68, 77 - - - BAV_Validator_Waighted had a serious bug which caused wrong validation results - if a validator object is used more than once. - - - splitted BAV_Validator_Waighted into BAV_Validator_Waighted and its new - super class BAV_Validator_Iteration. BAV_Validator_Iteration can be used by other - validators like BAV_Validator_Transformation. - - - added BAV_Validator_Tranformation as new abstract super class for validators which - are using transformation tables. - - - example/full.php used the old path. - - - added BAV_Validator_Multi as abstract super class for validators which implements - several validation algorithmns. - - - BAV_Validator_06 was modified, in order to be reusable by more validators - - - BAV_Validator_02::__construct()'s parameters were modified, in order to be reusable - by more validators - - - checkValidators.php recognizes more accurant which validators are buggy. - - -Version 0.4 - April 27, 2004 ----------------------------- - - BAV_ValidationResult distinguishes betweend unknown bank - and unknown algorithm. So exit codes of bav.php and result codes of - BAV_ValidationResult have changed. - - - corrected Validators: 81 (a half). - - - checkValidators.php uses verify.txt to check the corectness of the algorithms. - This is still in Beta, because I don't know how these bank accounts should be - treated for real. - - - change of banklist.xml structure. This file is still unused, but it is prepared - to contain all the data for exporting (including test accounts). - - - BAV_BankFactory_SQL::getBank($bankID) is safer, because it escapes the bankID - with BAV_SQL::escape() - - - There is no need to define BAV_ROOT_PATH, this will be done in config/paths.php - So you have only to care about the correct include of config/paths.php. - - - config.php uses per default the hashtable, so you can use BAV without installing - any database. - - - added BAV_Controller to hide all the BAV_* classes (like BAV_Bank, BAV_Factory, - BAV_Account) and provide a more simple interface. But you can and should still - use the old way to validate an account. This class is intended for users which - are not scripting so object oriented. - - -Version 0.3a - April 22, 2004 ------------------------------ - - BAV_Validator_42 was not implemented correctly. - - -Version 0.3 - April 22, 2004 ----------------------------- - - BAV adds support for an unified standard constructor __construct() - - - New powerfull abstract class BAV_Validator_Waighted and its subclass - BAV_Validator_Waighted_Default. These classes offer support for iterating - through waighted algorithmns. - - - Implementation of Validator_56, Validator_57, Validator_91, Validator_A9. - So 34 more Bank IDs are supported. - - - Validator_01 and Validator_06 were rewritten, in order to be used by - other Validators. So these two Validators are verified. - - - Validator_08 and Validator_79 were only slightly verified by - checkValidators.php, and there were return values missing. - They've been patched, but the algorithms were not verified! - - -Version 0.2a - April 5, 2004 ----------------------------- - - BAV is inherited explictly from stdClass. - - - The Script's path is detected correctly by using __FILE__ - instead of $_SERVER['SCRIPT_FILENAME'], which is not available - on every platform. - - - BAV_Validator::crossSum() is fixed. - - - corrected and rewritten algorithm for Validator_63 - - -Version 0.2 - March 20, 2004 ----------------------------- - - The data source changed. The old text file will no more be supported. - Instead the text file of the Deutsche Bundesbank is supported. This file - is included in this package and also located in a ZIP archiv at - - - - Bank name support is completely removed (it even wasn't implemented - completely), because several banks have the same BLZ. So the datastructures - only saves the relation between BLZ and validation algorithm. - - - Class model was slightly improved (the BAV_BankFactory_File hierarchy). - - - XML support was added. This will be usefull in future releases, when - the validator is responsable for different countries. All different data - sources will be exported in one single XML document. So a user needs only the - XML document to update his validator. - - - bav.php was added. This is a command line validator. - It may operate interactively or takes the parameters from the command line. - It throws exit codes, so it may be used by other command line scripts. - - - Bug with the default bank constructor was fixed. - - - All files have a licence note. - - - This Changelog was added - - - Scripts are independent of the CWD. - - - the BAV_BankFactory gets a singleton object which will be initialized in - the central config file config/config.php. - - -Version 0.1 - March 15, 2004 ----------------------------- - - This is the first release. It comes with generated and fixed validators and - several data structures (serialized hashtable, SQLite and an import script - for MySQL). As source for the data structure a text file from the original - project (php_kontocheck) is used. - diff --git a/docs/example.php b/docs/example.php new file mode 100755 index 00000000..b89620dd --- /dev/null +++ b/docs/example.php @@ -0,0 +1,113 @@ +#!/bin/env php + + * @see BAV + */ + +require_once __DIR__ . "/../vendor/autoload.php"; + +use malkusch\bav\BAV; + +/** + * Let's have some fun with the bank 10000000 + */ +try { + // API Facade with default configuration + $bav = new BAV(); + + // Does the bank exist? + echo "Bank 10000000 ", + $bav->isValidBank("10000000") ? "exists" : "doesn't exist", "\n"; + + // Does the account exist? + echo "Account 12345 is ", + $bav->isValidBankAccount("10000000", "12345") ? "valid" : "invalid", "\n"; + + // Use PHP's validation filter + if (filter_var("10000000", FILTER_CALLBACK, $bav->getValidBankFilterCallback())) { + echo "Bank 10000000 is valid.\n"; + + } else { + echo "Bank 10000000 is invalid.\n"; + + } + + // Account filter validation needs a previous call to the bank filter. + if (filter_var("12345", FILTER_CALLBACK, $bav->getValidAccountFilterCallback())) { + echo "Account 12345 is valid.\n"; + + } else { + echo "Account 12345 is invalid.\n"; + + } + + // Print name of the bank + $agency = $bav->getMainAgency("10000000"); + echo "{$agency->getName()} {$agency->getCity()}\n"; + + /** + * Are there any more agencies? + */ + print_r($bav->getAgencies("10000000")); + +} catch (BAVException $error) { + die("Some error happened in the data backend."); + +} + +/** + * Now have a look at the special features of PDODataBackend. Note that + * the script will exit now if the PDO object could not be created. You should + * edit the PDO object to create a valid DBS connection. + */ + +use malkusch\bav\PDODataBackendContainer; + +try { + /* + * Create the PDO container. If you intend to do so you should + * create the file bav/configuration.php and return a Configuration which + * uses PDODataBackendContainer. + * + * @see ConfigurationRegistry + */ + $backendContainer = new PDODataBackendContainer( + new \PDO('sqlite::memory:') + ); + $backend = $backendContainer->getDataBackend(); + + /** + * We can use an arbitrary SQL statement to search for some agencies. This statement + * needs at least to return the ids of the agencies. + */ + $agencies = $backend->getAgencies("SELECT id FROM {$backend->getPrefix()}agency LIMIT 10"); + foreach ($agencies as $agency) { + echo "Found agency {$agency->getPostcode()} of bank {$agency->getBank()->getBankID()}\n"; + + } + + /** + * You perform better if you provide all attributes of the agency table. Let's + * try it and search all banks in munich. + */ + $agencies = $backend->getAgencies( + "SELECT * FROM {$backend->getPrefix()}agency + WHERE city='München' + GROUP BY bank" + ); + foreach ($agencies as $agency) { + echo "{$agency->getBank()->getBankID()} ({$agency->getName()}, {$agency->getCity()})\n"; + + } + +} catch (BAVException $error) { + die($error->getTraceAsString()); + +} diff --git a/docs/gpl.txt b/docs/gpl.txt deleted file mode 100644 index 5b6e7c66..00000000 --- a/docs/gpl.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/docs/pruefzifferberechnungsmethoden.pdf b/docs/pruefzifferberechnungsmethoden.pdf new file mode 100644 index 00000000..f1c4ada5 Binary files /dev/null and b/docs/pruefzifferberechnungsmethoden.pdf differ diff --git a/scripts/example.php b/scripts/example.php deleted file mode 100755 index 68a54013..00000000 --- a/scripts/example.php +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/env php - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package example - * @filesource - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - * @see BAV_DataBackend - * @see BAV_Bank - * @see BAV_Agency - */ - - -/** - * We need to require the autoloader - */ -require_once __DIR__ . "/../autoloader/autoloader.php"; - - -/** - * Now we have to decide which data backend we'll use. - * - * BAV_DataBackend_File: - * $databack = new BAV_DataBackend_File(); - * - * or BAV_DataBackend_PDO: - * $databack = new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test')); - * - * In this example we take BAV_DataBackend_File: - */ -$databack = new BAV_DataBackend_File(); - - -/** - * As this is our first time we use it. We have to install the data structure. - * This should only be called once for installation. For future use you should - * skip this step. - */ -try { - $databack->install(); - -} catch (BAV_DataBackendException $error) { - die("Installation failed: {$error->getMessage()}\n"); - -} - -/** - * If you want to update your installed data structure to a new Bundesbank file - * you have to call update(): - * - * $databack->update(); - * - * Now this is not necessary, as install() calls implicitly update(). - */ - - -/** - * Let's have some fun with the bank 10000000 - */ -try { - $bank = $databack->getBank(10000000); - /** - * Hmm, what name does this bank have? - */ - echo "{$bank->getMainAgency()->getName()} {$bank->getMainAgency()->getCity()}\n"; - /** - * Are there any more agencies? - */ - print_r($bank->getAgencies()); - /** - * And now we want to see if the account 12345 is valid: - */ - echo "Account 12345 is ", $bank->isValid(12345) ? "valid" : "invalid", "\n"; - -} catch (BAV_DataBackendException_BankNotFound $error) { - /** - * Now you would know that the bank 10000000 does not exist. - * BAV_DataBackend->bankExists(10000000) would also tell that: - */ - if (! $databack->bankExists($error->getBankID())) { // of course that's the same as if(true) - die("Bank {$error->getBankID()} does not exist."); - - } - -} catch (BAV_DataBackendException $error) { - die("Some error happened in the data backend."); - -} - - -/** - * As this is a clean example we won't leave anything back so we uninstall the - * datastructure. For your real life application you won't call uninstall() as - * you want to keep your data structure. - */ -try { - $databack->uninstall(); - -} catch (BAV_DataBackendException $error) { - die("Uninstallation failed"); - -} - - -/** - * Now have a look at the special features of BAV_DataBackend_PDO. Note that - * the script will exit now if the PDO object could not be created. You should - * edit the PDO object to create a valid DBS connection. - */ -try { - - $databackPDO = new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test')); - $databackPDO->install(); - - - /** - * We can use an arbitrary SQL statement to search for some agencies. This statement - * needs at least to return the ids of the agencies. - */ - $agencies = $databackPDO->getAgencies("SELECT id FROM {$databackPDO->getPrefix()}agency LIMIT 10"); - foreach ($agencies as $agency) { - echo "Found agency {$agency->getPostcode()} of bank {$agency->getBank()->getBankID()}\n"; - - } - - - /** - * You perform better if you provide all attributes of the agency table. Let's - * try it and search all banks in munich. - */ - $agencies = $databackPDO->getAgencies(" - SELECT * FROM {$databackPDO->getPrefix()}agency - WHERE city='München' - GROUP BY bank"); - foreach ($agencies as $agency) { - echo "{$agency->getBank()->getBankID()} ({$agency->getName()}, {$agency->getCity()})\n"; - - } - - - $databackPDO->uninstall(); - -} catch (BAV_DataBackendException $error) { - die($error->getTraceAsString()); - -} \ No newline at end of file diff --git a/scripts/verifyImport.php b/scripts/verifyImport.php deleted file mode 100755 index e89b459b..00000000 --- a/scripts/verifyImport.php +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/env php - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package scripts - * @author Markus Malkusch - * @copyright Copyright (C) 2006 Markus Malkusch - * @see BAV_VerifyImport - */ - - -/** - * We need to require the autoloader - */ -require_once __DIR__ . "/../autoloader/autoloader.php"; - - -/** - * This works only if you have called BAV_DataBackend_File->install(). That - * means there must exist a ../data/banklist.txt. If this does not apply to - * you, you have to change these lines. - */ -$databack = new BAV_DataBackend_File(); - - -$importer = new BAV_VerifyImport($databack); - - -/** - * In this loop you should insert the account IDs with bank IDs. - * - * Of course you need to modify the while condition and the - * sources for $bankID and $accountID. - */ -while ($youHaveMoreAccounts) { // <- Please change - - $bankID = $accounts[$i]['bankID']; // <- Please change - $accountID = $accounts[$i]['accountID']; // <- Please change - - /** - * As a third optional boolean parameter you may specify - * if the account is valid (TRUE) or not (FALSE). Default - * is a valid account. - */ - $importer->import($bankID, $accountID); - -} - - -/** - * An optional parameter says where to save the file. - * Default's to ../data/verify.ini - */ -$importer->save(); \ No newline at end of file diff --git a/tests/AgencyQueryTest.php b/tests/AgencyQueryTest.php deleted file mode 100755 index 27ebbb15..00000000 --- a/tests/AgencyQueryTest.php +++ /dev/null @@ -1,112 +0,0 @@ -getAgencies($sql) - * - * Copyright (C) 2009 Markus Malkusch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package test - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ - - -class AgencyQueryTest extends PHPUnit_Framework_TestCase { - - - /** - * @var BAV_DataBackend_PDO - */ - private $backend; - - - /** - */ - protected function setUp() { - $this->backend = new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test')); - } - - - public function testOnlyID() { - $agencies = $this->backend->getAgencies( - 'SELECT id FROM bav_agency LIMIT 100'); - $this->assertAgencies($agencies, 100); - } - - - public function testIDAndBank() { - $agencies = $this->backend->getAgencies( - 'SELECT id, bank FROM bav_agency LIMIT 100'); - $this->assertAgencies($agencies, 100); - } - - - public function testNoBank() { - $agencies = $this->backend->getAgencies( - 'SELECT id, name, postcode, city, shortTerm, pan, bic FROM bav_agency LIMIT 100'); - $this->assertAgencies($agencies, 100); - } - - - /** - * @expectedException BAV_DataBackendException_IO_MissingAttributes - */ - public function testNoID() { - $result = $this->backend->getAgencies( - 'SELECT name, postcode, city, shortTerm, pan, bic, bank FROM bav_agency LIMIT 1' - ); - } - - - private function assertAgencies(Array $agencies, $count) { - $this->assertEquals($count, count($agencies)); - - foreach ($agencies as $agency) { - if ($agency->isMainAgency()) { - $this->assertTrue( - $agency->getBank()->getMainAgency() === $agency, - "Inconsistent Main Agency" - ); - $this->assertTrue( - $agency->getBank() === $agency->getBank()->getMainAgency()->getBank(), - "Inconsistent Bank" - ); - - } else { - $includedCount = 0; - foreach ($agency->getBank()->getAgencies() as $banksAgency) { - $this->assertTrue( - $banksAgency->getBank() === $agency->getBank(), - "Inconsistent bank" - ); - if ($banksAgency === $agency) { - $includedCount++; - - } - } - $this->assertEquals(1, $includedCount, "Inconsistent agency"); - } - } - } - - -} - - -?> \ No newline at end of file diff --git a/tests/BackendTest.php b/tests/BackendTest.php deleted file mode 100755 index f474de30..00000000 --- a/tests/BackendTest.php +++ /dev/null @@ -1,210 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package test - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ - -class BackendTest extends PHPUnit_Framework_TestCase { - - - private static - /** - * @var BAV_DataBackend_File - */ - $referenceBackend; - - - /** - * Defines the reference backend - */ - static public function classConstructor() { - self::$referenceBackend = new BAV_DataBackend_File(); - } - - - /** - * @return Array The tested backends - */ - public function provideBackends() { - return array( - array(new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test'))), - array(new BAV_DataBackend_File()) - ); - } - - - /** - */ - public function provideInstallationBackends() { - return array( - array(new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test'), 'bavtest_')), - array(new BAV_DataBackend_File(tempnam(BAV_DataBackend_File::getTempdir(), 'bavtest'))) - ); - } - - - /** - * @return Array - */ - public function provideBanks() { - $banks = array(); - foreach($this->provideBackends() as $backendArray) { - $backend = $backendArray[0]; - foreach (self::$referenceBackend->getAllBanks() as $bank) { - $comparedBank = $backend->getBank($bank->getBankID()); - $banks[] = array($bank, $comparedBank); - - } - } - return $banks; - } - - - /** - * @return Array - */ - public function provideAgencies() { - $agencies = array(); - foreach($this->provideBanks() as $banks) { - $referenceBank = $banks[0]; - $testedBank = $banks[1]; - - $referenceAgencies = array(); - foreach ($referenceBank->getAgencies() as $agency) { - $referenceAgencies[$agency->getID()] = $agency; - - } - - foreach ($testedBank->getAgencies() as $agency) { - $agencies[] = array( - $referenceAgencies[$agency->getID()], - $agency - ); - - } - - } - return $agencies; - } - - - /** - * @dataProvider provideInstallationBackends - */ - public function testInstallation(BAV_DataBackend $backend) { - $backend->install(); - $backend->update(); - $backend->uninstall(); - } - - - /** - * @dataProvider provideInstallationBackends - */ - public function testInstallationIsComplete(BAV_DataBackend $backend) { - $this->markTestIncomplete(); - //TODO test if the installation process fills all banks - } - - - /** - * Testet, dass ein erneutes $backend->getBank($id) das selbe - * Objekt zurückliefert. - * - * @dataProvider provideBackends - */ - public function testSingleInstances(BAV_DataBackend $backend) { - foreach (self::$referenceBackend->getAllBanks() as $refBank) { - $this->assertTrue( - $backend->getBank($refBank->getBankID()) === $backend->getBank($refBank->getBankID()), - "Different objects for bank {$refBank->getBankID()}" - ); - } - } - - - /** - * @dataProvider provideBackends - */ - public function testGetAllBanks(BAV_DataBackend $backend) { - $this->assertEquals( - count(self::$referenceBackend->getAllBanks()), - count($backend->getAllBanks()) - ); - } - - - /** - * @dataProvider provideBanks - */ - public function testBanks(BAV_Bank $referenceBank, BAV_Bank $testedBank) { - $this->assertEquals( - $referenceBank->getValidationType(), - $testedBank->getValidationType() - ); - - $this->assertEqualAgency( - $referenceBank->getMainAgency(), - $testedBank->getMainAgency() - ); - - $this->assertEquals( - count($referenceBank->getAgencies()), - count($testedBank->getAgencies()) - ); - } - - - /** - * @dataProvider provideAgencies - */ - public function testAgencies(BAV_Agency $referenceAgency, BAV_Agency $testedAgency) { - $this->assertEqualAgency($referenceAgency, $testedAgency); - } - - - private function assertEqualAgency(BAV_Agency $a, BAV_Agency $b) { - $this->assertTrue($a->getBank()->getBankID() === $b->getBank()->getBankID()); - $this->assertTrue($a->getID() === $b->getID()); - $this->assertTrue($a->getPostcode() === $b->getPostcode()); - $this->assertTrue($a->getCity() === $b->getCity()); - $this->assertTrue($a->getName() === $b->getName()); - $this->assertTrue($a->getShortTerm() === $b->getShortTerm()); - $this->assertTrue($a->hasPAN() === $b->hasPAN()); - $this->assertTrue($a->hasBIC() === $b->hasBIC()); - if ($a->hasPAN()) { - $this->assertTrue($a->getPAN() === $b->getPAN()); - - } - if ($a->hasBIC()) { - $this->assertTrue($a->getBIC() === $b->getBIC()); - - } - } - - -} -BackendTest::classConstructor(); \ No newline at end of file diff --git a/tests/CrossProjectTest.php b/tests/CrossProjectTest.php deleted file mode 100755 index afb03f27..00000000 --- a/tests/CrossProjectTest.php +++ /dev/null @@ -1,173 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package test - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ - - -class CrossProjectTest extends PHPUnit_Framework_TestCase { - - - private - /** - * @var int - */ - #$lastAccount = 9999999999, - $lastAccount = 99999, - /** - * @var Array - */ - $testedValidators = array(), - /** - * @var Array - */ - $failedBankDependentValidators = array(), - /** - * @var Array - */ - $testAPIs = array(); - - - /** - * @return Array - */ - protected function setUp() { - $ktoblzcheckPath = __DIR__ . "/../tmp/ktoblzcheck/ktoblzcheck-1.21/src"; - - $this->testAPIs = array( - new BAV_TestAPI_BAV(), - new BAV_TestAPI_Kontocheck('/etc/blz.lut2', 2), - new BAV_TestAPI_Ktoblzcheck( - "$ktoblzcheckPath/bankdata/bankdata.txt", - "$ktoblzcheckPath/bin/ktoblzcheck" - ) - ); - } - - - /** - * @return Array - */ - public function provideBanks() { - $banks = array(); - $backend = new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test')); - foreach ($backend->getAllBanks() as $bank) { - $banks[] = array($bank); - - } - return $banks; - } - - - /** - * @dataProvider provideBanks - */ - public function testCrossProjects(BAV_Bank $bank) { - try { - $isSkip = $bank->getValidator() instanceof BAV_Validator_BankDependent - ? array_key_exists($bank->getValidationType(), $this->failedBankDependentValidators) - : array_key_exists($bank->getValidationType(), $this->testedValidators); - - if ($isSkip) { - return; - - } - - for ($account = $this->lastAccount; $account >= 0; $account--) { - for($pad = strlen($account); $pad <= strlen($this->lastAccount); $pad++) { - $paddedAccount = str_pad($account, $pad, "0", STR_PAD_LEFT); - $this->assertSameResult($bank, $paddedAccount); - - } - } - - } catch (BAV_TestAPIException_Validation_BankNotFound $e) { - return; - - } catch (Exception $e) { - if ($bank instanceof BAV_Validator_BankDependent) { - $this->failedBankDependentValidators[$bank->getValidationType()] = true; - - } - throw $e; - - } - $this->testedValidators[$bank->getValidationType()] = true; - } - - - private function assertSameResult(BAV_Bank $bank, $account) { - $results = array(); - $resultValues = array(); - foreach ($this->testAPIs as $key => $testAPI) { - $result = $testAPI->getResult($bank, $account); - $results[] = $result; - $resultValues[] = $result->getResult(); - - } - - $this->assertEquals( - 1, - count(array_unique($resultValues)), - $this->getErrorMessage($bank, $account, $results) - ); - } - - - /** - * @param BAV_Bank $bank - * @param String $account - * @param array $results - * @return String - */ - private function getErrorMessage(BAV_Bank $bank, $account, Array $results) { - $resultTranslation = array( - BAV_TestAPIResult::VALID => "valid", - BAV_TestAPIResult::INVALID => "invalid", - BAV_TestAPIResult::ERROR => "error" - ); - - $message = "{$bank->getBankID()}/{$bank->getValidationType()}\t" - . str_pad($account, strlen($this->lastAccount)) . "\t"; - - foreach ($results as $result) { - $message .= "{$result->getTestAPI()->getName()}: " - . str_pad($resultTranslation[$result->getResult()], 8); - if ($result instanceof BAV_TestAPIResult_Error) { - $message .= " {$result->getMessage()}"; - - } - $message .= "\t"; - - } - - return $message; - } - - -} - - -?> \ No newline at end of file diff --git a/tests/DataConstraintTest.php b/tests/DataConstraintTest.php deleted file mode 100755 index 2e6b1ae0..00000000 --- a/tests/DataConstraintTest.php +++ /dev/null @@ -1,149 +0,0 @@ -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - - self::$pdo->exec("DROP TABLE IF EXISTS bank"); - self::$pdo->exec("CREATE TEMPORARY TABLE bank ( - id int primary key, - blz char(8), - isMain tinyint(1), - name varchar(58), - plz varchar(5), - city varchar(35), - shortterm varchar(27), - pan char(5), - bic varchar(11), - validator char(2), - index(blz), - index(name), - index(shortterm), - index(pan), - index(bic) - ) engine=MEMORY"); - - $fp = fopen(__DIR__ . '/../data/banklist.txt', 'r'); - if (! is_resource($fp)) { - throw new RuntimeException('I/O-Error'); - - } - - $insert = self::$pdo->prepare(" - INSERT INTO bank - ( id, blz, isMain, name, plz, city, shortterm, pan, bic, validator) - VALUES (:id, :blz, :isMain, :name, :plz, :city, :shortTerm, :pan, :bic, :validator)"); - $insert->bindParam(':id', $id); - $insert->bindParam(':blz', $blz); - $insert->bindParam(':isMain', $isMain); - $insert->bindParam(':name', $name); - $insert->bindParam(':plz', $plz); - $insert->bindParam(':city', $city); - $insert->bindParam(':shortTerm', $shortTerm); - $insert->bindParam(':pan', $pan); - $insert->bindParam(':bic', $bic); - $insert->bindParam(':validator', $validator); - - while ($line = fgets($fp)) { - $blz = substr($line, 0, 8); - $isMain = ($line{8} === '1') ? 1 : 0; - $name = trim(substr($line, 9, 58)); - $plz = trim(substr($line, 67, 5)); - $city = trim(substr($line, 72, 35)); - $shortTerm = trim(substr($line, 107, 27)); - $pan = trim(substr($line, 134, 5)); - $bic = trim(substr($line, 139, 11)); - $validator = substr($line, 150, 2); - $id = substr($line, 152, 6); - - $insert->execute(); - - } - fclose($fp); - } - - - /** - * @return Array - */ - public function provideParsedLines() { - $parser = new BAV_FileParser(); - $lines = array(); - - for($i = 0; $i < $parser->getLines(); $i++) { - $line = $parser->readLine($i); - $blz = mb_substr($line, 0, 8, 'UTF-8'); - $type = mb_substr($line, BAV_FileParser::TYPE_OFFSET, BAV_FileParser::TYPE_LENGTH, 'UTF-8'); - - $lines[] = array($blz, $type); - } - - return $lines; - } - - - /** - * @dataProvider provideParsedLines - */ - public function testParser($blz, $type) { - $this->assertRegExp('~^\d{8}$~', $blz); - $this->assertRegExp('~^[\dA-Z]\d$~', $type); - } - - - /** - * Every bankID should have exact one validator - */ - public function testValidatorCount() { - $statement = self::$pdo->query(" - SELECT blz FROM bank GROUP BY blz HAVING count(DISTINCT validator) != 1 - "); - $this->assertFalse( - $statement->fetch(), - "bankID <-> validator is not n:1!" - ); - } - - - /** - * Every bankID should have exact one mainAgency - */ - public function testMainAgency () { - $statement = self::$pdo->query("SELECT blz FROM bank GROUP BY blz HAVING SUM(isMain) != 1"); - $this->assertFalse( - $statement->fetch(), - "Every bankID should have exact one mainAgency." - ); - } - - - public function testBLZDatatype () { - $statement = self::$pdo->query("SELECT blz FROM bank WHERE blz LIKE '0%'"); - $this->assertFalse( - $statement->fetch(), - "Every bankID should not start with 0." - ); - } - -} - - -?> \ No newline at end of file diff --git a/tests/TestSuite.php b/tests/TestSuite.php deleted file mode 100644 index 3c2f1945..00000000 --- a/tests/TestSuite.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package test - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ - - -require_once __DIR__ . '/AgencyQueryTest.php'; -require_once __DIR__ . '/BackendTest.php'; -require_once __DIR__ . '/DataConstraintTest.php'; -require_once __DIR__ . '/ValidatorTest.php'; -require_once __DIR__ . '/VerifyImportTest.php'; - - -class TestSuite extends PHPUnit_Framework_TestSuite { - - - /** - * @return TestSuite - */ - public static function suite() { - $suite = new self(); - - $suite->addTestSuite('AgencyQueryTest'); - $suite->addTestSuite('DataConstraintTest'); - $suite->addTestSuite('ValidatorTest'); - $suite->addTestSuite('VerifyImportTest'); - $suite->addTestSuite('BackendTest'); - - return $suite; - } - - -} - - -?> \ No newline at end of file diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php deleted file mode 100755 index ef85d510..00000000 --- a/tests/ValidatorTest.php +++ /dev/null @@ -1,254 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package test - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ - - -class ValidatorTest extends PHPUnit_Framework_TestCase { - - - private static - /** - * @var BAV_DataBackend - */ - $dataBackend, - /** - * @var array This array contains all names of implemented algorithms as keys. - */ - $implementedBanks = array(), - /** - * @var array all known banks - */ - $knownBanks = array(); - - - /** - * @throws BAV_FileParserException_IO - * @throws BAV_FileParserException_FileNotExists - */ - protected function setUp() { - if (! empty(self::$dataBackend)) { - return; - - } - #self::$dataBackend = new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test')); - self::$dataBackend = new BAV_DataBackend_File(); - - - foreach (self::$dataBackend->getAllBanks() as $bank) { - self::$knownBanks[$bank->getValidationType()] = $bank; - - } - } - - - /** - * @return Array - */ - public function provideBanks() { - $this->setUp(); - - $banks = array(); - $files = BAV_ClassFile::getClassFiles(__DIR__.'/../classes/validator/validators/'); - foreach ($files as $class) { - if (! preg_match('~^BAV_Validator_([A-Z0-9]{2})$~', $class->getName(), $matchType)) { - continue; - - } - $validatorType = $matchType[1]; - $bank = array_key_exists($validatorType, self::$knownBanks) - ? self::$knownBanks[$validatorType] - : new BAV_Bank(self::$dataBackend, 12345678, $validatorType); - - $banks[] = array($bank); - self::$implementedBanks[$validatorType] = $bank; - - } - return $banks; - } - - - /** - * @return Array - */ - public function provideAccountsAndBanksInAllLengths() { - $providedAccountsAndBanks = array(); - foreach ($this->provideBanks() as $bank) { - $bank = $bank[0]; - for ($length = 0; $length <= 10; $length++) { - $providedAccountsAndBanks[] = array($bank, str_repeat(1, $length)); - - } - } - return $providedAccountsAndBanks; - } - - - /** - * This Test runs all validators in order to find parse Errors - * and fills {@link $implementedBanks}. - * - * @param String $validatorType - * @throws BAV_ClassFileException_IO - * @throws BAV_ClassFileException_MissingClass - * @dataProvider provideBanks - */ - public function testFindParseErrors(BAV_Bank $bank) { - /** - * testing 10 random bank accounts - */ - for ($i = 0; $i < 10; $i++) { - $bank->isValid(mt_rand(0, 9999999999)); - - } - } - - - /** - * 0 - 0000000000 should always be invalid - * - * @param String $validatorType - * @throws BAV_ClassFileException_IO - * @throws BAV_ClassFileException_MissingClass - * @dataProvider provideBanks - */ - public function testNullIsInvalid(BAV_Bank $bank) { - for ($length = 0; $length <= 10; $length++) { - $account = str_pad("0", $length, "0", STR_PAD_LEFT); - $this->assertFalse( - $bank->isValid($account), - "{$bank->getBankID()}/{$bank->getValidationType()} $account should be invalid." - ); - - } - } - - - /** - * Short accounts should not raise exception. - * - * @param int $account - * @throws BAV_ClassFileException_IO - * @throws BAV_ClassFileException_MissingClass - * @dataProvider provideAccountsAndBanksInAllLengths - */ - public function testAccountLength(BAV_Bank $bank, $account) { - $bank->isValid($account); - } - - - /** - * @return Array - */ - public function provideTestAccounts() { - $verifyArray = parse_ini_file(__DIR__.'/../data/verify.ini', true); - if (! $verifyArray) { - throw new RuntimeException("couldn't parse verify.ini."); - - } - return array_merge( - $this->getTestAccounts($verifyArray['valid'], true), - $this->getTestAccounts($verifyArray['invalid'], false) - ); - } - - - /** - * @return Array - */ - private function getTestAccounts(Array $testAccounts, $expectedValidation) { - $accounts = array(); - foreach ($testAccounts as $typeOrBankID => $tests) { - $accounts[] = array( - $typeOrBankID, - preg_split(':\D+:', $tests), - $expectedValidation - ); - - } - return $accounts; - } - - - /** - * @dataProvider provideTestAccounts - */ - public function testAccount($typeOrBankID, Array $accountIDs, $expectedValidation) { - if (strlen($typeOrBankID) <= 2) { - $typeOrBankID = (strlen($typeOrBankID) < 2 ? '0' : '').$typeOrBankID; - $this->assertArrayHasKey($typeOrBankID, self::$implementedBanks); - $bank = self::$implementedBanks[$typeOrBankID]; - - $this->assertEquals($typeOrBankID, $bank->getValidationType()); - - } else { - try { - $bank = self::$dataBackend->getBank($typeOrBankID); - - } catch (BAV_DataBackendException_BankNotFound $e) { - switch ($e->getBankID()) { - - case '13051052': - case '13051172': - case '81053132': - $bank = new BAV_Bank(self::$dataBackend, $e->getBankID(), '52'); - break; - - case '16052072': - case '85055142': - $bank = new BAV_Bank(self::$dataBackend, $e->getBankID(), '53'); - break; - - case '80053762': - case '80053772': - case '80053782': - $bank = new BAV_Bank(self::$dataBackend, $e->getBankID(), 'B6'); - break; - - case '81053272': - case '86055462': - $bank = new BAV_Bank(self::$dataBackend, $e->getBankID(), 'C0'); - break; - - default: throw $e; - - } - } - } - - foreach ($accountIDs as $accountID) { - $this->assertEquals( - $expectedValidation, - $bank->isValid($accountID), - "$accountID validates wrongly." - ); - - } - } - - -} \ No newline at end of file diff --git a/tests/VerifyImportTest.php b/tests/VerifyImportTest.php deleted file mode 100755 index 6e81da4c..00000000 --- a/tests/VerifyImportTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package test - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - * @see BAV_VerifyImport - */ - - -class VerifyImportTest extends PHPUnit_Framework_TestCase { - - - private - /** - * @var array - */ - $validationMap = array(), - /** - * @var array - */ - $verifyArray = array(), - /** - * @var BAV_DataBackend_File - */ - $databack; - - - protected function setUp() { - $this->databack = new BAV_DataBackend_File(); - $this->verifyArray = parse_ini_file(__DIR__.'/../data/verify.ini', true); - - $this->assertType( - PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, - $this->verifyArray, - "Could not parse verify.ini" - ); - - foreach ($this->databack->getAllBanks() as $bank) { - $this->validationMap[$bank->getValidationType()] = $bank; - - } - } - - - public function testFileImport() { - $importer = new BAV_VerifyImport($this->databack); - $importer->importVerifyFile(); - $this->assertImporter($importer); - } - - - public function testSequentialImport() { - $importer = new BAV_VerifyImport($this->databack); - $notSupported = array(); - foreach ($this->verifyArray as $expect => $array) { - foreach ($array as $type => $accounts) { - try { - $type = (strlen($type) < 2 ? '0' : '').$type; - $accounts = preg_split('~\D+~', $accounts); - $bankID = strlen($type) === 2 ? $this->getBank($type)->getBankID() : $type; - foreach ($accounts as $account) { - $importer->import($bankID, $account, $expect === 'valid' ? true : false); - - } - - } catch (BAV_DataBackendException_BankNotFound $e) { - $notSupported[] = $type; - - } - - } - - } - $this->assertImporter($importer, $notSupported); - } - - - private function assertImporter(BAV_VerifyImport $importer, Array $notSupported = array()) { - $file = tempnam('/tmp', 'BAV'); - $this->assertFileExists($file); - - $importer->save($file); - $checkArray = parse_ini_file($file, true); - unlink($file); - - $this->assertType( - PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, - $checkArray, - "Could not parse temporary file $file." - ); - - foreach ($this->verifyArray as $expect => $array) { - foreach ($array as $type => $accounts) { - $actualAccounts = @$checkArray[$expect][$type]; - unset($checkArray[$expect][$type]); - if (array_search($type, $notSupported) !== false) { - continue; - - } - $this->assertEquals( - preg_replace('~\D~', '', $accounts), - preg_replace('~\D~', '', $actualAccounts), - "[$expect]$type is not equal!" - ); - - } - - } - - $this->assertEquals(0, count($checkArray['valid'])); - $this->assertEquals(0, count($checkArray['invalid'])); - } - - - /** - * @param String $validationType - * @return BAV_Bank - */ - private function getBank($validationType) { - if (! isset($this->validationMap[$validationType])) { - throw new BAV_DataBackendException_BankNotFound($validationType); - - } - return $this->validationMap[$validationType]; - } - -} - - -?> \ No newline at end of file diff --git a/tests/autoloader/InstantAutoloader.php b/tests/autoloader/InstantAutoloader.php new file mode 100644 index 00000000..e3147af3 --- /dev/null +++ b/tests/autoloader/InstantAutoloader.php @@ -0,0 +1,248 @@ +. + * + * @category PHP + * @package Autoloader + * @author Markus Malkusch + * @copyright 2009 - 2010 Markus Malkusch + * @license http://php-autoloader.malkusch.de/en/license/ GPL 3 + * @version SVN: $Id$ + * @link http://php-autoloader.malkusch.de/en/ + */ + +namespace malkusch\autoloader; + +/** + * There might be several InstantAutoloaders deployed in a project. + * One is enough. + */ +if (! class_exists("malkusch\autoloader\InstantAutoloader", false)) { + + /** + * An instant autoloader for shipping with project builds + * + * You can build a complete index of your project (by calling + * Autoloader::buildIndex()). If you use AutoloaderIndex_PHPArrayCode as + * index you can only use this instant autoloader for your project. This class + * has no further dependency on any other class. Just copy this class and the + * generated index anywhere into your project. + * + * Consider setting the AutoloaderIndexFilter_RelativePath filter. + * + * @category PHP + * @package Autoloader + * @author Markus Malkusch + * @license http://php-autoloader.malkusch.de/en/license/ GPL 3 + * @version Release: 1.12 + * @link http://php-autoloader.malkusch.de/en/ + * @see Autoloader::buildIndex() + * @see AutoloaderIndex_PHPArrayCode() + * @see AutoloaderIndexFilter_RelativePath() + */ + class InstantAutoloader + { + + const + /** + * The name of the class constructor is classConstructor(). + */ + CLASS_CONSTRUCTOR = 'classConstructor'; + + private + /** + * @var string + */ + $_basePath = "", + /** + * @var array + */ + $_index = array(); + + /** + * Loads the generated index array + * + * The index must be a generated AutoloaderIndex_PHPArrayCode index. + * + * @param string $indexPath Path to the generated index + */ + public function __construct($indexPath) + { + $this->_index = require $indexPath; + } + + /** + * Registers this autoloader at the autoloader stack + * + * @return void + */ + public function register() + { + // spl_autoload_register() disables __autoload(). This might be unwanted. + if (\function_exists("__autoload")) { + \spl_autoload_register("__autoload"); + + } + \spl_autoload_register(array($this, "autoload")); + } + + /** + * Includes all class paths + * + * You can use this as an alternative to the autoload mechanism. This + * simply includes all classes without any autoloader. + * + * @return void + */ + public function requireAll() + { + foreach ($this->_index as $classPath) { + $this->_requirePath($classPath); + + } + } + + /** + * Sets the base path for the class paths in the index + * + * @param string $basePath Base path for the class paths in the index + * + * @return void + */ + public function setBasePath($basePath) + { + $this->_basePath = $basePath; + } + + /** + * Autoloader callback + * + * @param string $class Class name + * + * @return void + */ + public function autoload($class) + { + $this->_normalizeClass($class); + + /* + * spl_autoload_call() runs the complete stack, + * even though the class is already defined by + * a previously registered method. + */ + if ( + \class_exists($class, false) + || \interface_exists($class, false) + ) { + return; + + } + if ( + \version_compare(PHP_VERSION, "5.4", '>=') + && \trait_exists($class, false) + ) { + return; + + } + if (!\array_key_exists($class, $this->_index)) { + return; + + } + + $this->_requirePath($this->_index[$class]); + + $this->_callClassConstructor($class, self::CLASS_CONSTRUCTOR); + } + + /** + * Requires a class path + * + * @param string $path Class path + * + * @return void + */ + private function _requirePath($path) + { + if (!empty($this->_basePath)) { + $path = $this->_basePath . DIRECTORY_SEPARATOR . $path; + + } + require_once $path; + } + + /** + * Normalizes the reference of a class name with strtolower() + * + * Normalizing is needed as PHP is case insensitive. + * + * @param String &$class The reference of a class name + * + * @see strtolower(). + * @return void + */ + private function _normalizeClass(&$class) + { + $class = \strtolower($class); + } + + /** + * Calls the class constructor + * + * If the class $class has the method public static $constructor, it + * will be called. + * + * @param String $class A class which might have a class constructor + * @param String $constructorName the method name of the class constructor + * + * @return bool true if the class constructor was called + */ + public static function _callClassConstructor($class, $constructorName) + { + $reflectionClass = new \ReflectionClass($class); + if (!$reflectionClass->hasMethod($constructorName)) { + return false; + + } + + $constructor = $reflectionClass->getMethod($constructorName); + if (!$constructor->isStatic()) { + return false; + + } + + if (\version_compare(PHP_VERSION, "5.4", '>=') && $reflectionClass->isTrait()) { + return false; + + } + + if ($constructor->getDeclaringClass()->getName() != $reflectionClass->getName()) { + return false; + + } + + $constructor->invoke(null); + return true; + } + + } + +} \ No newline at end of file diff --git a/tests/autoloader/autoloader.php b/tests/autoloader/autoloader.php new file mode 100644 index 00000000..f2164d81 --- /dev/null +++ b/tests/autoloader/autoloader.php @@ -0,0 +1,23 @@ +setBasePath(__DIR__); +$_autoloader->register(); +unset($_autoloader); \ No newline at end of file diff --git a/tests/autoloader/index/0.php b/tests/autoloader/index/0.php new file mode 100644 index 00000000..0367e64d --- /dev/null +++ b/tests/autoloader/index/0.php @@ -0,0 +1,35 @@ + '../classes/testAPI/TestAPI.php', + 'malkusch\bav\timemock' => '../classes/TimeMock.php', + 'malkusch\bav\classfile' => '../classes/class/ClassFile.php', + 'malkusch\bav\pdofactory' => '../classes/PDOFactory.php', + 'malkusch\bav\bavtestapi' => '../classes/testAPI/BAVTestAPI.php', + 'malkusch\bav\testapiresult' => '../classes/testAPI/TestAPIResult.php', + 'malkusch\bav\testapiexception' => '../classes/testAPI/exception/TestAPIException.php', + 'malkusch\bav\kontochecktestapi' => '../classes/testAPI/KontocheckTestAPI.php', + 'malkusch\bav\classfileexception' => '../classes/class/exception/ClassFileException.php', + 'malkusch\bav\ktoblzchecktestapi' => '../classes/testAPI/KtoblzcheckTestAPI.php', + 'malkusch\bav\testapierrorresult' => '../classes/testAPI/TestAPIErrorResult.php', + 'malkusch\bav\classfileioexception' => '../classes/class/exception/ClassFileIOException.php', + 'malkusch\bav\missingclassexception' => '../classes/class/exception/MissingClassException.php', + 'malkusch\bav\validationtestapiexception' => '../classes/testAPI/exception/ValidationTestAPIException.php', + 'malkusch\bav\testapiunavailableexception' => '../classes/testAPI/exception/TestAPIUnavailableException.php', + 'malkusch\bav\banknotfoundtestapiexception' => '../classes/testAPI/exception/BankNotFoundTestAPIException.php', + 'malkusch\bav\notinitializedtestapiexception' => '../classes/testAPI/exception/NotInitializedTestAPIException.php', +); diff --git a/tests/bin/test-install.php b/tests/bin/test-install.php new file mode 100755 index 00000000..fb32fb05 --- /dev/null +++ b/tests/bin/test-install.php @@ -0,0 +1,30 @@ +#!/bin/env php + + * @license WTFPL + */ + +namespace malkusch\bav; + +require_once __DIR__ . "/../bootstrap.php"; + +try { + ConfigurationRegistry::getConfiguration()->setAutomaticInstallation(false); + $databack = ConfigurationRegistry::getConfiguration()->getDatabackendContainer()->getDataBackend(); + + // install file + $databack->install(); + echo "Bundesbank file downloaded.\n"; + + // install PDO + $pdoContainer = new PDODataBackendContainer(PDOFactory::makePDO()); + $pdoContainer->getDataBackend()->install(); + echo "PDO installed.\n"; + +} catch (DataBackendException $error) { + die("Installation failed: {$error->getMessage()}\n"); + +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 00000000..03601dff --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,4 @@ + - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package scripts - * @subpackage test - * @author Markus Malkusch - * @copyright Copyright (C) 2009 Markus Malkusch - */ - - -class BAV_CheckAgainstTestAPIs extends BAV { - - - const VALID = 1; - const INVALID = 2; - const BANK_NOT_FOUND = 3; - const ERROR = 4; - - - private - /** - * @var int - */ - #$firstAccount = 9999999999, - $firstAccount = 999, - /** - * @var int - */ - $lastAccount = 1, - /** - * @var Array - */ - $testedValidators = array(), - /** - * @var Array - */ - $differences = array(), - /** - * @var Array - */ - $testAPIs = array(); - - - public function __construct() { - $ktoblzcheckPath = __DIR__ . "/../tmp/ktoblzcheck/ktoblzcheck-1.21/src"; - - $this->testAPIs[] = new BAV_TestAPI_BAV(); - $this->testAPIs[] = new BAV_TestAPI_Kontocheck('/etc/blz.lut', 2); - $this->testAPIs[] = new BAV_TestAPI_Ktoblzcheck( - "$ktoblzcheckPath/bankdata/bankdata.txt", - "$ktoblzcheckPath/bin/ktoblzcheck" - ); - - - #$backend = new BAV_DataBackend_File(); - $backend = new BAV_DataBackend_PDO(new PDO('mysql:host=localhost;dbname=test', 'test')); - - - if (! empty($GLOBALS['argv'][1])) { - $nodeNumber = $GLOBALS['argv'][1]; - $nodeCount = @$GLOBALS['argv'][2]; - - if ($nodeNumber * $nodeCount == 0 || min($nodeNumber, $nodeCount) < 0) { - trigger_error( - 'Expect two numeric arguments > 0: $nodeNumber $nodeCount', - E_USER_ERROR - ); - - } - - if ($nodeNumber > $nodeCount) { - trigger_error( - 'Expect first argument ($nodeNumber) <= second argument ($nodeCount)', - E_USER_ERROR - ); - - } - - } else { - $nodeNumber = 1; - $nodeCount = 1; - - } - - $increment = $this->lastAccount > $this->firstAccount ? 1 : -1; - $padLength = strlen(max($this->lastAccount, $this->firstAccount)); - - $count = ceil(abs($this->lastAccount - $this->firstAccount) / $nodeCount); - $firstAccount = $this->firstAccount + $increment * ($nodeNumber - 1) * ($count + 1); - - if ($nodeCount == $nodeNumber) { - $afterLastAccount = $this->lastAccount + $increment; - - } else { - $afterLastAccount = $firstAccount + $increment * ($count + 1); - - } - - foreach ($backend->getAllBanks() as $bank) { - try { - if ( array_key_exists($bank->getValidationType(), $this->testedValidators) - && ! $bank->getValidator() instanceof BAV_Validator_BankDependent) { - - continue; - - } - - for ($account = $firstAccount; $account != $afterLastAccount; $account += $increment) { - for($pad = strlen($account); $pad <= $padLength; $pad++) { - $paddedAccount = str_pad($account, $pad, "0", STR_PAD_LEFT); - $differences = count($this->differences); - $this->testAccount($bank, $paddedAccount); - if (count($this->differences) > $differences) { - break 2; - - } - } - } - - $this->testedValidators[$bank->getValidationType()] = true; - - } catch (BAV_TestAPIException_Validation_BankNotFound $e) { - continue; - - } - } - } - - - private function testAccount(BAV_Bank $bank, $account) { - $results = array(); - $resultValues = array(); - foreach ($this->testAPIs as $key => $testAPI) { - $result = $testAPI->getResult($bank, $account); - $results[] = $result; - $resultValues[] = $result->getResult(); - - } - - if (count(array_unique($resultValues)) == 1) { - return; - - } - - - $resultTranslation = array( - BAV_TestAPIResult::VALID => "valid", - BAV_TestAPIResult::INVALID => "invalid", - BAV_TestAPIResult::ERROR => "error" - ); - - echo "{$bank->getBankID()}/{$bank->getValidationType()}\t", - str_pad($account, strlen($this->lastAccount)), "\t"; - - foreach ($results as $result) { - echo "{$result->getTestAPI()->getName()}: ", - str_pad($resultTranslation[$result->getResult()], 8); - if ($result instanceof BAV_TestAPIResult_Error) { - echo " {$result->getMessage()}"; - - } - echo "\t"; - - } - echo "\n"; - - $this->differences[] = array($bank, $account, $results); - } - - -} -new BAV_CheckAgainstTestAPIs(); - - -?> \ No newline at end of file diff --git a/tests/classes/PDOFactory.php b/tests/classes/PDOFactory.php new file mode 100644 index 00000000..e811ce52 --- /dev/null +++ b/tests/classes/PDOFactory.php @@ -0,0 +1,63 @@ + + * @see makePDO() + */ +class PDOFactory +{ + + /** + * Environment variable for a Data Source Name + */ + const ENV_DSN = "PDO_DSN"; + + /** + * Environment variable for the database user + */ + const ENV_USER = "PDO_USER"; + + /** + * Environment variable for the database password + */ + const ENV_PASSWORD = "PDO_PASSWORD"; + + /** + * Builds a PDO. + * + * If the environment doesn't provide the dsn, user and password + * it uses the default mysql test database. + * + * @return \PDO + */ + public static function makePDO() + { + $dsn = getenv(self::ENV_DSN); + if (! $dsn) { + $dsn = "mysql:host=localhost;dbname=test"; + + } + + $user = getenv(self::ENV_USER); + if (! $user) { + $user = "test"; + + } + + $password = getenv(self::ENV_PASSWORD); + if (! $password) { + $password = null; + + } + + $pdo = new \PDO($dsn, $user, $password); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + return $pdo; + } +} diff --git a/tests/classes/TimeMock.php b/tests/classes/TimeMock.php new file mode 100644 index 00000000..bd880bc8 --- /dev/null +++ b/tests/classes/TimeMock.php @@ -0,0 +1,54 @@ + + */ +class TimeMock +{ + + /** + * @var int + */ + private static $time = null; + + public static function time() + { + return is_null(self::$time) ? \time() : self::$time; + } + + /** + * Disable mocking of the time. + */ + public static function disable() + { + self::$time = null; + } + + /** + * Sets the moc time. + * + * @param int $time moc time + */ + public static function setTime($time) + { + return self::$time = $time; + } +} diff --git a/classes/class/BAV_ClassFile.php b/tests/classes/class/ClassFile.php similarity index 69% rename from classes/class/BAV_ClassFile.php rename to tests/classes/class/ClassFile.php index bcc16928..966c2f9d 100644 --- a/classes/class/BAV_ClassFile.php +++ b/tests/classes/class/ClassFile.php @@ -1,8 +1,6 @@ path = $path; - $this->name = basename($path, '.php'); - - + private function __construct($path) + { + $this->path = $path; + $this->name = basename($path, '.php'); + + /** * Load the class definition */ require_once $this->path; - - + + /** * check parent class */ preg_match_all(':extends +([a-zA-Z0-9_]+):', $this->getClassDefinition(), $matches); foreach ($matches[1] as $match) { if (! isset($this->neededClasses[$match])) { - throw new BAV_ClassFileException_MissingClass($this->name, $match); - + throw new MissingClassException($this->name, $match); + } $this->parent = $this->neededClasses[$match]; $this->neededClasses['parent'] = $this->parent; break; } - - + + /** * check needed classes */ preg_match_all(':new +([a-zA-Z0-9_]+)\(:', $this->getClassDefinition(), $matchesNew); - preg_match_all('/([a-zA-Z0-9_]+)::/', $this->getClassDefinition(), $matchesStatic); + preg_match_all('/([a-zA-Z0-9_]+)::/', $this->getClassDefinition(), $matchesStatic); foreach (array_merge($matchesNew[1], $matchesStatic[1]) as $match) { if (! isset($this->neededClasses[$match])) { - throw new BAV_ClassFileException_MissingClass($this->name, $match); - + throw new MissingClassException($this->name, $match); + } } } + /** - * @throws BAV_ClassFileException_MissingClass + * @throws MissingClassException * @param string $path - * @return BAV_ClassFile + * @return ClassFile */ - static public function getClassFile($path) { + public static function getClassFile($path) + { if (! isset(self::$instances[$path])) { self::$instances[$path] = new self($path); - + } return self::$instances[$path]; } + /** - * @throws BAV_ClassFileException_IO - * @throws BAV_ClassFileException_MissingClass + * @throws ClassFileIOException + * @throws MissingClassException * @param string $dir - * @return array BAV_ClassFile objects + * @return array ClassFile objects */ - static public function getClassFiles($dir) { + public static function getClassFiles($dir) + { $classFiles = array(); $dh = opendir($dir); if (! $dh) { - throw new BAV_ClassFileException_IO(); - + throw new ClassFileIOException(); + } while (($file = readdir($dh)) !== false) { $path = $dir.$file; if (is_file($path)) { $classFiles[] = self::getClassFile($path); - + } } closedir($dh); return $classFiles; } + /** * @return BAV a new instance of {@link $name} */ - public function getInstance() { + public function getInstance() + { if (func_num_args() == 0) { return new $this->name(); } $argStr = ''; $args = func_get_args(); - for($i = 0; $i < func_num_args(); $i++) { + for ($i = 0; $i < func_num_args(); $i++) { $argStr .= '$args['.$i.'], '; } eval('$instance = new $this->name('.substr($argStr, 0, -2).');'); return $instance; } + /** - * @throws BAV_ClassFileException_IO + * @throws ClassFileIOException * @return string */ - public function getClassDefinition() { + public function getClassDefinition() + { if (is_null($this->classDefinition)) { $this->classDefinition = ''; $fp = fopen($this->path, 'r'); if (! $fp) { - throw new BAV_ClassFileException_IO(); - + throw new ClassFileIOException(); + } $this->classDefinition = fread($fp, filesize($this->path)); fclose($fp); - - + + /** * delete comments */ $this->classDefinition = preg_replace('_/\*.*\*/_sU', '', $this->classDefinition); - + } return $this->classDefinition; } + /** * @return string */ - public function getName() { + public function getName() + { return $this->name; } - - -} - - -?> \ No newline at end of file +} diff --git a/classes/class/exception/BAV_ClassFileException_IO.php b/tests/classes/class/exception/ClassFileException.php similarity index 92% rename from classes/class/exception/BAV_ClassFileException_IO.php rename to tests/classes/class/exception/ClassFileException.php index 4129da41..81adac0e 100644 --- a/classes/class/exception/BAV_ClassFileException_IO.php +++ b/tests/classes/class/exception/ClassFileException.php @@ -1,6 +1,6 @@ @@ -25,10 +25,8 @@ * @author Markus Malkusch * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_ClassFileException_IO extends BAV_ClassFileException { +class ClassFileException extends BAVException +{ } - - -?> \ No newline at end of file diff --git a/classes/class/exception/BAV_ClassFileException.php b/tests/classes/class/exception/ClassFileIOException.php similarity index 92% rename from classes/class/exception/BAV_ClassFileException.php rename to tests/classes/class/exception/ClassFileIOException.php index a2ec7929..cfd29481 100644 --- a/classes/class/exception/BAV_ClassFileException.php +++ b/tests/classes/class/exception/ClassFileIOException.php @@ -1,5 +1,6 @@ @@ -24,10 +25,8 @@ * @author Markus Malkusch * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_ClassFileException extends RuntimeException { +class ClassFileIOException extends ClassFileException +{ } - - -?> \ No newline at end of file diff --git a/classes/class/exception/BAV_ClassFileException_MissingClass.php b/tests/classes/class/exception/MissingClassException.php similarity index 81% rename from classes/class/exception/BAV_ClassFileException_MissingClass.php rename to tests/classes/class/exception/MissingClassException.php index bd1ad691..a338a4f1 100644 --- a/classes/class/exception/BAV_ClassFileException_MissingClass.php +++ b/tests/classes/class/exception/MissingClassException.php @@ -1,6 +1,6 @@ @@ -25,43 +25,42 @@ * @author Markus Malkusch * @copyright Copyright (C) 2006 Markus Malkusch */ -class BAV_ClassFileException_MissingClass extends BAV_ClassFileException { - +class MissingClassException extends ClassFileException +{ - private /** * @var string */ - $className = '', + private $className = ''; + /** * @var string */ - $missingClassName = ''; - - + private $missingClassName = ''; + /** * @param string $className * @param string $missingClassName */ - public function __construct($className, $missingClassName) { + public function __construct($className, $missingClassName) + { $this->className = $className; $this->missingClassName = $missingClassName; } + /** * @return string */ - public function getClassName() { + public function getClassName() + { return $this->className; } + /** * @return string */ - public function getMissingClassName() { + public function getMissingClassName() + { return $this->missingClassName; } - - } - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/BAV_TestAPI_BAV.php b/tests/classes/testAPI/BAVTestAPI.php similarity index 65% rename from classes/verify/testAPI/BAV_TestAPI_BAV.php rename to tests/classes/testAPI/BAVTestAPI.php index 9d76d272..035e70d4 100644 --- a/classes/verify/testAPI/BAV_TestAPI_BAV.php +++ b/tests/classes/testAPI/BAVTestAPI.php @@ -1,8 +1,6 @@ * @copyright Copyright (C) 2009 Markus Malkusch */ -class BAV_TestAPI_BAV extends BAV_TestAPI { - - - public function __construct() { - parent::__construct(); - - $this->setName("bav"); +class BAVTestAPI extends TestAPI +{ + + public function __construct() + { + parent::__construct(); + + $this->setName("bav"); + } + + /** + * Returns true if the API is available. + * + * @return bool + */ + protected function isAvailable() + { + return true; } - - - /** - * @param int $bankCode - * @param int $account - * @return bool - * @throws BAV_TestAPIException_Validation_BankNotFound - */ - protected function isValid(BAV_Bank $bank, $account) { - try { + + /** + * @param int $bankCode + * @param int $account + * @return bool + * @throws BankNotFoundTestAPIException + */ + protected function isValid(Bank $bank, $account) + { + try { return $bank->isValid($account); - - } catch (Exception $e) { + + } catch (Exception $e) { echo $e->getMessage(), "\n", $e->getTraceAsString(); exit(1); - - } - } - - -} - -?> \ No newline at end of file + } + } +} diff --git a/tests/classes/testAPI/KontocheckTestAPI.php b/tests/classes/testAPI/KontocheckTestAPI.php new file mode 100644 index 00000000..7c81e0a8 --- /dev/null +++ b/tests/classes/testAPI/KontocheckTestAPI.php @@ -0,0 +1,114 @@ + + * @link http://sourceforge.net/projects/kontocheck/ + */ +class KontocheckTestAPI extends TestAPI +{ + + const NOT_INITIALIZED = -40; + const BANK_NOT_FOUND = -4; + const INVALID_NULL = -12; + const INVALID_KTO = -3; + const INVALID_FALSE = 0; + + /** + * @param String $lutFile + * @param int $lutVersion + * @throws TestAPIException + * @throws TestAPIUnavailableException + */ + public function __construct($lutFile = null, $lutVersion = null) + { + parent::__construct(); + + $this->setName("kc"); + + if (is_null($lutFile)) { + $lutFile = __DIR__ . "/../../data/blz.lut2"; + + } + + if (is_null($lutVersion)) { + $lutVersion = 2; + + } + + if (! lut_init($lutFile, $lutVersion)) { + throw new TestAPIException("Could not initialize LUT."); + + } + } + + /** + * Return true for known false positives. + * + * @return true + */ + public function ignoreTestCase(Bank $bank, $account) + { + // http://sourceforge.net/p/kontocheck/bugs/11/ + if ($bank->getBankID() == "80063508") { + return true; + + } + + // http://sourceforge.net/p/kontocheck/bugs/12/ + if ($bank->getValidationType() == "90") { + return true; + + } + + return parent::ignoreTestCase($bank, $account); + } + + /** + * Returns true if the API is available. + * + * @return bool + */ + protected function isAvailable() + { + return function_exists("lut_init"); + } + + /** + * @param int $bank + * @param int $account + * @return bool + * @throws ValidationTestAPIException + * @throws NotInitializedTestAPIException + * @throws BankNotFoundTestAPIException + */ + protected function isValid(Bank $bank, $account) + { + $isValid = kto_check_blz($bank->getBankID(), $account); + + switch ($isValid) { + case self::NOT_INITIALIZED: + throw new NotInitializedTestAPIException("LUT not initialized"); + + case self::BANK_NOT_FOUND: + throw new BankNotFoundTestAPIException($bank->getBankID()); + + case self::INVALID_NULL: + case self::INVALID_KTO: + case self::INVALID_FALSE: + return false; + + default: + if ($isValid < 0) { + throw new ValidationTestAPIException("unknown code $isValid"); + + } + return true; + + } + } +} diff --git a/tests/classes/testAPI/KtoblzcheckTestAPI.php b/tests/classes/testAPI/KtoblzcheckTestAPI.php new file mode 100644 index 00000000..3963d2a2 --- /dev/null +++ b/tests/classes/testAPI/KtoblzcheckTestAPI.php @@ -0,0 +1,119 @@ + + * @license WTFPL + * @link http://sourceforge.net/projects/ktoblzcheck/ + */ +class KtoblzcheckTestAPI extends TestAPI +{ + + const BINARY = "ktoblzcheck"; + const VALID = 0; + const INVALID = 2; + const BANK_NOT_FOUND = 3; + + /** + * @var String + */ + private $binary = ''; + + /** + * @var String + */ + private $bankdata = ''; + + /** + * @param String $bankdata + * @param String $binary + * @throws TestAPIException + */ + public function __construct($bankdata = null, $binary = null) + { + if (! is_null($bankdata)) { + $this->bankdata = realpath($bankdata); + + } + $this->binary = is_null($binary) ? self::BINARY : realpath($binary); + + parent::__construct(); + $this->setName("ktoblzcheck"); + } + + /** + * Return true for known false positives. + * + * Version 1.45 has many false positives. + * + * @return true + */ + public function ignoreTestCase(Bank $bank, $account) + { + if ($account == 0) { + return true; + + } + + /* In version 1.45 those do differ: + * + * bank: 28570092 method: 63 account: 5 bav: valid kc: valid ktoblzcheck: invalid + * bank: 76026000 method: C7 account: 5 bav: valid kc: valid ktoblzcheck: invalid + * bank: 30022000 method: 08 account: 5 bav: invalid kc: invalid ktoblzcheck: valid + * bank: 80063508 method: 09 account: 30 bav: valid ktoblzcheck: invalid + * bank: 22230023 method: 68 account: 26 bav: invalid kc: invalid ktoblzcheck: valid + * AccountNumberCheck::check: Specified method 'E1' is unknown + * bank: 36050105 method: 78 account: 30 bav: invalid kc: invalid ktoblzcheck: valid + */ + $falsePositives = array("63", "C7", "08", "09", "68", "E1", "78"); + if (in_array($bank->getValidationType(), array($falsePositives))) { + return true; + + } + + return parent::ignoreTestCase($bank, $account); + } + + /** + * Returns true if the API is available. + * + * @return bool + */ + protected function isAvailable() + { + exec("$this->binary --version", $out, $result); + return $result === 0; + } + + /** + * @param int $account + * @return bool + * @throws ValidationTestAPIException + * @throws NotInitializedTestAPIException + * @throws BankNotFoundTestAPIException + */ + protected function isValid(Bank $bank, $account) + { + $fileParam = empty($this->bankdata) ? '' : "--file=$this->bankdata"; + $cmd = "$this->binary $fileParam '{$bank->getBankID()}' '$account'"; + exec($cmd, $out, $result); + + switch ($result) { + case self::VALID: + return true; + + case self::INVALID: + return false; + + case self::BANK_NOT_FOUND: + throw new BankNotFoundTestAPIException("Bank not found: {$bank->getBankID()}"); + + default: + throw new ValidationTestAPIException("unknown code $result: " . implode("\n", $out)); + + } + } +} diff --git a/tests/classes/testAPI/TestAPI.php b/tests/classes/testAPI/TestAPI.php new file mode 100644 index 00000000..1e5a11ee --- /dev/null +++ b/tests/classes/testAPI/TestAPI.php @@ -0,0 +1,112 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @package classes + * @subpackage verify + * @author Markus Malkusch + * @copyright Copyright (C) 2009 Markus Malkusch + */ +abstract class TestAPI +{ + + /** + * @var String + */ + private $name = ''; + + /** + * @param int $account + * @return bool + * @throws ValidationTestAPIException + */ + abstract protected function isValid(Bank $bank, $account); + + /** + * Returns true if the API is available. + * + * @return bool + */ + abstract protected function isAvailable(); + + /** + * Return true for known false positives. + * + * @return true + */ + public function ignoreTestCase(Bank $bank, $account) + { + return false; + } + + /** + * @throws TestAPIUnavailableException + */ + public function __construct() + { + $this->setName(get_class($this)); + + if (! $this->isAvailable()) { + throw new TestAPIUnavailableException(); + + } + } + + /** + * @param string $name + */ + protected function setName($name) + { + $this->name = $name; + } + + /** + * @param int $account + * @return TestAPIResult + */ + public function getResult(Bank $bank, $account) + { + try { + $result = $this->isValid($bank, $account) + ? TestAPIResult::VALID + : TestAPIResult::INVALID; + return new TestAPIResult($this, $result); + + } catch (Exception $e) { + return new TestAPIErrorResult( + $this, + TestAPIResult::ERROR, + $e->getMessage() + ); + + } + } + + /** + * @return String + */ + public function getName() + { + return $this->name; + } +} diff --git a/classes/verify/testAPI/BAV_TestAPIResult_Error.php b/tests/classes/testAPI/TestAPIErrorResult.php similarity index 69% rename from classes/verify/testAPI/BAV_TestAPIResult_Error.php rename to tests/classes/testAPI/TestAPIErrorResult.php index 40e65a42..571fe8de 100644 --- a/classes/verify/testAPI/BAV_TestAPIResult_Error.php +++ b/tests/classes/testAPI/TestAPIErrorResult.php @@ -1,7 +1,6 @@ @@ -19,45 +18,37 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * * @package classes * @subpackage verify * @author Markus Malkusch * @copyright Copyright (C) 2009 Markus Malkusch */ +class TestAPIErrorResult extends TestAPIResult +{ + /** + * @var String + */ + private $message = ''; -class BAV_TestAPIResult_Error extends BAV_TestAPIResult { + /** + * @param TestAPI $testAPI + * @param int $result + * @param String $message + */ + public function __construct(TestAPI $testAPI, $result, $message = '') + { + parent::__construct($testAPI, $result); + + $this->message = $message; + } - - private - /** - * @var String - */ - $message = ''; - - - /** - * @param BAV_TestAPI $testAPI - * @param int $result - * @param String $message - */ - public function __construct(BAV_TestAPI $testAPI, $result, $message = '') { - parent::__construct($testAPI, $result); - - $this->message = $message; - } - - /** * @return String */ - public function getMessage() { + public function getMessage() + { return $this->message; } - - } - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/BAV_TestAPIResult.php b/tests/classes/testAPI/TestAPIResult.php similarity index 66% rename from classes/verify/testAPI/BAV_TestAPIResult.php rename to tests/classes/testAPI/TestAPIResult.php index 52d249d3..f9c2e1b9 100644 --- a/classes/verify/testAPI/BAV_TestAPIResult.php +++ b/tests/classes/testAPI/TestAPIResult.php @@ -1,8 +1,6 @@ @@ -20,61 +18,52 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * * @package classes * @subpackage verify * @author Markus Malkusch * @copyright Copyright (C) 2009 Markus Malkusch */ +class TestAPIResult +{ - -class BAV_TestAPIResult extends BAV { - - - const VALID = 1; + const VALID = 1; const INVALID = 2; const BANK_NOT_FOUND = 3; const ERROR = 4; - - - private - /** - * @var BAV_TestAPI - */ - $testAPI, - /** - * @var int - */ - $result; - - - /** - * @param BAV_TestAPI $testAPI - * @param int $result - */ - public function __construct(BAV_TestAPI $testAPI, $result) { - $this->testAPI = $testAPI; - $this->result = $result; - } - - - /** - * @return BAV_TestAPI - */ - public function getTestAPI() { - return $this->testAPI; - } - - + + /** + * @var TestAPI + */ + private $testAPI; + /** + * @var int + */ + private $result; + + /** + * @param TestAPI $testAPI + * @param int $result + */ + public function __construct(TestAPI $testAPI, $result) + { + $this->testAPI = $testAPI; + $this->result = $result; + } + + /** + * @return TestAPI + */ + public function getTestAPI() + { + return $this->testAPI; + } + /** * @return int */ - public function getResult() { + public function getResult() + { return $this->result; } - - } - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/exception/BAV_TestAPIException_Validation_BankNotFound.php b/tests/classes/testAPI/exception/BankNotFoundTestAPIException.php similarity index 90% rename from classes/verify/testAPI/exception/BAV_TestAPIException_Validation_BankNotFound.php rename to tests/classes/testAPI/exception/BankNotFoundTestAPIException.php index 80402259..0c4757ed 100644 --- a/classes/verify/testAPI/exception/BAV_TestAPIException_Validation_BankNotFound.php +++ b/tests/classes/testAPI/exception/BankNotFoundTestAPIException.php @@ -1,5 +1,6 @@ @@ -24,10 +25,7 @@ * @author Markus Malkusch * @copyright Copyright (C) 2009 Markus Malkusch */ -class BAV_TestAPIException_Validation_BankNotFound extends BAV_TestAPIException_Validation { - +class BankNotFoundTestAPIException extends ValidationTestAPIException +{ } - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/exception/BAV_TestAPIException_Validation_NotInitialized.php b/tests/classes/testAPI/exception/NotInitializedTestAPIException.php similarity index 90% rename from classes/verify/testAPI/exception/BAV_TestAPIException_Validation_NotInitialized.php rename to tests/classes/testAPI/exception/NotInitializedTestAPIException.php index c5817248..ed0c4f0a 100644 --- a/classes/verify/testAPI/exception/BAV_TestAPIException_Validation_NotInitialized.php +++ b/tests/classes/testAPI/exception/NotInitializedTestAPIException.php @@ -1,5 +1,6 @@ @@ -24,10 +25,7 @@ * @author Markus Malkusch * @copyright Copyright (C) 2009 Markus Malkusch */ -class BAV_TestAPIException_Validation_NotInitialized extends BAV_TestAPIException_Validation { - +class NotInitializedTestAPIException extends ValidationTestAPIException +{ } - - -?> \ No newline at end of file diff --git a/classes/verify/testAPI/exception/BAV_TestAPIException.php b/tests/classes/testAPI/exception/TestAPIException.php similarity index 93% rename from classes/verify/testAPI/exception/BAV_TestAPIException.php rename to tests/classes/testAPI/exception/TestAPIException.php index 14bda328..235caf92 100644 --- a/classes/verify/testAPI/exception/BAV_TestAPIException.php +++ b/tests/classes/testAPI/exception/TestAPIException.php @@ -1,4 +1,7 @@ * @@ -22,10 +25,7 @@ * @author Markus Malkusch * @copyright Copyright (C) 2009 Markus Malkusch */ -class BAV_TestAPIException extends RuntimeException { - +class TestAPIException extends BAVException +{ } - - -?> \ No newline at end of file diff --git a/tests/classes/testAPI/exception/TestAPIUnavailableException.php b/tests/classes/testAPI/exception/TestAPIUnavailableException.php new file mode 100644 index 00000000..65237e28 --- /dev/null +++ b/tests/classes/testAPI/exception/TestAPIUnavailableException.php @@ -0,0 +1,14 @@ + + * @license WTFPL + */ +class TestAPIUnavailableException extends TestAPIException +{ + +} diff --git a/classes/verify/testAPI/exception/BAV_TestAPIException_Validation.php b/tests/classes/testAPI/exception/ValidationTestAPIException.php similarity index 91% rename from classes/verify/testAPI/exception/BAV_TestAPIException_Validation.php rename to tests/classes/testAPI/exception/ValidationTestAPIException.php index 0bf21f80..a272fe3d 100644 --- a/classes/verify/testAPI/exception/BAV_TestAPIException_Validation.php +++ b/tests/classes/testAPI/exception/ValidationTestAPIException.php @@ -1,5 +1,6 @@ @@ -24,10 +25,7 @@ * @author Markus Malkusch * @copyright Copyright (C) 2009 Markus Malkusch */ -class BAV_TestAPIException_Validation extends BAV_TestAPIException { - +class ValidationTestAPIException extends TestAPIException +{ } - - -?> \ No newline at end of file diff --git a/tests/data/.gitignore b/tests/data/.gitignore new file mode 100644 index 00000000..5b2c275f --- /dev/null +++ b/tests/data/.gitignore @@ -0,0 +1,4 @@ +invalidLength.txt +invalidFirstLineContent.txt +notConstantLength.txt + diff --git a/tests/data/accounts.json b/tests/data/accounts.json new file mode 100644 index 00000000..625f03e6 --- /dev/null +++ b/tests/data/accounts.json @@ -0,0 +1,4754 @@ +[ + { + "validator": "00", + "valid": [ + "15727", + "33449", + "41921", + "75952", + "90332", + "158501", + "190967", + "199695", + "238881", + "247841", + "251348", + "283895", + "285643", + "299099", + "0000324350", + "332965", + "333286", + "334664", + "353813", + "357913", + "360289", + "363945", + "364497", + "369231", + "407437", + "409839", + "411827", + "421321", + "424010", + "425157", + "431148", + "432245", + "454413", + "464602", + "483404", + "487306", + "488544", + "512657", + "542043", + "551226", + "561563", + "565697", + "573691", + "578971", + "591842", + "602995", + "603274", + "613349", + "614578", + "616029", + "620690", + "620997", + "624148", + "630434", + "630541", + "637348", + "637439", + "639005", + "640409", + "641779", + "642744", + "646901", + "647339", + "651190", + "663799", + "666677", + "667022", + "673665", + "675801", + "679910", + "681403", + "683219", + "688424", + "710301", + "711200", + "719054", + "724302", + "733113", + "735423", + "741074", + "741496", + "741769", + "742338", + "747998", + "760975", + "769364", + "769521", + "783332", + "791095", + "793885", + "805424", + "805655", + "832196", + "835058", + "854406", + "877415", + "889733", + "904748", + "913707", + "919274", + "943928", + "966689", + "966895", + "1043777", + "1046374", + "1050004", + "1127125", + "1129790", + "1160878", + "1165315", + "0001173780", + "1206317", + "1247329", + "1263607", + "1301514", + "1423813", + "1501824", + "1501832", + "1502129", + "1512813", + "1519701", + "1554658", + "1636232", + "1670868", + "1717222", + "1795798", + "1810662", + "1813500", + "1827682", + "1870179", + "1999515", + "2007458", + "2007961", + "2052587", + "2060127", + "2095602", + "2138030", + "2159846", + "2167484", + "2192193", + "2193860", + "2206068", + "2211944", + "2240505", + "2251460", + "2277275", + "2539021", + "2542850", + "2698595", + "2737674", + "2890929", + "2933125", + "3119138", + "3148350", + "3160538", + "3187853", + "3287141", + "3292190", + "3307576", + "3485083", + "3504255", + "3621182", + "3627064", + "3743465", + "3823010", + "3900404", + "4077210", + "4129490", + "4178570", + "4224473", + "4243283", + "4281374", + "4418851", + "4446779", + "4497921", + "4520052", + "5018312", + "5030481", + "5057393", + "5108402", + "5112065", + "5116207", + "5120605", + "5123682", + "5143987", + "5219662", + "5236021", + "5241948", + "5288683", + "5304118", + "5333141", + "5341557", + "5435623", + "5515812", + "5526371", + "5526439", + "5610126", + "5658687", + "5678198", + "5680939", + "5691225", + "5779814", + "5959531", + "5973722", + "5993951", + "6100549", + "6100556", + "6145643", + "6254189", + "6408454", + "6443436", + "6651137", + "6723563", + "6752992", + "6851984", + "6945661", + "7068125", + "7130065", + "7140858", + "7249444", + "7260284", + "7261290", + "7325137", + "7416662", + "7471469", + "7502982", + "7541337", + "7574700", + "7722036", + "7728819", + "7760861", + "7845803", + "8026098", + "8060873", + "8099962", + "8105488", + "8173544", + "0008192007", + "8244014", + "8395212", + "8552580", + "8620148", + "8723546", + "8724643", + "8735987", + "8749541", + "8846230", + "8896847", + "9204967", + "9233081", + "9271842", + "9290701", + "9324997", + "9370511", + "9435140", + "9830951", + "10108124", + "10280170", + "10291177", + "10337046", + "10575124", + "10643161", + "10661916", + "10678670", + "10699650", + "10756690", + "10777712", + "10859296", + "11132743", + "11145596", + "11153392", + "11283702", + "11415270", + "12265658", + "12405304", + "12509717", + "12570602", + "12722245", + "13017132", + "13136874", + "13139811", + "14033138", + "14283394", + "14520118", + "15017775", + "16013666", + "16026320", + "16026528", + "0017185273", + "17202219", + "17346701", + "18201780", + "18507426", + "18568683", + "19609361", + "20005492", + "20131850", + "20154985", + "20242418", + "20506986", + "20511770", + "20535969", + "21021167", + "22044010", + "22053730", + "22053920", + "22231062", + "22443337", + "22595649", + "22731145", + "23106420", + "23427602", + "23650781", + "25006891", + "25634858", + "27341080", + "27643063", + "28107464", + "0029150471", + "29323086", + "30279251", + "30594576", + "30604664", + "0030658983", + "31112121", + "31453186", + "31500598", + "32102774", + "0032112906", + "33003856", + "33033820", + "33104456", + "33299876", + "35118850", + "36223766", + "36228831", + "37585908", + "38313607", + "38564621", + "40125494", + "41532045", + "43225283", + "43399641", + "43504760", + "43528348", + "43753318", + "0043774819", + "43861434", + "43906320", + "44161677", + "44323871", + "44389385", + "45103504", + "45572336", + "46515441", + "46535555", + "47017868", + "47174248", + "47224027", + "47233432", + "47235197", + "47254115", + "47457825", + "47523170", + "47844964", + "48006993", + "48479869", + "50007723", + "50023936", + "50045749", + "50084193", + "50105865", + "50127091", + "50139831", + "50297449", + "51169357", + "52108610", + "52753506", + "52955119", + "55119754", + "57273633", + "57542169", + "59104307", + "59110940", + "59177535", + "59681296", + "60406329", + "60518321", + "60601861", + "60813839", + "63144281", + "0064608540", + "65495921", + "65615502", + "67412486", + "68568039", + "69300945", + "70078951", + "71111801", + "71353098", + "71863419", + "72893175", + "74233511", + "74593732", + "78253176", + "79233755", + "80143530", + "80150436", + "080167497", + "82561721", + "82733197", + "86114667", + "87134813", + "89234884", + "90140039", + "91563197", + "92013820", + "93034403", + "100025709", + "100043959", + "100049832", + "100078484", + "100083641", + "100091511", + "100094382", + "100143585", + "100165075", + "100195544", + "100197144", + "100218197", + "100220854", + "100243765", + "100483031", + "100610344", + "100624733", + "100630052", + "100631993", + "100654888", + "100683424", + "100696251", + "100720374", + "100744382", + "100756055", + "100759158", + "100907245", + "101058832", + "101060390", + "101133478", + "101249837", + "101543379", + "101586543", + "101902070", + "101909075", + "101956167", + "102070778", + "102105145", + "102142148", + "102305265", + "102685120", + "103042503", + "103104121", + "103235982", + "103393955", + "103454252", + "103500534", + "104140280", + "104241401", + "104350111", + "104981147", + "105014237", + "105097729", + "0105100812", + "105214316", + "105302491", + "105507297", + "105535934", + "105541767", + "106021744", + "106232762", + "106726680", + "106760457", + "107090649", + "107119992", + "107147530", + "107532020", + "107557555", + "107805491", + "109064444", + "0109101980", + "109125005", + "109153049", + "109435990", + "109677245", + "110030590", + "110104874", + "110319969", + "110322468", + "111048682", + "111163325", + "111165775", + "111199279", + "112046610", + "112180450", + "113414601", + "113476915", + "0114106727", + "115057580", + "115348112", + "117069658", + "117070870", + "117076737", + "117076794", + "117213348", + "118128354", + "120015474", + "120026695", + "120751268", + "121234538", + "121313316", + "122202369", + "122802390", + "124030131", + "124101932", + "124111667", + "124398561", + "124643107", + "127077311", + "0128104320", + "128293081", + "129208716", + "129416723", + "129627832", + "129929485", + "130009285", + "130027014", + "130285679", + "130304306", + "130331184", + "131035560", + "133309252", + "133349472", + "133378299", + "133923086", + "134013366", + "134111244", + "134147693", + "134202654", + "0134225697", + "0134241199", + "134251644", + "134447309", + "0134574292", + "134581826", + "135032365", + "135211613", + "135409001", + "135430734", + "136253648", + "137316246", + "138438767", + "138715594", + "139071120", + "140021197", + "140305061", + "140639220", + "140651928", + "141332767", + "143147536", + "145013876", + "145114831", + "145887048", + "148009764", + "149007130", + "149447773", + "150496917", + "150544906", + "150582500", + "151274362", + "154026751", + "155072036", + "155743149", + "157003591", + "157052416", + "0160016010", + "161004635", + "161080007", + "161708011", + "162037733", + "0164033557", + "165012022", + "165013020", + "166009415", + "170104616", + "170720114", + "171709504", + "174027284", + "174076349", + "178183893", + "188002877", + "190020172", + "194018479", + "198024267", + "200223659", + "201076676", + "204478143", + "209876606", + "210524385", + "215006131", + "215885336", + "219018660", + "220143903", + "226304616", + "228750634", + "240086439", + "240091231", + "240310698", + "240431403", + "240768507", + "240994699", + "244729505", + "249653411", + "269919254", + "276002722", + "290056506", + "291148161", + "300012812", + "300036944", + "300220720", + "301000550", + "301015319", + "301032348", + "301039749", + "302109954", + "307043653", + "309000867", + "314024670", + "315051540", + "330205154", + "334007754", + "335009247", + "353001274", + "370068256", + "380414870", + "380614420", + "380833608", + "380843912", + "430494930", + "430563122", + "430780536", + "485755896", + "500178470", + "539290858", + "550218937", + "570611681", + "0590214789", + "0620217885", + "620422014", + "760434043", + "901124792", + "901219618", + "903147817", + "1000213676", + "1000371292", + "1000444446", + "1000687127", + "1004989305", + "1005097983", + "1006626079", + "1009183276", + "1009853704", + "1010794129", + "1011138870", + "1011223797", + "1011312814", + "1012137129", + "1012840706", + "1015819939", + "1015827148", + "1019763612", + "1022790016", + "1022817678", + "1026313013", + "1029189261", + "1032100693", + "1034784551", + "1036751418", + "1042869956", + "1043741816", + "1043762655", + "1044953659", + "1046754220", + "1048750440", + "1049782558", + "1051782363", + "1052923693", + "1058771302", + "1059762755", + "1059789840", + "1060012414", + "1077781761", + "1081034751", + "1081807057", + "1087779706", + "1100018124", + "1100112646", + "1100242328", + "1100636867", + "1111773402", + "1112213374", + "1133822898", + "1139793036", + "1152775092", + "1166413243", + "1200292595", + "1205473901", + "1216016004", + "1216519767", + "1224456879", + "1224506178", + "1233573516", + "1234493284", + "1234567897", + "1235500830", + "1238454696", + "1238500886", + "1242470613", + "1247450537", + "1247461542", + "1251466643", + "1266470861", + "1268512900", + "1278501653", + "1281444693", + "1282504925", + "1300066899", + "1305494021", + "1327489009", + "1336459050", + "1352483315", + "1352498966", + "1382515706", + "1385491970", + "1386474413", + "1386494882", + "1395490087", + "1397462332", + "1397469733", + "1398504371", + "1484538846", + "1505002889", + "1512029735", + "1512033299", + "1550025017", + "1560101782", + "1600169591", + "1600189151", + "1623259734", + "1750529941", + "1800084079", + "2001032610", + "2002621601", + "2002829808", + "2003202302", + "2003895303", + "2005074204", + "3001134703", + "3007405610", + "3007622420", + "4455667784" + ], + "invalid": [ + "6414241", + "51181008", + "71214205", + "179751314", + "1600166307", + "1600176485", + "1600201934" + ] + }, + { + "validator": "01", + "valid": [ + "26084", + "113069", + "120193", + "131429", + "158048", + "203261", + "210931", + "227003", + "314181", + "368883", + "407665", + "613765", + "658830", + "675909", + "687052", + "715058", + "717544", + "718079", + "725938", + "745420", + "746395", + "757614", + "757968", + "781879", + "785710", + "798305", + "872180", + "969419", + "993007", + "1068106", + "1323456", + "1409095", + "1410565", + "1452183", + "1713750", + "1728972", + "1794717", + "1895984", + "1928693", + "1943465", + "2015639", + "2038654", + "2069733", + "2118299", + "2144201", + "2155984", + "2157731", + "2166997", + "2168476", + "2202703", + "2204505", + "2288318", + "2434375", + "2602097", + "2645432", + "2660792", + "2669377", + "2701651", + "2711098", + "2746654", + "2854759", + "3092716", + "3128264", + "3234938", + "3240379", + "3360046", + "3441855", + "3697283", + "3734775", + "3739732", + "3757707", + "3829130", + "3854930", + "3920936", + "5023109", + "5035135", + "5249457", + "5253285", + "5289424", + "5302710", + "5334764", + "5535408", + "5547159", + "5773349", + "5833588", + "6026662", + "6247111", + "6271527", + "6309035", + "6402925", + "6404538", + "6448460", + "6818100", + "7257519", + "7307005", + "7502635", + "7676334", + "7700396", + "7932085", + "8097479", + "8152266", + "8167770", + "8207764", + "8220806", + "8321619", + "8388920", + "8517083", + "8575805", + "8701497", + "9155138", + "9766864", + "9792780", + "10003468", + "10006630", + "10092747", + "10118607", + "10203567", + "10331453", + "10600933", + "10902246", + "11011583", + "11105372", + "11179274", + "11375047", + "11431431", + "11506713", + "11534974", + "11549608", + "11610616", + "0012003624", + "15069225", + "15129983", + "0019191924", + "20407456", + "20459772", + "21153833", + "28105413", + "34115796", + "36110926", + "43107290", + "48069182", + "48288925", + "48298434", + "48298599", + "48519319", + "0049510771", + "79024598", + "79225878", + "110073075", + "110450911", + "111039922", + "111042854", + "118014957", + "400154680", + "400257769", + "440005517", + "440696483", + "520020663", + "560047950", + "650005558", + "680034142", + "800097402", + "805134315", + "930060543", + "970323226", + "7487014533", + "7808006261", + "7817001288", + "7820035928", + "7850004503", + "7855006269", + "7870026509", + "7894005393", + "7895008588" + ] + }, + { + "validator": "02", + "valid": [ + "837547", + "1207253", + "206110073", + "228036623", + "281042020" + ] + }, + { + "validator": "03", + "valid": [ + "1324235", + "0001552183", + "3524411", + "10061406", + "10180769", + "10295401", + "10309905", + "10310431", + "10311421", + "10530419", + "10556853", + "10583749", + "10627894", + "10635582", + "11091519", + "0011578088", + "16075071", + "16081482", + "18512188", + "21019866", + "21045481", + "21265980", + "29516145", + "88900850", + "91204231", + "171066238", + "201061140" + ] + }, + { + "validator": "04", + "valid": [ + "452424", + "26038154", + "100074389", + "100272431", + "101123944", + "106215383", + "112020500", + "112054960", + "118058925", + "120039954", + "120069004", + "121089335", + "129030054", + "0132055440", + "132102120", + "135011479", + "138040461", + "170109716", + "183001213", + "189055382", + "258133560", + "285024684", + "352194565", + "461095011", + "483110731", + "509017468", + "1004626229" + ] + }, + { + "validator": "05", + "valid": [ + "707332", + "715450", + "20602488", + "74451368", + "1000155103", + "1000158676", + "1000232770", + "1119059815", + "1122020909", + "1133076023", + "1143002210", + "1143020991", + "1151024604", + "1190015933", + "1191050683", + "1203108096", + "1204112751", + "1205017813", + "1243105910", + "1252001199", + "1325042959", + "1334003727", + "1395136604" + ], + "invalid": [ + "1151043211" + ] + }, + { + "validator": "06", + "valid": [ + "10987", + "38105", + "151327", + "195502", + "315508", + "397806", + "454761", + "481742", + "501905", + "704903", + "707104", + "753084", + "763608", + "868108", + "870501", + "1070908", + "1306812", + "1445308", + "1557750", + "1658565", + "2009420", + "2087715", + "2206102", + "2406608", + "2420600", + "2434709", + "2657406", + "2838010", + "3081702", + "3151468", + "3320502", + "3380009", + "3574512", + "3684954", + "4007409", + "4190203", + "4194446", + "4286502", + "4366018", + "4369939", + "4398408", + "4543378", + "4563492", + "4833333", + "5110904", + "5220009", + "5263530", + "5395704", + "5582407", + "5847010", + "6011306", + "6014607", + "6194605", + "6205208", + "6306209", + "6406300", + "9082107", + "10038219", + "10041007", + "10391741", + "11142907", + "11312012", + "11731317", + "12036701", + "12128800", + "14179704", + "15253401", + "17600010", + "18050714", + "18090171", + "20009578", + "20095601", + "21221805", + "21287008", + "21525308", + "22073001", + "22184202", + "22208802", + "22550608", + "23605600", + "26129400", + "30093801", + "31143306", + "032017711", + "33103409", + "33250266", + "33276591", + "33439377", + "34222665", + "37082805", + "37098302", + "38005642", + "38121405", + "42912808", + "54785208", + "58451304", + "60006059", + "60010501", + "60561702", + "60789401", + "63961906", + "64132407", + "65448017", + "70004755", + "70959003", + "71466019", + "74157920", + "75034202", + "76138125", + "0076940576", + "77373608", + "78411910", + "79118508", + "94012341", + "100677580", + "101981908", + "102029305", + "102094816", + "102115783", + "102123921", + "106036080", + "106269807", + "107743103", + "107794018", + "108053429", + "110596600", + "113087005", + "120313100", + "122009440", + "124058384", + "126229402", + "129115408", + "132491909", + "0136091204", + "139098609", + "140933007", + "142081059", + "148015120", + "150204402", + "0151014615", + "162099949", + "167522807", + "201677009", + "202102301", + "212123153", + "300257488", + "302284016", + "316025803", + "0332061151", + "352029106", + "400978344", + "402626020", + "442087725", + "455643694", + "464958657", + "472028030", + "502350013", + "600449010", + "604534011", + "700894010", + "704151012", + "800693012", + "0822132146", + "912049876", + "932062453", + "1000076917", + "1000141077", + "1000401621", + "1002002694", + "1004455017", + "1005719018", + "1007510019", + "1010017900", + "1011056489", + "1011058627", + "1012057918", + "1017551007", + "1017984000", + "1070019317", + "1104002621", + "1110016782", + "1151022525", + "1160016996", + "1202318025", + "1305964014", + "1401197016", + "1404594016", + "1440553024", + "1505051013", + "1604360010", + "2103064018", + "2200194015", + "2300528018", + "2501392017", + "2700165011", + "3027527018", + "3084786003", + "3190874000", + "3301012011", + "3500818017", + "3608074014", + "3611790200", + "3806419000", + "3901322006", + "4030490202", + "4031242300", + "4217071904", + "4273366011", + "4401416736", + "4805013007", + "5071411003", + "5073321010", + "5203248018", + "5417939000", + "5500226015", + "5910849001", + "5948188009", + "6715561008", + "6889719000", + "7016101006", + "7018052002", + "7022656001", + "7029259008", + "7042509005", + "7087604009", + "7101991002", + "7168541001", + "7504535015", + "7800903003", + "8214910200", + "8705406007", + "9602494036" + ] + }, + { + "validator": "07", + "valid": [ + "100521509", + "100529704", + "114082618" + ] + }, + { + "validator": "08", + "valid": [ + "000000001", + "000000002", + "000059998", + "000059999" + ] + }, + { + "validator": "09", + "valid": [ + "076187", + "348754", + "532061", + "534684", + "1542321", + "1716002", + "5344401", + "0010487098", + "13263033", + "0224032555", + "289388600", + "363935500", + "0365090255", + "0601803230", + "0603545730", + "0827910430", + "851194900", + "1500807210", + "1501525610", + "2825252001", + "3012082935" + ] + }, + { + "validator": "A0", + "valid": [ + "3287", + "18761", + "28290", + "54500", + "521003287" + ] + }, + { + "validator": "A1", + "valid": [ + "0010030005", + "0010030997", + "1010030054" + ], + "invalid": [ + "0000030005", + "0010030998", + "0110030005" + ] + }, + { + "validator": "A2", + "valid": [ + "461954", + "100059583", + "111017588", + "118010529", + "170017107", + "215108716", + "3456789012", + "3456789019", + "5678901231", + "6789012348" + ], + "invalid": [ + "0123456789", + "1234567890" + ] + }, + { + "validator": "A3", + "valid": [ + "12106810", + "12835781", + "14490706", + "15895793", + "16474511", + "18952178", + "22721142", + "22943145", + "29804108", + "30181232", + "103338646", + "106300569", + "107341166", + "111354734", + "119284073", + "0123456782", + "0123456789", + "134164664", + "139011761", + "1142995800", + "1155783002", + "1234567890", + "1234567897", + "2110641665", + "9876543210" + ], + "invalid": [ + "0543216789", + "6543217890" + ] + }, + { + "validator": "A4", + "valid": [ + "0000862342", + "0000905844", + "0001123458", + "0004711172", + "0004711173", + "0007093330", + "0007093335", + "0664040000", + "1199503010", + "1299503117", + "5030101099", + "8499421235", + "8997710000" + ], + "invalid": [ + "0000399443", + "0000553313", + "6099702031" + ] + }, + { + "validator": "A5", + "valid": [ + "0000051640", + "0000159590", + "0000251437", + "0007948344", + "750176844", + "9380027210", + "9932290910", + "9941510001", + "9961230019" + ], + "invalid": [ + "0000251438", + "000798345", + "9941510002", + "9961230020" + ] + }, + { + "validator": "A6", + "valid": [ + "17", + "55300030", + "150178033", + "600003555", + "800048548", + "0855000014", + "900291823" + ], + "invalid": [ + "305888", + "200071280", + "810033652", + "860000817" + ] + }, + { + "validator": "A7", + "valid": [ + "19010008", + "19010438", + "19010660", + "19010876", + "209010892" + ], + "invalid": [ + "209010893" + ] + }, + { + "validator": "A8", + "valid": [ + "1340967", + "1359100", + "2812584", + "3066045", + "3122972", + "3173283", + "3388344", + "3464075", + "3503398", + "3560279", + "5177022", + "5645956", + "6906028", + "7015798", + "7436660", + "7436661", + "7436670", + "7436678", + "8911428", + "199100002", + "199100004", + "2599100003", + "3199204090", + "3199500501" + ], + "invalid": [ + "1340966", + "3503391", + "7436666", + "7436677", + "9934567", + "99100110", + "99345678", + "199100040", + "3199500502" + ] + }, + { + "validator": "A9", + "valid": [ + "86725", + "87700", + "504360", + "822035", + "5043608", + "5114348", + "32577083" + ], + "invalid": [ + "86724", + "292497", + "30767208" + ] + }, + { + "validator": "B0", + "valid": [ + "1000000406", + "1000000606", + "1035791538", + "1126939724", + "1197423162", + "1197423460" + ], + "invalid": [ + "51234309", + "51234901", + "535791830", + "600000606", + "1000000405", + "1035791539", + "8035791532", + "8137423260" + ] + }, + { + "validator": "B1", + "valid": [ + "1434253150", + "2746315471", + "7414398260", + "8347251693" + ], + "invalid": [ + "0123456789", + "2345678901", + "5678901234" + ] + }, + { + "validator": "B2", + "valid": [ + "0020012357", + "21086079", + "21284318", + "23006358", + "0080012345", + "0926801910", + "1002345674", + "8000990054", + "9000481805" + ], + "invalid": [ + "0020012399", + "0080012347", + "0080012370", + "0932100027", + "3310123454", + "8000990057", + "8011000126", + "9000481800", + "9980480111" + ] + }, + { + "validator": "B3", + "valid": [ + "19", + "140", + "1000000060", + "1002798417", + "8409915001", + "9635000101", + "9730200100" + ], + "invalid": [ + "2799899", + "1000000111", + "9635100101", + "9730300100" + ] + }, + { + "validator": "B4", + "valid": [ + "51640", + "251437", + "7948344", + "9380027210", + "9932290910", + "9941510001", + "9961230019" + ], + "invalid": [ + "159590", + "251438", + "7948345", + "9941510002", + "9961230020" + ] + }, + { + "validator": "B5", + "valid": [ + "0123456782", + "0130098767", + "0159006955", + "1045000252", + "1151043216", + "2000123451", + "9000939033" + ], + "invalid": [ + "0023456787", + "0056789018", + "0159004165", + "2345678901", + "3045000333", + "5678901234", + "7414398260", + "8347251693", + "9000293707" + ] + }, + { + "validator": "B6", + "valid": [ + "0269876545", + "9110000000" + ], + "invalid": [ + "0269456780", + "9111000000" + ] + }, + { + "validator": "B7", + "valid": [ + "0001001008", + "0001007222", + "0001057887", + "0005922372", + "0700001529", + "0730000019", + "0800107653", + "0810011825" + ], + "invalid": [ + "0001057886", + "0003815570", + "0005620516", + "0740912243", + "0893524479" + ] + }, + { + "validator": "B8", + "valid": [ + "0734192657", + "2938692523", + "3145863029", + "5432198760", + "6932875274", + "9070873333" + ], + "invalid": [ + "0132572975", + "9000412340", + "9310305011" + ] + }, + { + "validator": "B9", + "valid": [ + "1253657", + "4353631", + "7125633", + "41203755", + "58467232", + "61287958", + "81069577", + "87920187" + ], + "invalid": [ + "2356412", + "5435886", + "9435414", + "43025432", + "54352684", + "61256523", + "86521362", + "88034023" + ] + }, + { + "validator": "C1", + "valid": [ + "0446786040", + "0478046940", + "0701625830", + "0701625840", + "0882095630", + "5432112349", + "5543223456", + "5654334563", + "5765445670", + "5876556788" + ], + "invalid": [ + "0446786240", + "0478046340", + "0701625440", + "0701625730", + "0882095130", + "5432112341", + "5543223458", + "5654334565", + "5765445672", + "5876556780" + ] + }, + { + "validator": "C2", + "valid": [ + "2394871426", + "4218461950", + "5127485166", + "7352569148", + "8738142564" + ], + "invalid": [ + "0328705282", + "9024675131" + ] + }, + { + "validator": "C3", + "valid": [ + "19919", + "4431276", + "9294182", + "9000010006", + "9000420530", + "9000577650" + ], + "invalid": [ + "17002", + "122448", + "123451", + "9000731120", + "9000733227", + "9000734028" + ] + }, + { + "validator": "C4", + "valid": [ + "0000000019", + "0000094455", + "0000292932", + "9000010006", + "9000420530", + "9000577650" + ], + "invalid": [ + "0000000017", + "0000094459", + "0000292933", + "9000726558", + "9000732000", + "9001733457" + ] + }, + { + "validator": "C5", + "valid": [ + "0000301168", + "0000302554", + "0300020050", + "0300566000", + "1000061378", + "1000061412", + "3060188103", + "3070402023", + "4450164064", + "4863476104", + "5000000028", + "5000000391", + "6450008149", + "6800001016", + "9000100012", + "9000210017" + ], + "invalid": [ + "0000302589", + "0000507336", + "0302555000", + "0302589000", + "1000061457", + "1000061498", + "3081000783", + "3081308871", + "4864446015", + "4865038012", + "5000001028", + "5000001075", + "6450008150", + "6542812818", + "9000110012", + "9000300310" + ] + }, + { + "validator": "C6", + "valid": [ + "0000065516", + "0203178249", + "1031405209", + "1082012201", + "2003455189", + "2004001016", + "3068459207", + "3110150986", + "4012660028", + "4100235626", + "5035105948", + "5286102149", + "6028426119", + "6861001755", + "7000202027", + "7002000023", + "7008199027", + "8526080015", + "8711072264", + "9000430223", + "9000781153" + ], + "invalid": [ + "0091423614", + "0525111212", + "1000118821", + "1082311275", + "2004306518", + "2016001206", + "3462816371", + "3622548632", + "4000456126", + "4232300158", + "5002684526", + "5564123850", + "6295473774", + "6640806317", + "7000062022", + "7006003027", + "8348300002", + "8654216984", + "9000260986", + "9000641509" + ] + }, + { + "validator": "C7", + "valid": [ + "3500022", + "38150900", + "39101181", + "94012341", + "600103660", + "5073321010" + ], + "invalid": [ + "987614325", + "1234517892" + ] + }, + { + "validator": "C8", + "valid": [ + "0022007130", + "0123456789", + "0552071285", + "3456789012", + "3456789019", + "5678901231" + ], + "invalid": [ + "1234567890", + "9012345678" + ] + }, + { + "validator": "C9", + "valid": [ + "0123456789", + "3456789019", + "5678901231" + ], + "invalid": [ + "1234567890", + "3456789012", + "9012345678" + ] + }, + { + "validator": "D0", + "valid": [ + "5700000000", + "5710000000", + "5799999999", + "6100272324", + "6100273479" + ], + "invalid": [ + "6100272885", + "6100273377", + "6100274012" + ] + }, + { + "validator": "D1", + "valid": [ + "0082012203", + "1452683581", + "2129642505", + "3002000027", + "4230001407", + "5000065514", + "6001526215", + "7126502149", + "9000430223" + ], + "invalid": [ + "0000260986", + "1062813622", + "2256412314", + "3012084101", + "4006003027", + "5814500990", + "6128462594", + "7000062035", + "8003306026", + "9000641509" + ] + }, + { + "validator": "D2", + "valid": [ + "51181008", + "71214205", + "189912137", + "235308215", + "1234567897", + "4455667784" + ], + "invalid": [ + "6414241", + "179751314" + ] + }, + { + "validator": "D3", + "valid": [ + "1600169591", + "1600189151", + "1800084079", + "6019937007", + "6021354007", + "6030642006" + ], + "invalid": [ + "6019835001", + "6025017009", + "6028267003" + ] + }, + { + "validator": "D4", + "valid": [ + "1112048219", + "2024601814", + "3000005012", + "4143406984", + "5926485111", + "6286304975", + "7900256617", + "8102228628", + "9002364588" + ], + "invalid": [ + "0359432843", + "1000062023", + "2204271250", + "3051681017", + "4000123456", + "5212744564", + "6286420010", + "7859103459", + "8003306026", + "9916524534" + ] + }, + { + "validator": "D5", + "valid": [ + "0000100062", + "0000100088", + "0000127787", + "0004711172", + "0004711173", + "0007093330", + "0007093335", + "0099632004", + "1799222116", + "5999718138" + ], + "invalid": [ + "0000100084", + "0000100085", + "0001123458", + "0399242139", + "1999204293", + "3299632008", + "8623420004" + ] + }, + { + "validator": "D6", + "valid": [ + "3409", + "585327", + "1650513", + "3601671056", + "4402001046", + "6100268241", + "7001000681", + "9000111105", + "9001291005" + ], + "invalid": [ + "33394", + "595795", + "16400501", + "3615071237", + "6039267013", + "6039316014", + "7004017653", + "9002720007", + "9017483524" + ] + }, + { + "validator": "D7", + "valid": [ + "0134637709", + "0201005939", + "0230103715", + "0301000434", + "0330035104", + "0420001202", + "0500018205", + "0602006999" + ], + "invalid": [ + "0135638809", + "0202005939", + "0231307867", + "0301005331", + "0330034104", + "0420001302", + "0501006102", + "0601006977" + ] + }, + { + "validator": "D8", + "valid": [ + "0010000000", + "0010000001", + "0099999998", + "0099999999", + "1403414848", + "6800000439", + "6899999954" + ], + "invalid": [ + "0000260986", + "0009999999", + "0100000000", + "1062813622", + "3012084101" + ] + }, + { + "validator": "D9", + "valid": [ + "0123456782", + "0123456789", + "1100132044", + "1100669030", + "1234567890", + "1234567897", + "9876543210" + ], + "invalid": [ + "0543216789", + "1100789043", + "1100914032", + "6543217890" + ] + }, + { + "validator": "E0", + "valid": [ + "2610015", + "1234568013", + "1534568010", + "8741013011" + ], + "invalid": [ + "2710014", + "1234769013", + "9741015011" + ] + }, + { + "validator": "E1", + "valid": [ + "0100041104", + "0100054106", + "0200025107" + ], + "invalid": [ + "0081313890", + "0150013107", + "0200035101", + "0987402008", + "4268550840" + ] + }, + { + "validator": "E2", + "valid": [ + "0003831745", + "0051330335", + "1730773457", + "1987654327", + "2012345675", + "2220467998", + "3190519693", + "3011219713", + "4131220086", + "4110919419", + "5000083836", + "5069696965" + ], + "invalid": [ + "0121314151", + "0036958466", + "1000174716", + "1975312468", + "2260519349", + "2004002175", + "3780024149", + "3015024274", + "4968745438", + "4005012150", + "5000137454", + "5221398871", + "6221398879", + "6742185327", + "7793867322", + "7900695413", + "8001256238", + "8303808900", + "9703805111", + "9006126433" + ] + }, + { + "validator": "10", + "valid": [ + "268100", + "405221", + "1066889", + "1249754", + "2055007", + "2190869", + "2740001", + "3157008", + "4064224", + "4927397", + "7219008", + "7305001", + "8783004", + "0011313005", + "12345008", + "13692003", + "0013702017", + "0013711008", + "14088002", + "15977005", + "21564000", + "25168177", + "28396006", + "29342007", + "30177383", + "31251005", + "31741002", + "32710011", + "34247009", + "34409009", + "36757004", + "41683005", + "46199004", + "50018906", + "58032002", + "58583009", + "59083000", + "61007404", + "62162004", + "62248502", + "62320009", + "63919001", + "65383206", + "65421000", + "66933005", + "67427006", + "69748004", + "71089004", + "71934006", + "72769009", + "74509004", + "77126009", + "77823001", + "81424000", + "82319006", + "85355003", + "86504002", + "87654008", + "88279707", + "93107501", + "100919200", + "104064005", + "110145003", + "114126003", + "115634002", + "132623005", + "139350004", + "141401001", + "141508108", + "146468007", + "172570000", + "183699009", + "209611006", + "255658001", + "265281008", + "274018004", + "302329005", + "341294004", + "344455009", + "370509005", + "382813006", + "431361002", + "434894001", + "452586003", + "624107000", + "653792000", + "0672453002", + "0709427000", + "4322740006" + ] + }, + { + "validator": "11", + "valid": [ + "769010", + "3059227", + "5661730", + "7547927", + "7761619" + ] + }, + { + "validator": "13", + "valid": [ + "0225524", + "0247387", + "1002054", + "1005628", + "1039767", + "1049568", + "1055292", + "1058056", + "1159656", + "1182468", + "1194398", + "1201375", + "1258318", + "1268275", + "1311521", + "1413574", + "1495035", + "1501055", + "1503861", + "1615384", + "1934264", + "2007763", + "2014660", + "2053809", + "2107597", + "2120061", + "2199099", + "2205524", + "2220267", + "2226579", + "2332294", + "2602258", + "2722320", + "2737450", + "2762219", + "2781243", + "2803120", + "2872984", + "2915288", + "2928208", + "3004058", + "3150679", + "3301736", + "3319423", + "3409083", + "3610011", + "3657020", + "3992781", + "4261285", + "4301313", + "4440400", + "4500435", + "4528493", + "5020946", + "5262282", + "5272943", + "5502448", + "5637707", + "5712369", + "5715966", + "5885082", + "6101851", + "6183636", + "6189559", + "6284244", + "6333868", + "6402671", + "6412365", + "6557557", + "6739064", + "6815211", + "6824817", + "7013998", + "7103260", + "7253032", + "7307630", + "7396302", + "7455223", + "7682065", + "7917495", + "8018129", + "8020083", + "0008107260", + "8107260", + "8255754", + "8279374", + "8327694", + "8491714", + "8656654", + "8674285", + "8844011", + "8913790", + "8962060", + "8983447", + "61895598", + "142400100", + "169622800", + "180449101", + "183613900", + "291176600", + "300574100", + "360460001", + "363743600", + "414410102", + "420499600", + "458348000", + "640575700", + "654143700", + "800317000", + "871638301", + "887051100", + "2035269000", + "2052828100", + "2456073600", + "2476822200", + "2501728000", + "2510678600", + "2519056600", + "2586066300", + "2609531900", + "2628892200", + "2675906200", + "2758889000", + "2923239800" + ] + }, + { + "validator": "14", + "valid": [ + "0002212269", + "0005405858", + "0005534550", + "0102385015", + "0105451078", + "0301360175" + ] + }, + { + "validator": "17", + "valid": [ + "0446786040" + ] + }, + { + "validator": "19", + "valid": [ + "0200520016", + "0240334000" + ] + }, + { + "validator": "20", + "valid": [ + "479381", + "824305", + "1154257", + "1273426", + "1369725", + "1899325", + "2159902", + "2322323", + "2325640", + "2623714", + "2639092", + "8055335", + "44412827", + "54514800", + "54518890", + "54547881", + "0104029366", + "104029633", + "114013560", + "120044099", + "170154270", + "181026384", + "230253873", + "240293274", + "240317220", + "240370147", + "310192048", + "310284317", + "320321924", + "320335895", + "480891508", + "0544531612", + "574805036", + "610113003", + "640272290", + "730014240", + "780125037", + "810392216", + "820158089", + "930220650", + "940165139", + "970106041", + "990356221", + "1000110709", + "1000162962", + "1000288044", + "1010131024", + "1010201480", + "1040114438", + "1100016011", + "1112141061", + "1120106911", + "1130170400", + "1160163274", + "1180020266", + "1205186871", + "1210254677", + "1210424386", + "1210444506", + "1220039973", + "1220128160", + "1220132523", + "1220251492", + "1231080236", + "1231085270", + "1240147500", + "1320002834", + "1320019990", + "1320084253", + "1320244773", + "1360159289", + "1370017720", + "1384012946", + "1400032837", + "1410142732", + "1420005622", + "1420025844", + "1420186740", + "1440102879", + "1440116306", + "1440255519", + "1450066506", + "1450118832", + "1455022361", + "1490182744", + "1520054455", + "1525023892", + "1560027149", + "1564041421", + "1600040434", + "1640002142", + "1642902205", + "1654694769", + "1700189260", + "1704007417", + "1705150698", + "1714079690", + "1770003149", + "1770007225", + "1795109285", + "1800081215", + "1800277241", + "1800813658", + "1800858686", + "1800887937", + "1801244940", + "1801587961", + "1801802145", + "1802124094", + "1878755486", + "2020173223", + "2030269606", + "2060200442", + "2101438910", + "2105426096", + "2194924089", + "2194929749", + "2301484389", + "2303032698", + "2334006796", + "2334024638", + "2623445373", + "2804376802", + "4000009449", + "4000014523", + "4000078416", + "4000120463", + "4000514887", + "4000665222", + "4000780242", + "4000873780", + "4001159169", + "4002288760", + "4010033245", + "4011104871", + "4017076870", + "4020393996", + "4040119059", + "4043081630", + "4046047734", + "4050029788", + "4074018794", + "4074027998", + "4081029577", + "4110254243", + "4110265164", + "4110268384", + "4111124548", + "4116181949", + "4120172525", + "4120581727", + "4124535177", + "4134457470", + "4134472240", + "4134477781", + "4134478788", + "4134486896", + "4150092520", + "4210070896", + "4211162638", + "4329021167", + "4504025855", + "4505017864", + "4505059532", + "4506021067", + "4509009300", + "4516061002", + "4517017260", + "4521015633", + "4521024268", + "4532004433", + "4538017561", + "4550132634", + "4573023866", + "4611018860", + "4611022329", + "4616000854", + "4636004502", + "4709008839", + "4740039686", + "4810013486", + "4814031187" + ] + }, + { + "validator": "21", + "valid": [ + "1003000905" + ] + }, + { + "validator": "24", + "valid": [ + "138301", + "2654808", + "6654802", + "0008312466", + "12012805", + "15784605", + "19930102", + "20722857", + "37508101", + "0054539709", + "58033469", + "75355664", + "87347466", + "97325461", + "104314104", + "128062504", + "147889708", + "149072705", + "159847662", + "161217609", + "163663707", + "172260109", + "172733703", + "189685304", + "207866608", + "211454501", + "221590752", + "222634101", + "223608502", + "225190902", + "243892469", + "245559463", + "245570906", + "250957205", + "252751203", + "0259545855", + "266106306", + "289996202", + "294453309", + "0303960501", + "312990467", + "317000302", + "335891752", + "341082808", + "351588305", + "354485809", + "358419756", + "367494465", + "370155702", + "371201755", + "373120600", + "376977706", + "380945509", + "382158757", + "391181603", + "393451100", + "395379808", + "396143755", + "397829304", + "400435609", + "407944107", + "420549466", + "428720804", + "429603103", + "470512207", + "476474805", + "477489500", + "478534602", + "0484872103", + "489812106", + "506077201", + "507396309", + "512418804", + "523324465", + "535455805", + "536429309", + "541037309", + "549391804", + "549458463", + "567307467", + "574440461", + "594760436", + "609110807", + "612677805", + "615312806", + "615669100", + "619757433", + "619987466", + "620882307", + "621493462", + "623310806", + "630364305", + "636860205", + "641340801", + "642856201", + "643090307", + "656888800", + "658759801", + "661216804", + "0674808207", + "679178803", + "682845800", + "687280608", + "689825603", + "696038306", + "707906603", + "769190208", + "773147304", + "808330206", + "817070108", + "822181103", + "826645800", + "836159809", + "853913605", + "857088677", + "857366204", + "858630208", + "862839201", + "868388461", + "871362908", + "872698209", + "875801858", + "881293200", + "883517467", + "891832433", + "893849100", + "919329609", + "924004808", + "0924938309", + "932805200", + "935340904", + "938127804", + "942404205", + "948020200", + "961883807", + "962622805", + "972353801", + "994574203", + "995556208", + "1306118605", + "3307118608", + "9307118603" + ] + }, + { + "validator": "25", + "valid": [ + "201189283", + "215160754", + "260322814", + "521382181" + ] + }, + { + "validator": "26", + "valid": [ + "0005501024", + "0520309001", + "1111118111" + ] + }, + { + "validator": "27", + "valid": [ + "311068", + "1026251", + "1168228", + "1998640", + "2288363", + "2417855", + "2529915", + "2949741", + "3436169", + "6438071", + "6506448", + "7234313", + "8348336", + "24022022", + "105478820", + "2847169488" + ] + }, + { + "validator": "28", + "valid": [ + "1025100", + "11172400", + "12161400", + "13962900", + "14180100", + "14701000", + "16062800", + "19999000", + "25712500", + "30037300", + "31672500", + "32767000", + "81972700", + "86817500", + "90051600", + "94383500", + "108927700", + "109083600", + "120234000", + "128460600", + "134365300", + "146438800", + "185539500", + "207806600", + "281545100", + "356055400", + "417539500", + "422851000", + "500076900", + "704899800", + "706799200", + "712864900", + "802350600", + "965291400", + "1003320300", + "1300379800", + "1301472200", + "1500945900", + "1701922200", + "2613786000", + "3000134000", + "4202778000", + "4804141600", + "4804373700", + "9130000201" + ] + }, + { + "validator": "29", + "valid": [ + "3145863029" + ] + }, + { + "validator": "31", + "valid": [ + "0263160165", + "1000000524", + "1000000583" + ] + }, + { + "validator": "32", + "valid": [ + "6190", + "12610", + "17191", + "24384", + "26930", + "27944", + "39772", + "40215", + "43583", + "44644", + "72621", + "72699", + "82872", + "128821", + "157260", + "232254", + "405868", + "413640", + "457442", + "536938", + "611050", + "747564", + "1113402", + "1408518", + "1870181", + "2002124", + "2034069", + "2142562", + "2213060", + "2466570", + "2480794", + "2551918", + "2721155", + "2738252", + "2872269", + "3009807", + "3024547", + "3573060", + "3945138", + "4027000", + "4028554", + "4046463", + "4256484", + "4328663", + "4389670", + "4517385", + "4557298", + "4575288", + "4610202", + "4629124", + "4793706", + "4840151", + "5028256", + "5412200", + "5534348", + "5822181", + "5870488", + "5944724", + "5951917", + "6020879", + "6818501", + "7380119", + "7909497", + "8286035", + "8637725", + "9141405", + "100133361", + "0121114867", + "0122116979", + "200070947", + "1709107983", + "9030101192", + "9245500460" + ] + }, + { + "validator": "33", + "valid": [ + "48658", + "76058", + "84956", + "243604", + "388874", + "414603" + ] + }, + { + "validator": "34", + "valid": [ + "1719500", + "2197900", + "4484700", + "4556700", + "5547400", + "7666200", + "8556900", + "10395800", + "17223211", + "17733200", + "23269600", + "24680119", + "25998701", + "44289600", + "51010701", + "61681700", + "62232801", + "67255200", + "69111201", + "87344200", + "91230900", + "108128700", + "109522400", + "110375700", + "151497800", + "211211000", + "255603700", + "300457600", + "428759800", + "462687900", + "657944700", + "704449500", + "751781100", + "831599801", + "912976700", + "1102503503", + "1303805900", + "1402578600", + "2205169300", + "2267965900", + "2385868300", + "3302596800", + "3604813700", + "4019966700", + "4100063000", + "5021301200", + "5155223500", + "5226472900", + "5801714701", + "6003572300", + "6102129400", + "6159335600", + "8703609900", + "8740184200", + "8805374700", + "9913000700", + "9914001000" + ] + }, + { + "validator": "35", + "valid": [ + "101599", + "101709", + "102349", + "102921", + "107451", + "108443" + ] + }, + { + "validator": "36", + "valid": [ + "113178", + "146666" + ] + }, + { + "validator": "37", + "valid": [ + "624315", + "632500" + ] + }, + { + "validator": "38", + "valid": [ + "191919", + "302519", + "915024", + "1009082", + "1100660", + "1128073", + "1307258", + "1609627", + "1938842", + "2376159" + ] + }, + { + "validator": "39", + "valid": [ + "200205", + "10019400" + ] + }, + { + "validator": "40", + "valid": [ + "1258345", + "3231963", + "6215820003" + ] + }, + { + "validator": "41", + "valid": [ + "0166805317", + "4013410024", + "4016660195", + "4019151002", + "4019310079", + "4019340829" + ] + }, + { + "validator": "42", + "valid": [ + "59498", + "59510" + ] + }, + { + "validator": "43", + "valid": [ + "2033552", + "6135244", + "9516893476" + ] + }, + { + "validator": "44", + "valid": [ + "889006", + "2618040504" + ] + }, + { + "validator": "45", + "valid": [ + "0000012340", + "0100114240", + "0994681254", + "1000199999", + "3545343232", + "4013410024" + ] + }, + { + "validator": "46", + "valid": [ + "0235468612", + "0837890901", + "1041447600" + ] + }, + { + "validator": "47", + "valid": [ + "1018000", + "1003554450" + ] + }, + { + "validator": "48", + "valid": [ + "2959730", + "93703660" + ] + }, + { + "validator": "49", + "valid": [ + "1121799", + "1444160", + "1826128", + "2195865", + "3278482", + "3374520", + "4152679", + "4928024", + "190388439" + ] + }, + { + "validator": "50", + "valid": [ + "4000005001", + "4444442001", + "5850797000", + "6142451000", + "6144837000" + ] + }, + { + "validator": "51", + "valid": [ + "0000156071", + "0000156078", + "164670", + "201178", + "270350", + "340968", + "458966", + "592242", + "1009588", + "0001156071", + "0001156136", + "0001234567", + "2056778", + "0099100010", + "101356073", + "0199100002", + "0199100004", + "2599100002", + "2599100003", + "3199204090", + "3199500501" + ], + "invalid": [ + "0099100110", + "0099345678", + "0199100040" + ] + }, + { + "validator": "54", + "valid": [ + "4900010987", + "4964137395" + ] + }, + { + "validator": "56", + "valid": [ + "0290545005", + "9718304037" + ] + }, + { + "validator": "57", + "valid": [ + "0105781645", + "0112762973", + "0203861428", + "0208762720", + "0210772314", + "0405542767", + "0408720610", + "0508750313", + "0610784275", + "0802713267", + "0803732716", + "0804841115", + "0905712134", + "1004731551", + "1105812120", + "1110742116", + "1201760575", + "1204762751", + "1209752022", + "1407781403", + "1412720611", + "1506801596", + "1509701720", + "1609751400", + "1702770213", + "1702772364", + "1706812524", + "1711764016", + "1801810233", + "1805761311", + "1906721722", + "1907791678", + "1909700805", + "2204762175", + "2204840420", + "2205812216", + "2208483021", + "2210811386", + "2410781111", + "2603784092", + "2802752203", + "2804540670", + "2811722469", + "2901554056", + "2901784132", + "2908752583", + "2910751345", + "2911792113", + "3003711345", + "3007762732", + "3101752218", + "3251080371", + "3891234567", + "5001050352", + "5045090090", + "7400060823", + "7500021766", + "7777778800", + "7800028282", + "8100244186", + "9322111030", + "9400001734" + ], + "invalid": [ + "1813499124", + "2206735010", + "5302707782", + "6412121212" + ] + }, + { + "validator": "58", + "valid": [ + "180881120", + "1000870595", + "1015222224", + "1800293377", + "3703169668", + "9200654108" + ] + }, + { + "validator": "59", + "valid": [ + "110105152", + "115075806" + ] + }, + { + "validator": "61", + "valid": [ + "0260760282", + "0260760481", + "1146720600", + "2063099200", + "7806114000" + ] + }, + { + "validator": "62", + "valid": [ + "5029076701" + ] + }, + { + "validator": "63", + "valid": [ + "0100206", + "0100230", + "0115055", + "0119008", + "0122135", + "0123927", + "0131185", + "0134312", + "0138271", + "0145862", + "0149955", + "0150870", + "0156265", + "0162065", + "167908", + "0169631", + "0173948", + "0177840", + "0187823", + "0188037", + "0195123", + "0200196", + "0208405", + "0210666", + "0212092", + "0222380", + "0223537", + "0226555", + "0231720", + "0232140", + "0245811", + "0246579", + "0250936", + "0252247", + "0257063", + "0260653", + "0272476", + "0282194", + "0291864", + "0303016", + "0304345", + "0308015", + "0312439", + "0322982", + "0323410", + "0323535", + "0324376", + "0325191", + "0330183", + "0341222", + "0342451", + "0356758", + "0366633", + "0382390", + "0400572", + "0401273", + "0401943", + "0403493", + "0409060", + "0411421", + "0415372", + "0430629", + "0432575", + "0433243", + "0444638", + "0473876", + "0477927", + "0496273", + "503458", + "0506758", + "0511535", + "0516369", + "0520486", + "0521666", + "0522268", + "0541698", + "0602656", + "0611798", + "0630541", + "0709568", + "0715417", + "0750752", + "0781831", + "0806786", + "0823419", + "830307", + "0853093", + "0858688", + "875344", + "0900019", + "0912642", + "0916445", + "0966663", + "0979864", + "1011071", + "1013887", + "1028273", + "1038538", + "1053198", + "1076710", + "1079318", + "1094846", + "1095843", + "1130194", + "1134345", + "1134675", + "1164359", + "1195718", + "1212877", + "1214527", + "1214535", + "1216266", + "1225911", + "1231315", + "0001234566", + "1238765", + "1239797", + "1267970", + "1268044", + "1301407", + "1305457", + "1331537", + "1335355", + "1335587", + "1416288", + "1453216", + "1488493", + "1543271", + "1561067", + "1564897", + "1587401", + "1716026", + "1720176", + "1722834", + "1741115", + "1743855", + "1750017", + "1756006", + "1801661", + "1810621", + "1841907", + "1857523", + "0001869791", + "1919588", + "1941723", + "1977206", + "1991017", + "1992015", + "1993898", + "2000263", + "2015741", + "2021764", + "2038222", + "2043255", + "2051357", + "2081693", + "2108033", + "2114650", + "2116127", + "2130953", + "2137552", + "2222883", + "2224533", + "2242717", + "2243178", + "2303253", + "2343788", + "2352573", + "2385631", + "2421618", + "2435600", + "2439594", + "2440071", + "2504660", + "2506210", + "2512929", + "2515641", + "2523793", + "2714202", + "2717932", + "2750578", + "2768208", + "2776011", + "2777076", + "2813095", + "2817369", + "2885325", + "3015773", + "3020757", + "3024387", + "3029766", + "3035292", + "3076072", + "3127594", + "3172269", + "3201076", + "3206083", + "3214384", + "3220050", + "3228889", + "3237625", + "3260759", + "3380243", + "3390010", + "3466521", + "3505708", + "3510849", + "3513132", + "3580487", + "3588928", + "3614401", + "3631231", + "3722410", + "3742186", + "3743978", + "3779238", + "3807401", + "3838000", + "3900388", + "3900628", + "3912441", + "3916293", + "3945037", + "3946829", + "3947322", + "3980224", + "3985082", + "3991031", + "4000808", + "4001152", + "4009684", + "4017067", + "4079059", + "4106712", + "4111068", + "4212205", + "4254181", + "4255410", + "4301842", + "4303913", + "4381604", + "4383501", + "4389698", + "4397790", + "4441622", + "4472700", + "4474573", + "4512505", + "4517736", + "4608105", + "4623245", + "4662078", + "4679429", + "4687786", + "4750212", + "4757076", + "4792560", + "4816542", + "4904413", + "4905857", + "4914123", + "4938494", + "4999918", + "5000849", + "5014600", + "5019211", + "5019336", + "5040928", + "5051719", + "5052360", + "5064159", + "5080510", + "5085204", + "5104070", + "5137534", + "5146360", + "5183710", + "5214564", + "5364823", + "5379367", + "5386792", + "5402177", + "5415484", + "5425483", + "5434709", + "5441407", + "5461587", + "5518816", + "5605993", + "5609581", + "5710678", + "5726963", + "5729553", + "5861901", + "5916226", + "6002349", + "6018022", + "6018774", + "6072599", + "6082515", + "6101331", + "6229231", + "6301469", + "6310692", + "6342208", + "6373492", + "6399653", + "6409015", + "6418735", + "6428684", + "6465744", + "6472518", + "6606024", + "6609689", + "6648349", + "6648802", + "6687628", + "6710750", + "6911648", + "6967103", + "6967715", + "7004690", + "7012297", + "7046014", + "7124746", + "7133101", + "7241896", + "7367204", + "7414402", + "7580012", + "7591902", + "7602394", + "7669807", + "7721244", + "7758808", + "7839293", + "7850134", + "7931926", + "8002966", + "8003998", + "8015208", + "8038523", + "8041378", + "8174344", + "8317349", + "8415432", + "8446908", + "8500555", + "8563553", + "8606568", + "8736779", + "8765711", + "8816498", + "8832701", + "8898389", + "8911299", + "8988149", + "9167172", + "9185737", + "9530908", + "9540774", + "9616046", + "9636499", + "9777228", + "9838244", + "9974601", + "010645000", + "012280400", + "12305900", + "015414600", + "020725800", + "025168600", + "030367701", + "032341001", + "033075301", + "040766800", + "075023200", + "105405500", + "123456600", + "126598200", + "127129500", + "140763400", + "141742700", + "166180000", + "173605700", + "183688100", + "199577800", + "200019800", + "200882900", + "212612600", + "268515400", + "271161200", + "284753100", + "297518300", + "339102600", + "348160300", + "364094300", + "376629200", + "382011501", + "400635900", + "419723200", + "445628100", + "446031700", + "492134200", + "501471700", + "516460300", + "518427000", + "520717000", + "549157600", + "606530400", + "629314600", + "651866600", + "654272400", + "684461700", + "700305600", + "740613500", + "781787700", + "953647500", + "971982400", + "989686100" + ] + }, + { + "validator": "64", + "valid": [ + "1206473010", + "5016511020", + "7129309000" + ] + }, + { + "validator": "65", + "valid": [ + "1234567400", + "1234567590" + ] + }, + { + "validator": "66", + "valid": [ + "100150502", + "100154508", + "100154516", + "101154508", + "101154516", + "0983393104", + "1934567890" + ] + }, + { + "validator": "68", + "valid": [ + "412718", + "2011740", + "2056760", + "5030817", + "5477724", + "6210801", + "6743173", + "7322472", + "7922792", + "8406316", + "8606147", + "19807727", + "51181008", + "53101527", + "63206300", + "71214205", + "71240804", + "76545806", + "987654324", + "987654328", + "8889654328" + ], + "invalid": [ + "6414241", + "179751314" + ] + }, + { + "validator": "69", + "valid": [ + "0192735300", + "1234567006", + "1234567900", + "2676152100", + "3429127000", + "4633049600", + "6820735200", + "9721134869", + "9993327600" + ] + }, + { + "validator": "70", + "valid": [ + "6790160566" + ] + }, + { + "validator": "71", + "valid": [ + "7101234007" + ] + }, + { + "validator": "73", + "valid": [ + "1340966", + "1340967", + "1340968", + "3157179", + "3503391", + "3503392", + "3503398", + "0003503398", + "4356770", + "0099100010", + "0199100002", + "0199100004", + "2599100002", + "2599100003", + "3199204090", + "7899100003" + ], + "invalid": [ + "121212", + "0099100110", + "0099345678", + "0199100040", + "987654321" + ] + }, + { + "validator": "74", + "valid": [ + "1016", + "26260", + "239314", + "239319", + "242243", + "242248", + "2166429", + "2180800", + "2191583", + "2212686", + "3126166", + "11183027", + "12150645", + "16139552", + "18002113", + "19188812", + "21156690", + "21164306", + "23162183", + "24158198", + "25342700", + "29250677", + "1821200043" + ], + "invalid": [ + "1011", + "26265", + "18002118", + "6160000024" + ] + }, + { + "validator": "76", + "valid": [ + "0000123456", + "05809599", + "6123004", + "6531994", + "0006543200", + "06915620", + "8414580", + "0012345600", + "0100800600", + "0104328600", + "0104860000", + "105873300", + "0112634900", + "0113304400", + "120240600", + "0120566300", + "0121637500", + "0125787000", + "0128125200", + "0128706000", + "132511500", + "0170935500", + "0172758800", + "0189463800", + "0192100900", + "192650000", + "0196647900", + "0198032400", + "0208896400", + "0210575500", + "0217797300", + "0229277400", + "0231661400", + "0242439300", + "257924800", + "262121600", + "0275041700", + "276322900", + "0283431500", + "300634700", + "0300691800", + "0304816000", + "0307135200", + "0330385800", + "0355884800", + "0360341600", + "0362792500", + "0376111300", + "0377432600", + "380269300", + "0382556500", + "0402954900", + "0412751100", + "0423584800", + "0442018400", + "0443942900", + "0450002700", + "0452113400", + "0463287400", + "0465112100", + "0474515200", + "475407400", + "0479894600", + "0497179600", + "500126200", + "0508685100", + "0521968100", + "0527717600", + "0540112400", + "0543222400", + "0550006000", + "0550423500", + "564428800", + "0568021900", + "0572497100", + "0580959900", + "0582180000", + "0584789800", + "0586390900", + "0587902400", + "591024900", + "0591994000", + "0595377700", + "600201800", + "0601346600", + "0601711300", + "0601755100", + "0601782400", + "0607777800", + "0615188700", + "616217400", + "0622059900", + "0626028700", + "631049700", + "0636079800", + "0644103800", + "0661830300", + "0671404300", + "683597100", + "0702319400", + "703070800", + "0705479800", + "0711523400", + "0719079700", + "720670700", + "0722974400", + "0738194300", + "752765200", + "0755268300", + "755343200", + "758549400", + "0770541400", + "0770751400", + "0803082000", + "818739300", + "827270000", + "829419700", + "0834822400", + "0848425900", + "0887238700", + "0890570800", + "0910652200", + "0921624800", + "0923303900", + "0932650900", + "0934153500", + "0949667100", + "0961376600", + "979219300", + "4013888500", + "4039882200", + "4041862600", + "4093425200", + "4096323900", + "4170214200", + "4274556200", + "4301338800", + "4366681500", + "4366759500", + "4545908400", + "7876543100", + "9012345600" + ] + }, + { + "validator": "77", + "valid": [ + "10338", + "13844", + "0000047671", + "0000054321", + "69258" + ] + }, + { + "validator": "78", + "valid": [ + "2268316", + "2418697", + "2431302", + "2443018", + "2516888", + "4334181", + "4629739", + "5083688", + "5561311", + "6573331", + "7581499", + "8707069", + "8717050", + "8920555", + "9999999981" + ] + }, + { + "validator": "79", + "valid": [ + "1550167850", + "3230012688", + "5440001898", + "6330001063", + "7000149349", + "8000003577", + "9011200140" + ] + }, + { + "validator": "80", + "valid": [ + "340966", + "340968", + "0099100010", + "0199100002", + "0199100004", + "2599100002", + "2599100003", + "3199204090", + "3199500501" + ], + "invalid": [ + "0099100110", + "0099345678", + "0199100040" + ] + }, + { + "validator": "81", + "valid": [ + "300900", + "467405", + "526800", + "544825", + "0646440", + "960306", + "1105027", + "1114000", + "1359100", + "2369010", + "2636310", + "2656370", + "3524450", + "7023650", + "7033249", + "7117663", + "7168802", + "7296770", + "7491751", + "7568231", + "7612192", + "7622090", + "0099100010", + "100587427", + "0199100002", + "0199100004", + "2599100002", + "2599100003", + "3199204090", + "3199500501" + ], + "invalid": [ + "0099100110", + "0099345678", + "0199100040" + ] + }, + { + "validator": "82", + "valid": [ + "123897", + "3199500501" + ] + }, + { + "validator": "83", + "valid": [ + "0000156071", + "0000156078", + "0001156071", + "0001156136", + "0099100002" + ] + }, + { + "validator": "84", + "valid": [ + "100005", + "197284", + "240692", + "240699", + "240961", + "350982", + "350984", + "350985", + "371394", + "393814", + "461052", + "461054", + "461059", + "506869", + "634484", + "703176", + "950360", + "0099100010", + "0199100002", + "0199100004", + "2599100002", + "2599100003", + "3199204090", + "3199500501" + ], + "invalid": [ + "240965", + "350980", + "461053", + "0099100110", + "0099345678", + "0199100040" + ] + }, + { + "validator": "85", + "valid": [ + "0000156071", + "0000156078", + "316764", + "0326816", + "0001156071", + "0001156136", + "3199100002" + ] + }, + { + "validator": "86", + "valid": [ + "123897", + "340960", + "340968", + "833371", + "946150", + "972323", + "1001171", + "1009588", + "1136845", + "1293406", + "0099100010", + "0199100002", + "0199100004", + "2599100002", + "2599100003", + "3199204090", + "3199500501" + ], + "invalid": [ + "0099100110", + "0099345678", + "0199100040" + ] + }, + { + "validator": "87", + "valid": [ + "406", + "34715", + "51768", + "100005", + "223175", + "393814", + "542655", + "950360", + "973356", + "1298310", + "1311349", + "2266057", + "3011810", + "3186646", + "3467504", + "10701590", + "10720185", + "0099100010", + "0199100002", + "0199100004", + "2599100002", + "2599100003", + "3199204090", + "3199500501", + "1975641", + "1988654" + ], + "invalid": [ + "0099100110", + "0099345678", + "0199100040", + "0001924592" + ] + }, + { + "validator": "88", + "valid": [ + "1112", + "11410", + "16284", + "27146", + "32700", + "36765", + "37834", + "40100", + "50741", + "66877", + "67067", + "72222", + "78239", + "89060", + "119890", + "126314", + "152846", + "179426", + "215490", + "222348", + "227897", + "303674", + "317098", + "319988", + "320897", + "363910", + "483192", + "582840", + "614491", + "704890", + "707899", + "727610", + "818526", + "923222", + "929913", + "1000500", + "1057162", + "1064827", + "1069080", + "1073796", + "1190571", + "1202090", + "1431188", + "1694219", + "1807323", + "1807536", + "1825526", + "1920103", + "2508508", + "2525259", + "2569906", + "2628910", + "2680696", + "2704900", + "2807220", + "3221016", + "3227103", + "3241599", + "3302989", + "3501523", + "3603377", + "4207289", + "4840968", + "5195039", + "5729114", + "5916941", + "6124593", + "7174918", + "7178441", + "7425511", + "9710213", + "90013000", + "92525253", + "99913003", + "100007960", + "100263036" + ] + }, + { + "validator": "89", + "valid": [ + "1098506", + "32028008", + "218433000", + "254024009", + "507072006" + ] + }, + { + "validator": "90", + "valid": [ + "0000156071", + "0000156073", + "0000156077", + "0000156132", + "259413", + "415176", + "0000654321", + "0000666034", + "0000677747", + "737577", + "0000824491", + "0000840507", + "0000996663", + "0001156132", + "0001156136", + "0001784451", + "0001863530", + "0001975641", + "0001988654", + "2426013", + "2451050", + "3140482", + "0003865960", + "3921000", + "4569164", + "0004923250", + "0006073093", + "0099100002", + "982507293" + ], + "invalid": [ + "0000726393", + "0000820487", + "0000901568", + "0000924591", + "0001924592", + "0003865964", + "0099100007" + ] + }, + { + "validator": "91", + "valid": [ + "2974117000", + "5281770000", + "8840012000", + "8840019000", + "8840045000", + "8840050000", + "8840055000", + "8840080000", + "8840087000", + "9952812000" + ], + "invalid": [ + "8840010000", + "8840011000", + "8840014000", + "8840025000", + "8840026000", + "8840057000", + "8840062000" + ] + }, + { + "validator": "92", + "valid": [ + "4069613759", + "4069634518", + "4079604146", + "4129654921", + "4139507456", + "4149555848", + "4149578179", + "4239653647", + "4239680359", + "4349555862", + "4359725290" + ] + }, + { + "validator": "93", + "valid": [ + "0000127783", + "0000127791", + "0000306754", + "0000671479", + "1277830000", + "1277910000", + "3067540000", + "6714790000" + ] + }, + { + "validator": "94", + "valid": [ + "6782533003" + ] + }, + { + "validator": "95", + "valid": [ + "2594811", + "5300100", + "33739966", + "34239185", + "38794531", + "43917056", + "44212463", + "45333655", + "46599730", + "48256538", + "0068007003", + "189912137", + "235308215", + "654502633", + "657550590", + "658311255", + "659110580", + "0847321750", + "0910000000", + "0989999999", + "3180376878", + "4320265385", + "5800607576", + "6130421618", + "6340241892", + "6410681216", + "6450060494", + "6454000003" + ], + "invalid": [ + "6414241", + "51181008", + "71214205", + "179751314", + "1234567897", + "4455667784" + ] + }, + { + "validator": "96", + "valid": [ + "0000000208", + "0000254100", + "0101115152", + "115018954", + "161022942", + "0301204301", + "313808651", + "315811340", + "0318093154", + "319812057", + "329807382", + "345807936", + "371824206", + "378000624", + "0385014384", + "388816198", + "394225724", + "1200161570", + "1200571353", + "1200996087", + "1201255242", + "1201413450", + "1201674709", + "1251027898", + "1251063924", + "1251088153", + "1251112070", + "1251178780", + "1251199940", + "1251258300", + "1251272795", + "1251325481", + "1251424030", + "1251495190", + "1251673102", + "1251705004", + "1251721832", + "1251763837", + "9421000009" + ] + }, + { + "validator": "97", + "valid": [ + "24010019" + ] + }, + { + "validator": "98", + "valid": [ + "3009800016", + "5989800173", + "6719430018", + "9619319999", + "9619439213", + "9619509976" + ] + }, + { + "validator": "99", + "valid": [ + "1458264", + "1464558", + "1598783", + "2409097", + "2456737", + "2509822", + "2686821", + "2689901", + "3123707", + "3426610", + "3523004", + "4481488", + "0005559707", + "6258468", + "6710948", + "6947719", + "7071159", + "7746504", + "8003157", + "8788871", + "9081178", + "9424474", + "47313937", + "0068007003", + "85302353", + "303800468", + "311303740", + "326605174", + "326800139", + "0847321750", + "1290255151", + "1490152756", + "2610153499", + "4950117929", + "5180163834", + "5480158891", + "6260239897", + "6660243192", + "6720348169", + "6750164135", + "6790147721", + "6810215281" + ] + }, + { + "validator": "52", + "blz": "13051052", + "valid": [ + "42200908", + "46310653", + "49750996" + ] + }, + { + "validator": "52", + "blz": "13051172", + "valid": [ + "43001500", + "48726458" + ], + "invalid": [ + "29837521", + "82335729" + ] + }, + { + "validator": "52", + "blz": "81053132", + "valid": [ + "41084332" + ] + }, + { + "validator": "53", + "blz": "16052072", + "valid": [ + "382432256" + ] + }, + { + "validator": "53", + "blz": "85055142", + "valid": [ + "345033997" + ] + }, + { + "validator": "B6", + "blz": "80053762", + "valid": [ + "9110000000" + ], + "invalid": [ + "467310018", + "9111000000" + ] + }, + { + "validator": "B6", + "blz": "80053772", + "invalid": [ + "477310018" + ] + }, + { + "validator": "B6", + "blz": "80053782", + "valid": [ + "487310018" + ] + }, + { + "validator": "C0", + "blz": "81053272", + "valid": [ + "42279904", + "48074470", + "49279640", + "0082335729", + "0734192657", + "6932875274" + ] + }, + { + "validator": "C0", + "blz": "86055462", + "invalid": [ + "0132572975", + "3038752371" + ] + } +] \ No newline at end of file diff --git a/tests/data/bankleitzahlen_download.html b/tests/data/bankleitzahlen_download.html new file mode 100644 index 00000000..e9e956e8 --- /dev/null +++ b/tests/data/bankleitzahlen_download.html @@ -0,0 +1,903 @@ + + + + + + + Deutsche Bundesbank - Bankleitzahlen - Download - Bankleitzahlen + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +

Navigation und Service

+ + +
+

Deutsche Bundesbank (zur Startseite)

+ +
+ + +
+ +
+
+ +
+
+
+

+ Download - Bankleitzahlen +

+

Löschung von Bankleitzahlen

+

Zur Feststellung von Bankleitzahllöschungen können die unten stehenden Listen "BLZ-Löschungen zum (Gültigkeitstermin)" verwendet werden, in denen alle Bankleitzahllöschungen - gegebenenfalls mit Angabe der entsprechenden Nachfolge-Bankleitzahl - zu diesem sowie dem vorhergehenden Aktualisierungstermin verzeichnet wurden.

+

Diese Informationen können auch direkt der Bankleitzahlendatei entnommen werden (Feld 11 "Änderungskennzeichen" = "D" in Verbindung mit Feld 2 "Merkmal, ob bankleitzahlführender Zahlungsdienstleister ("1") oder nicht ("2")" = "1", bzw. Feld 13 "Hinweis auf Nachfolge-Bankleitzahl").

+

Hinweis: Eine Bankleitzahl wird nur dann gelöscht, wenn der mit dem "Änderungskennzeichen" = "D" gekennzeichnete Datensatz im Feld 2 mit "1" belegt ist. Die Löschung eines Datensatzes mit dem Merkmal "2" im Feld 2 bedeutet nicht die Löschung der Bankleitzahl selbst, sondern nur die Löschung dieses Datensatzes.

+

Informationen über die beabsichtigte Löschung von Bankleitzahlen können den Feldern 12 "Hinweis auf beabsichtigte Bankleitzahllöschung" sowie ggf. Feld 13 "Hinweis auf Nachfolge-Bankleitzahl" entnommen werden.

+

Download der Bankleitzahlendateien

+

Im Folgenden finden Sie die Bankleitzahlen-Dateien zum Download im ASCII-Format als PC-Text, PC-Excel und Lotus Notes. Die Dateien sind jeweils in den zwei letzten Versionen verfügbar. Die aktuellen Dateien werden zum 7. März 2016 gültig (und dürfen vorher im Zahlungsverkehr nicht verwendet werden). Die Bereitstellung der Dateien für die nächste Aktualisierung per 6. Juni 2016 wird voraussichtlich im Mai 2016 erfolgen.

+

Über die Bereitstellung neuer Bankleitzahlendateien sowie weiterer Informationen zu Bankleitzahlen, die für die reibungslose Abwicklung des Zahlungsverkehrs von großer Bedeutung sind, informieren wir Sie über unseren Newsletter. Sofern Sie Interesse haben, bitten wir Sie, sich zu registrieren.

+
+
+

Bankleitzahlen-Löschungen

+ +
+
+

Bankleitzahlendateien ungepackt

+
+

gültig vom 07.12.2015 bis 06.03.2016

+ +
+
+
+

Bankleitzahlendateien gepackt

+ +
+
+

Bankleitzahlendateien ungepackt

+
+

gültig vom 07.03.2016 bis 05.06.2016

+ +
+
+
+

Bankleitzahlendateien gepackt

+ +
+
+ +
+
+
+
+
+

Zusatzinformationen

+
+ +
+
+ + + +
+ +
+
+
+ + +
+
+

Hinweis 

+
+

Der verbindliche Bankleitzahlen-Änderungsdienst erfolgt für Zahlungsdienstleister durch einen gesicherten Download aus dem ExtraNet der Deutschen Bundesbank. Ergänzend stellt die Deutsche Bundesbank die Bankleitzahlendatei unverbindlich ins Internet ein. Bitte beachten Sie bei der Verwendung der Bankleitzahlendatei die Hinweise im Disclaimer.

+
+
+
+

+ Newsletter abonnieren +   +

+
+

+ + +Zeitung +

+

Erhalten Sie regelmäßig Informationen zu Bankleitzahlen und Prüfziffer-Berechnungsmethoden für Kontonummern, TARGET2 oder allgemein zu Zahlungsverkehr und Wertpapierabwicklung.

+ Weiter +
+
+
+
+
+
+
+
+
+
+
+ +
+ +
+ + + + \ No newline at end of file diff --git a/tests/data/bav/configuration.php b/tests/data/bav/configuration.php new file mode 100644 index 00000000..33d0d257 --- /dev/null +++ b/tests/data/bav/configuration.php @@ -0,0 +1,9 @@ +setTempDirectory("test"); + +return $configuration; diff --git a/tests/data/blz.lut2 b/tests/data/blz.lut2 new file mode 100644 index 00000000..d5382ffe Binary files /dev/null and b/tests/data/blz.lut2 differ diff --git a/tests/data/configuration.php b/tests/data/configuration.php new file mode 100644 index 00000000..33d0d257 --- /dev/null +++ b/tests/data/configuration.php @@ -0,0 +1,9 @@ +setTempDirectory("test"); + +return $configuration; diff --git a/tests/data/fileParserTest/bb-excerpt.txt b/tests/data/fileParserTest/bb-excerpt.txt new file mode 100644 index 00000000..cb9b86f7 --- /dev/null +++ b/tests/data/fileParserTest/bb-excerpt.txt @@ -0,0 +1,10 @@ +100000001Bundesbank 10591Berlin BBk Berlin 20100MARKDEF110009011380U000000000 +100100101Postbank 10916Berlin Postbank Berlin 10010PBNKDEFFXXX24000538U000000000 +100101111SEB 10789Berlin SEB Berlin 25805ESSEDE5F10013005361U000000000 +100104241Aareal Bank 10666Berlin Aareal Bank 26910AARBDE5W10009004795U000000000 +100196101Dexia Kommunalbank Deutschland 10969Berlin Dexia Berlin DXIADEBBXXX09055273U000000000 +100202001BHF-BANK 10117Berlin BHF-BANK Berlin 25155BHFBDEFF10060004794U000000000 +100205001Bank für Sozialwirtschaft 10178Berlin Bank für Sozialwirtschaft 25013BFSWDE33BER09000530U000000000 +100208901UniCredit Bank - HypoVereinsbank 10896Berlin UniCredit Bank-HypoVereinbk22014HYVEDEMM48899039785U000000000 +100208902UniCredit Bank - HypoVereinsbank 14532Kleinmachnow UniCredit Bank-HypoVereinbk22014HYVEDEMM48899049352U000000000 +100208902UniCredit Bank - HypoVereinsbank 16515Oranienburg UniCredit Bank-HypoVereinbk22014HYVEDEMM48899049745U000000000 diff --git a/tests/data/fileParserTest/simple.txt b/tests/data/fileParserTest/simple.txt new file mode 100644 index 00000000..67ba5b79 --- /dev/null +++ b/tests/data/fileParserTest/simple.txt @@ -0,0 +1,2 @@ +12345 +67890 \ No newline at end of file diff --git a/tests/data/no_configuration.php b/tests/data/no_configuration.php new file mode 100644 index 00000000..7d3dd7f0 --- /dev/null +++ b/tests/data/no_configuration.php @@ -0,0 +1,3 @@ + + */ +class BackendTest extends TestCase +{ + + /** + * @var FileDataBackend + */ + private static $referenceBackend; + + /** + * @var DataBackend[] + */ + private static $freeableDatabackends = array(); + + /** + * Defines the reference backend + */ + public static function classConstructor() + { + self::$referenceBackend = new FileDataBackend(); + } + + /** + * @return DataBackend[] The tested backends + */ + public function provideBackends() + { + $backends = array(); + + $backends[] = new PDODataBackend(PDOFactory::makePDO()); + $backends[] = new FileDataBackend(); + + $conn = array( + "pdo" => PDOFactory::makePDO(), + ); + $doctrineContainer = DoctrineBackendContainer::buildByConnection($conn, true); + $backends[] = new DoctrineDataBackend($doctrineContainer->getEntityManager()); + + foreach ($backends as &$backend) { + if (! $backend->isInstalled()) { + $backend->install(); + + } + + self::$freeableDatabackends[] = $backend; + + $backend = array($backend); + + }; + + return $backends; + } + + /** + * @return DataBackend[] + */ + public function provideInstallationBackends() + { + $backends = array(); + + $backends[] = new PDODataBackend(PDOFactory::makePDO(), "bavtest_"); + + $fileUtil = new FileUtil(); + $backends[] = new FileDataBackend(tempnam($fileUtil->getTempDirectory(), "bavtest")); + + $conn = array( + "driver" => "pdo_sqlite", + "path" => ":memory:" + ); + $doctrineContainer = DoctrineBackendContainer::buildByConnection($conn, true); + $backends[] = new DoctrineDataBackend($doctrineContainer->getEntityManager()); + + foreach ($backends as &$backend) { + if ($backend->isInstalled()) { + $backend->uninstall(); + + } + + self::$freeableDatabackends[] = $backend; + + $backend = array($backend); + + }; + + return $backends; + } + + protected function tearDown() + { + // Reduce memory foot print + foreach (self::$freeableDatabackends as $backend) { + $backend->free(); + + } + } + + /** + * @dataProvider provideInstallationBackends + */ + public function testInstallation(DataBackend $backend) + { + $backend->install(); + $backend->update(); + $backend->uninstall(); + } + + /** + * @dataProvider provideInstallationBackends + */ + public function testIsInstalled(DataBackend $backend) + { + $backend->install(); + $this->assertTrue($backend->isInstalled()); + + $backend->uninstall(); + $this->assertFalse($backend->isInstalled()); + } + + /** + * @dataProvider provideInstallationBackends + */ + public function testLastUpdate(DataBackend $backend) + { + $now = time(); + $backend->install(); + $update = $backend->getLastUpdate(); + $this->assertGreaterThanOrEqual($now, $update); + + $now = time(); + $backend->update(); + $update = $backend->getLastUpdate(); + $this->assertGreaterThanOrEqual($now, $update); + + $backend->uninstall(); + } + + /** + * Tests that the backend provides all banks and agencies + * + * @dataProvider provideBackends + */ + public function testInstallationIsComplete(DataBackend $backend) + { + $agencies = array(); + + foreach ($this->provideBanks() as $referenceBank) { + $bank = $backend->getBank($referenceBank->getBankID()); + + $this->assertEquals( + $referenceBank->getValidationType(), + $bank->getValidationType() + ); + + $agencies[$bank->getMainAgency()->getID()] = $bank->getMainAgency(); + foreach ($bank->getAgencies() as $agency) { + $agencies[$agency->getID()] = $agency; + + } + } + + $expectedAgencies = $this->provideAgencies(); + + $this->assertEquals(count($expectedAgencies), count($agencies)); + + foreach ($agencies as $id => $agency) { + $expectedAgency = $expectedAgencies[$id]; + $this->assertEqualAgency($expectedAgency, $agency); + + } + } + + /** + * Read all banks from the bundesbank file. + * + * @return Bank[] + */ + private function provideBanks() + { + $parser = new FileParser(); + $databackend = new FileDataBackend($parser->getFile()); + $banks = array(); + + for ($line = 0; $line < $parser->getLines(); $line++) { + $data = $parser->readLine($line); + $bank = $parser->getBank($databackend, $data); + $banks[$bank->getBankID()] = $bank; + + } + + return $banks; + } + + /** + * Read all agencies from the bundesbank file. + * + * @return Agency[] + */ + private function provideAgencies() + { + $parser = new FileParser(); + $databackend = new FileDataBackend($parser->getFile()); + $agencies = array(); + + for ($line = 0; $line < $parser->getLines(); $line++) { + $data = $parser->readLine($line); + $bank = $parser->getBank($databackend, $data); + $agency = $parser->getAgency($bank, $data); + $agencies[$agency->getID()] = $agency; + + } + + return $agencies; + } + + /** + * Testet, dass ein erneutes $backend->getBank($id) das selbe + * Objekt zurückliefert. + * + * @dataProvider provideBackends + */ + public function testSingleInstances(DataBackend $backend) + { + foreach (self::$referenceBackend->getAllBanks() as $refBank) { + $this->assertTrue( + $backend->getBank($refBank->getBankID()) === $backend->getBank($refBank->getBankID()), + "Different objects for bank {$refBank->getBankID()}" + ); + } + } + + /** + * @dataProvider provideBackends + */ + public function testGetAllBanks(DataBackend $backend) + { + $this->assertEquals( + count(self::$referenceBackend->getAllBanks()), + count($backend->getAllBanks()) + ); + } + + /** + * Test loading all banks + * + * @dataProvider provideBackends + */ + public function testBanks(DataBackend $backend) + { + foreach (self::$referenceBackend->getAllBanks() as $referenceBank) { + $testedBank = $backend->getBank($referenceBank->getBankID()); + + $this->assertEquals( + $referenceBank->getValidationType(), + $testedBank->getValidationType() + ); + + $this->assertEqualAgency( + $referenceBank->getMainAgency(), + $testedBank->getMainAgency() + ); + + $this->assertEquals( + count($referenceBank->getAgencies()), + count($testedBank->getAgencies()) + ); + + } + } + + /** + * Tests loading all agencies + * + * @dataProvider provideBackends + */ + public function testAgencies(DataBackend $backend) + { + foreach (self::$referenceBackend->getAllBanks() as $referenceBank) { + $testedBank = $backend->getBank($referenceBank->getBankID()); + + $referenceAgencies = array(); + foreach ($referenceBank->getAgencies() as $agency) { + $referenceAgencies[$agency->getID()] = $agency; + + } + + foreach ($testedBank->getAgencies() as $agency) { + $referenceAgency = $referenceAgencies[$agency->getID()]; + + $this->assertEqualAgency($referenceAgency, $agency); + + } + } + } + + private function assertEqualAgency(Agency $a, Agency $b) + { + $this->assertTrue($a->getBank()->getBankID() === $b->getBank()->getBankID()); + $this->assertTrue($a->getID() === $b->getID()); + $this->assertTrue($a->getPostcode() === $b->getPostcode()); + $this->assertTrue($a->getCity() === $b->getCity()); + $this->assertTrue($a->getName() === $b->getName()); + $this->assertTrue($a->getShortTerm() === $b->getShortTerm()); + $this->assertTrue($a->hasPAN() === $b->hasPAN()); + $this->assertTrue($a->hasBIC() === $b->hasBIC()); + if ($a->hasPAN()) { + $this->assertTrue($a->getPAN() === $b->getPAN()); + + } + if ($a->hasBIC()) { + $this->assertTrue($a->getBIC() === $b->getBIC()); + + } + } + + /** + * Test cases for testIsValidBIC() + * + * @see testIsValidBIC() + * @return array + */ + public function provideTestIsValidBIC() + { + $cases = array(); + foreach ($this->provideBackends() as $backendArray) { + $backend = $backendArray[0]; + $cases[] = array($backend, true, "VZVDDED1XXX"); + $cases[] = array($backend, true, "VZVDDED1001"); + $cases[] = array($backend, false, "VZVDDED1001X"); + $cases[] = array($backend, false, ""); + $cases[] = array($backend, false, "VZVDDED1~~~"); + + } + return $cases; + } + + /** + * Tests DataBackend::isValidBIC(); + * + * @dataProvider provideTestIsValidBIC + * @see DataBackend::isValidBIC(); + */ + public function testIsValidBIC(DataBackend $backend, $expected, $bic) + { + $this->assertEquals($expected, $backend->isValidBIC($bic)); + } + + /** + * Test cases for testGetBICAgencies() + * + * @see testGetBICAgencies() + */ + public function provideTestGetBICAgencies() + { + $cases = array(); + foreach ($this->provideBackends() as $backendArray) { + $backend = $backendArray[0]; + $cases[] = array($backend, "XXX", array()); + $cases[] = array($backend, "VZVDDED1XXX", array("52944")); + $cases[] = array($backend, "VZVDDED1XXX", array("52944")); + $cases[] = array($backend, "DELBDE33XXX", array("8536", "13567", "33248", "51683")); + + } + return $cases; + } + + /** + * Tests DataBackend::getBICAgencies() + * + * @dataProvider provideTestGetBICAgencies + * @see DataBackend::getBICAgencies(); + */ + public function testGetBICAgencies(DataBackend $backend, $bic, $expectedAgencyIds) + { + $agencies = $backend->getBICAgencies($bic); + $getID = function (Agency $agency) { + return $agency->getID(); + }; + $agenciesIds = array_map($getID, $agencies); + + sort($expectedAgencyIds); + sort($agenciesIds); + $this->assertEquals($expectedAgencyIds, $agenciesIds); + } +} + +BackendTest::classConstructor(); diff --git a/tests/unit-large/CrossProjectTest.php b/tests/unit-large/CrossProjectTest.php new file mode 100644 index 00000000..23cd1849 --- /dev/null +++ b/tests/unit-large/CrossProjectTest.php @@ -0,0 +1,216 @@ + + * @license WTFPL + * @large + */ +class CrossProjectTest extends TestCase +{ + + /** + * name of environment variable for setting this node number. + */ + const ENV_NODE_NUMBER = "NODE_NUMBER"; + + /** + * name of environment variable for setting the node count. + */ + const ENV_NODE_COUNT = "NODE_COUNT"; + + /** + * @var int + */ + #private $lastAccount = 9999999999, + private $lastAccount = 99999; + + /** + * @var int + */ + private $accountPadSize = 10; + + /** + * @var Array + */ + private $testedValidators = array(); + + /** + * @var Array + */ + private $failedBankDependentValidators = array(); + + /** + * @var int + */ + private static $nodeNumber = 0; + + /** + * @var int + */ + private static $nodeCount = 1; + + /** + * @var TestAPI[] + */ + private static $testAPIs = array(); + + public static function setUpBeforeClass(): void + { + self::$testAPIs = array(new BAVTestAPI()); + + try { + self::$testAPIs[] = new KontocheckTestAPI(); + + } catch (TestAPIUnavailableException $e) { + trigger_error("KontocheckTestAPI unavailable", E_USER_WARNING); + + } + + try { + //Too slow and version 1.45 has many false positives + //self::$testAPIs[] = new KtoblzcheckTestAPI(); + + } catch (TestAPIUnavailableException $e) { + trigger_error("KtoblzcheckTestAPI unavailable", E_USER_WARNING); + + } + } + + /** + * @return Bank[][] + */ + public function provideBanks() + { + $nodeNumber = getenv(self::ENV_NODE_NUMBER); + if ($nodeNumber) { + self::$nodeNumber = (int) $nodeNumber; + + } + $nodeCount = getenv(self::ENV_NODE_COUNT); + if ($nodeCount) { + self::$nodeCount = (int) $nodeCount; + + } + self::assertGreaterThan(self::$nodeNumber, self::$nodeCount); + + $banks = array(); + $backend = new PDODataBackend(PDOFactory::makePDO()); + $i = 0; + foreach ($backend->getAllBanks() as $bank) { + // only pick banks for this node. + if ($i % self::$nodeCount == self::$nodeNumber) { + $banks[] = array($bank); + + } + $i++; + + } + + return $banks; + } + + /** + * @dataProvider provideBanks + */ + public function testCrossProjects(Bank $bank) + { + try { + // Skip failed bank dependend validators or valid independend validators. + $isSkip = $bank->getValidator() instanceof Validator_BankDependent + ? array_key_exists($bank->getValidationType(), $this->failedBankDependentValidators) + : array_key_exists($bank->getValidationType(), $this->testedValidators); + + if ($isSkip) { + return; + + } + + // Generate accounts from $this->lastAccount until 0. + for ($account = $this->lastAccount; $account >= 0; $account--) { + + // Generate accounts with padded zeros up to $this->accountPadSize + for ($pad = strlen($account); $pad <= $this->accountPadSize; $pad++) { + $paddedAccount = str_pad($account, $pad, "0", STR_PAD_LEFT); + $this->assertSameResult($bank, $paddedAccount); + + } + } + + } catch (BankNotFoundTestAPIException $e) { + return; + + } catch (Exception $e) { + if ($bank instanceof Validator_BankDependent) { + $this->failedBankDependentValidators[$bank->getValidationType()] = true; + + } + throw $e; + + } + $this->testedValidators[$bank->getValidationType()] = true; + } + + private function assertSameResult(Bank $bank, $account) + { + $results = array(); + $resultValues = array(); + foreach (self::$testAPIs as $key => $testAPI) { + if ($testAPI->ignoreTestCase($bank, $account)) { + continue; + + } + $result = $testAPI->getResult($bank, $account); + $results[] = $result; + $resultValues[] = $result->getResult(); + + } + + $this->assertEquals( + 1, + count(array_unique($resultValues)), + $this->getErrorMessage($bank, $account, $results) + ); + } + + /** + * @param Bank $bank + * @param String $account + * @param array $results + * @return String + */ + private function getErrorMessage(Bank $bank, $account, Array $results) + { + $resultTranslation = array( + TestAPIResult::VALID => "valid", + TestAPIResult::INVALID => "invalid", + TestAPIResult::ERROR => "error" + ); + + $message = "bank: {$bank->getBankID()} method: {$bank->getValidationType()} account: $account"; + + foreach ($results as $result) { + $message .= " {$result->getTestAPI()->getName()}: ". $resultTranslation[$result->getResult()]; + if ($result instanceof TestAPIErrorResult) { + $message .= " {$result->getMessage()}"; + + } + } + + return $message; + } +} diff --git a/tests/unit/00UpdatePlanTest.php b/tests/unit/00UpdatePlanTest.php new file mode 100644 index 00000000..dc6bc26c --- /dev/null +++ b/tests/unit/00UpdatePlanTest.php @@ -0,0 +1,107 @@ + + */ +class UpdatePlanTest extends TestCase +{ + + /** + * Provide test cases for testIsOutdated() + * + * @see testIsOutdated() + */ + public function provideTestIsOutdated() + { + return array( + array("2012-11-01", "2013-01-31", false), + array("2012-10-31", "2013-01-31", true), + array("2013-02-01", "2013-04-01", false), + array("2013-01-31", "2013-04-01", true), + array("2013-02-01", "2013-02-01", false), + array("2013-01-31", "2013-02-01", true), + array("2013-02-01", "2013-02-31", false), + array("2013-01-31", "2013-02-31", true), + array("2013-02-01", "2013-03-01", false), + array("2013-01-31", "2013-03-01", true), + array("2013-02-01", "2013-03-31", false), + array("2013-01-31", "2013-03-31", true), + ); + } + + /** + * Tests isOutdated() + * + * @dataProvider provideTestIsOutdated + * @param string $mtime file time + * @param string $time current time + * @param bool $expectedIsOutdated + * @see UpdatePlan::isOutdated() + */ + public function testIsOutdated($mtime, $time, $expectedIsOutdated) + { + $fileUtil = new FileUtil(); + $file = tempnam($fileUtil->getTempDirectory(), 'bavtest'); + touch($file, strtotime($mtime)); + $backend = new FileDataBackend($file); + + TimeMock::setTime(strtotime($time)); + + $updatePlan = new AutomaticUpdatePlan(); + $this->assertEquals($expectedIsOutdated, $updatePlan->isOutdated($backend)); + + TimeMock::disable(); + } + + /** + * @expectedException \PHPUnit\Framework\Error\Warning + */ + public function testLogUpdatePlan() + { + $updatePlan = new LogUpdatePlan(); + $updatePlan->perform(new FileDataBackend()); + } + + /** + * @expectedException \PHPUnit\Framework\Error\Notice + * @medium + */ + public function testAutomaticUpdatePlanNotice() + { + $fileUtil = new FileUtil(); + $file = tempnam($fileUtil->getTempDirectory(), 'bavtest'); + $updatePlan = new AutomaticUpdatePlan(); + $updatePlan->perform(new FileDataBackend($file)); + } + + /** + * @expectedException \PHPUnit\Framework\Error\Notice + * @medium + */ + public function testAutomaticUpdatePlan() + { + $fileUtil = new FileUtil(); + $file = tempnam($fileUtil->getTempDirectory(), 'bavtest'); + touch($file, strtotime("-1 year")); + $backend = new FileDataBackend($file); + + $updatePlan = new AutomaticUpdatePlan(); + $this->assertTrue($updatePlan->isOutdated($backend)); + + $updatePlan->perform($backend); + $this->assertFalse($updatePlan->isOutdated($backend)); + } +} diff --git a/tests/unit/AgencyQueryTest.php b/tests/unit/AgencyQueryTest.php new file mode 100644 index 00000000..17abc7bd --- /dev/null +++ b/tests/unit/AgencyQueryTest.php @@ -0,0 +1,109 @@ + + * @licends GPL + */ +class AgencyQueryTest extends TestCase +{ + + /** + * @return SQLDataBackend[][] + */ + public function provideBackends() + { + $conn = array( + "pdo" => PDOFactory::makePDO(), + ); + $doctrineContainer = DoctrineBackendContainer::buildByConnection($conn, true); + + return array( + array(new PDODataBackend(PDOFactory::makePDO())), + array($doctrineContainer->getDataBackend()) + ); + } + + /** + * @dataProvider provideBackends + */ + public function testOnlyID(SQLDataBackend $backend) + { + $agencies = $backend->getAgencies( + 'SELECT id FROM bav_agency LIMIT 100' + ); + $this->assertAgencies($agencies, 100); + } + + /** + * @dataProvider provideBackends + */ + public function testIDAndBank(SQLDataBackend $backend) + { + $agencies = $backend->getAgencies( + 'SELECT id, bank FROM bav_agency LIMIT 100' + ); + $this->assertAgencies($agencies, 100); + } + + /** + * @dataProvider provideBackends + */ + public function testNoBank(SQLDataBackend $backend) + { + $agencies = $backend->getAgencies( + 'SELECT id, name, postcode, city, shortTerm, pan, bic FROM bav_agency LIMIT 100' + ); + $this->assertAgencies($agencies, 100); + } + + /** + * @dataProvider provideBackends + * @expectedException malkusch\bav\MissingAttributesDataBackendIOException + */ + public function testNoID(SQLDataBackend $backend) + { + $result = $backend->getAgencies( + 'SELECT name, postcode, city, shortTerm, pan, bic, bank FROM bav_agency LIMIT 1' + ); + } + + private function assertAgencies(Array $agencies, $count) + { + $this->assertEquals($count, count($agencies)); + + foreach ($agencies as $agency) { + if ($agency->isMainAgency()) { + $this->assertTrue( + $agency->getBank()->getMainAgency() === $agency, + "Inconsistent Main Agency" + ); + $this->assertTrue( + $agency->getBank() === $agency->getBank()->getMainAgency()->getBank(), + "Inconsistent Bank" + ); + + } else { + $includedCount = 0; + foreach ($agency->getBank()->getAgencies() as $banksAgency) { + $this->assertTrue( + $banksAgency->getBank() === $agency->getBank(), + "Inconsistent bank" + ); + if ($banksAgency === $agency) { + $includedCount++; + + } + } + $this->assertEquals(1, $includedCount, "Inconsistent agency"); + } + } + } +} diff --git a/tests/unit/BAVFacadeTest.php b/tests/unit/BAVFacadeTest.php new file mode 100644 index 00000000..4625144c --- /dev/null +++ b/tests/unit/BAVFacadeTest.php @@ -0,0 +1,277 @@ + + * @see BAV + */ +class BAVFacadeTest extends TestCase +{ + + /** + * Tests BAV::getBank(); + * + * @see BAV::getBank(); + */ + public function testGetBank() + { + $bav = new BAV(); + $bank = $bav->getBank("73362500"); + $this->assertNotNull($bank); + } + + /** + * Tests BAV::getBank(); + * + * @expectedException malkusch\bav\BankNotFoundException + * @see BAV::getBank(); + */ + public function testFailGetBank() + { + $bav = new BAV(); + $bav->getBank("12345678"); + } + + /** + * Tests BAV::getAgencies(); + * + * @expectedException malkusch\bav\BankNotFoundException + * @see BAV::getAgencies(); + */ + public function testFailGetAgencies() + { + $bav = new BAV(); + $bav->getAgencies("12345678"); + } + + /** + * Test cases for testGetAgencies() + * + * @return array + * @see testGetAgencies() + */ + public function provideTestGetAgencies() + { + return array( + array("73362500", 0), + array("10070000", 2), + array("10020890", 5), + ); + } + + /** + * Tests BAV::getAgencies(); + * + * @dataProvider provideTestGetAgencies + * @see BAV::getAgencies(); + */ + public function testGetAgencies($bankID, $count) + { + $bav = new BAV(); + $agencies = $bav->getAgencies($bankID); + $this->assertEquals($count, count($agencies)); + } + + /** + * Tests BAV::getMainAgency(); + * + * @see BAV::getMainAgency(); + */ + public function testGetMainAgency() + { + $bav = new BAV(); + $agency = $bav->getMainAgency("73362500"); + $this->assertNotNull($agency); + } + + /** + * Tests BAV::getMainAgency(); + * + * @expectedException malkusch\bav\BankNotFoundException + * @see BAV::getMainAgency(); + */ + public function testFailGetMainAgency() + { + $bav = new BAV(); + $bav->getMainAgency("12345678"); + } + + /** + * Test cases for testIsValidBank() + * + * @see testBankExists() + * @return array + */ + public function provideTestIsValidBank() + { + return array( + array("73362500", true), + array("12345678", false), + ); + } + + /** + * Tests BAV::isValidBank(); + * + * @dataProvider provideTestIsValidBank + * @see BAV::isValidBank(); + */ + public function testIsValidBank($bankID, $expected) + { + $bav = new BAV(); + $this->assertEquals($expected, $bav->isValidBank($bankID)); + } + + /** + * Test cases for testIsValidBankAccount() + * + * @see testIsValidBankAccount() + * @return array + */ + public function provideTestIsValidBankAccount() + { + return array( + array("73362500", "0110030005", false), + array("73362500", "0010030005", true), + ); + } + + /** + * Tests BAV::isValidBankAccount(); + * + * @dataProvider provideTestIsValidBankAccount + * @see BAV::isValidBankAccount(); + */ + public function testIsValidBankAccount($bankID, $account, $expected) + { + $bav = new BAV(); + $this->assertEquals($expected, $bav->isValidBankAccount($bankID, $account)); + } + + /** + * Test cases for testIsValidBIC() + * + * @see testIsValidBIC() + * @return array + */ + public function provideTestIsValidBIC() + { + return array( + array("VZVDDED1XXX", true), + array("VZVDDED1", true), + array("VZVDDED1~~~", false), + ); + } + + /** + * Tests BAV::isValidBankAccount(); + * + * @dataProvider provideTestIsValidBIC + * @see BAV::isValidBIC(); + */ + public function testIsValidBIC($bic, $expected) + { + $bav = new BAV(); + $this->assertEquals($expected, $bav->isValidBIC($bic)); + } + + /** + * Test cases for testGetBICAgencies() + * + * @see testGetBICAgencies() + * @return array + */ + public function provideTestGetBICAgencies() + { + return array( + array("VZVDDED1XXX", array("52944")), + array("VZVDDED1", array("52944")), + array("VZVDDED1~~~", array()), + ); + } + + /** + * Tests BAV::getBICAgencies(); + * + * @dataProvider provideTestGetBICAgencies + * @see BAV::getBICAgencies(); + */ + public function testGetBICAgencies($bic, $expected) + { + $bav = new BAV(); + $agencies = $bav->getBICAgencies($bic); + $getID = function (Agency $agency) { + return $agency->getID(); + }; + $agenciesIds = array_map($getID, $agencies); + + sort($expected); + sort($agenciesIds); + $this->assertEquals($expected, $agenciesIds); + } + + /** + * Tests filter validation + * + * @see BAV::getValidAccountFilterCallback() + * @see BAV::getValidBankFilterCallback() + */ + public function testFilterValidation() + { + $bav = new BAV(); + + $this->assertFalse( + filter_var( + "0", + FILTER_CALLBACK, + $bav->getValidBankFilterCallback() + ) + ); + + $this->assertTrue( + filter_var( + "10000000", + FILTER_CALLBACK, + $bav->getValidBankFilterCallback() + ) + ); + + $this->assertTrue( + filter_var( + "12345", + FILTER_CALLBACK, + $bav->getValidAccountFilterCallback() + ) + ); + + $this->assertFalse( + filter_var( + "0", + FILTER_CALLBACK, + $bav->getValidAccountFilterCallback() + ) + ); + } + + /** + * Tests BAV::isValidAccount(); + * + * @dataProvider provideTestIsValidBankAccount + * @see BAV::isValidAccount(); + */ + public function testValidAccount($bankID, $account, $expected) + { + $bav = new BAV(); + $bav->isValidBank($bankID); + + $this->assertEquals($expected, $bav->isValidAccount($account)); + } +} diff --git a/tests/unit/BICUtilTest.php b/tests/unit/BICUtilTest.php new file mode 100644 index 00000000..5ff42ddf --- /dev/null +++ b/tests/unit/BICUtilTest.php @@ -0,0 +1,42 @@ + + */ +class BICUtilTest extends TestCase +{ + + /** + * Test cases for testNormalize + * + * @see testNormalize() + */ + public function provideTestNormalize() + { + return array( + array("VZVDDED1", "VZVDDED1XXX"), + array("VZVDDED1ABC", "VZVDDED1ABC"), + ); + } + + /** + * Tests BICUtil:normalize() + * + * @see BICUtil::normalize() + * @dataProvider provideTestNormalize() + */ + public function testNormalize($bic, $expected) + { + $this->assertEquals($expected, BICUtil::normalize($bic)); + } +} diff --git a/tests/unit/BackendContainerTest.php b/tests/unit/BackendContainerTest.php new file mode 100644 index 00000000..993077a9 --- /dev/null +++ b/tests/unit/BackendContainerTest.php @@ -0,0 +1,57 @@ + + */ +class BackendContainerTest extends TestCase +{ + + /** + * Tests automatic installation. + */ + public function testAutomaticInstallation() + { + ConfigurationRegistry::getConfiguration()->setUpdatePlan(null); + $fileUtil = new FileUtil(); + $container = new FileDataBackendContainer(tempnam($fileUtil->getTempDirectory(), 'bavtest')); + + $this->assertTrue(ConfigurationRegistry::getConfiguration()->isAutomaticInstallation()); + + $backend = $container->getDataBackend(); + $this->assertTrue($backend->isInstalled()); + + $backend->uninstall(); + } + + /** + * Tests automatic installation. + */ + public function testAutomaticUpdate() + { + $updatePlan = new AutomaticUpdatePlan(); + $updatePlan->setNotice(false); + ConfigurationRegistry::getConfiguration()->setUpdatePlan($updatePlan); + + $fileUtil = new FileUtil(); + $container = new FileDataBackendContainer(tempnam($fileUtil->getTempDirectory(), 'bavtest')); + $backend = $container->getDataBackend(); + + touch($backend->getFile(), strtotime("-1 year")); + $this->assertTrue($updatePlan->isOutdated($backend)); + + $container->applyUpdatePlan($backend); + $this->assertFalse($updatePlan->isOutdated($backend)); + + $backend->uninstall(); + ConfigurationRegistry::getConfiguration()->setUpdatePlan(null); + } +} diff --git a/tests/unit/ConfigurationLocatorTest.php b/tests/unit/ConfigurationLocatorTest.php new file mode 100644 index 00000000..0506c158 --- /dev/null +++ b/tests/unit/ConfigurationLocatorTest.php @@ -0,0 +1,118 @@ + + * @licends GPL + * @see ConfigurationLocator + */ +class ConfigurationLocatorTest extends TestCase +{ + + /** + * locate() should return null + * + * @see ConfigurationLocator::locate(); + */ + public function testlocateReturnsNull() + { + $locator = new ConfigurationLocator(array(__DIR__ . "/noop.php")); + $this->assertNull($locator->locate()); + } + + /** + * locate() should throw an exception + * + * @see ConfigurationLocator::locate(); + * @expectedException malkusch\bav\ConfigurationException + */ + public function testlocateThrowsException() + { + $locator = new ConfigurationLocator( + array( + __DIR__ . "/../data/no_configuration.php" + ) + ); + $locator->locate(); + } + + /** + * locate() should find absolute paths + * + * @param string[] $paths + * @dataProvider provideTestLocateFindsAbsolutePath + * @see ConfigurationLocator::locate(); + */ + public function testLocateFindsAbsolutePath(array $paths) + { + $locator = new ConfigurationLocator($paths); + $configuration = $locator->locate(); + + $this->assertInstanceOf("malkusch\bav\Configuration", $configuration); + $this->assertEquals("test", $configuration->getTempDirectory()); + } + + /** + * Test cases for testLocateFindsAbsolutePath(). + * + * @return string[][][] + * @see testLocateFindsAbsolutePath() + */ + public function provideTestLocateFindsAbsolutePath() + { + $existingPath = __DIR__ . "/../data/configuration.php"; + $notExistingPath = __DIR__ . "/../data/noop.php"; + + return array( + array(array($existingPath)), + array(array($existingPath, $notExistingPath)), + array(array($notExistingPath, $existingPath)), + ); + } + + /** + * locate() should find paths from the include path + * + * @param string[] $paths + * @dataProvider provideTestLocateFindsIncludePath + * @see ConfigurationLocator::locate(); + */ + public function testLocateFindsIncludePath($includePath, array $paths) + { + set_include_path(get_include_path() . PATH_SEPARATOR . $includePath); + + $locator = new ConfigurationLocator($paths); + $configuration = $locator->locate(); + + $this->assertInstanceOf("malkusch\bav\Configuration", $configuration); + $this->assertEquals("test", $configuration->getTempDirectory()); + + restore_include_path(); + } + + /** + * Test cases for testLocateFindsIncludePath(). + * + * @return string[][][] + * @see testLocateFindsIncludePath() + */ + public function provideTestLocateFindsIncludePath() + { + $existingPath = "configuration.php"; + $notExistingPath = "noop.php"; + $includePath = __DIR__ . "/../data"; + + return array( + array($includePath, array($existingPath)), + array($includePath, array($existingPath, $notExistingPath)), + array($includePath, array($notExistingPath, $existingPath)), + ); + } +} diff --git a/tests/unit/ConfigurationRegistryTest.php b/tests/unit/ConfigurationRegistryTest.php new file mode 100644 index 00000000..46c03cc4 --- /dev/null +++ b/tests/unit/ConfigurationRegistryTest.php @@ -0,0 +1,58 @@ + + * @licends GPL + * @see ConfigurationRegistry + */ +class ConfigurationRegistryTest extends TestCase +{ + + /** + * Disable update hook + */ + protected function tearDown(): void + { + ConfigurationRegistry::getConfiguration()->setUpdatePlan(null); + } + + /** + * Tests the initialization with a configuration from the include path. + * + * @see ConfigurationRegistry::classConstructor() + */ + public function testInitWithIncludePathConfiguration() + { + set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . "/../data/"); + + ConfigurationRegistry::classConstructor(); + $configuration = ConfigurationRegistry::getConfiguration(); + + $this->assertInstanceOf("malkusch\bav\Configuration", $configuration); + $this->assertEquals("test", $configuration->getTempDirectory()); + + restore_include_path(); + } + + /** + * Tests the initialization with the default configuration + * + * @see ConfigurationRegistry::classConstructor() + */ + public function testInitWithDefaultConfiguration() + { + ConfigurationRegistry::classConstructor(); + $configuration = ConfigurationRegistry::getConfiguration(); + + $this->assertInstanceOf("malkusch\bav\DefaultConfiguration", $configuration); + $this->assertNotEquals("test", $configuration->getTempDirectory()); + } +} diff --git a/tests/unit/ContextValidationTest.php b/tests/unit/ContextValidationTest.php new file mode 100644 index 00000000..54f9a1b9 --- /dev/null +++ b/tests/unit/ContextValidationTest.php @@ -0,0 +1,145 @@ + + */ +class ContextValidationTest extends TestCase +{ + + /** + * @var ContextValidation + */ + private $validation; + + protected function setUp(): void + { + $bav = new BAV(); + $this->validation = new ContextValidation($bav->getDataBackend()); + } + + /** + * Tests switching the bank context + * + * @see ContextValidation::isValidBank() + */ + public function testContextSwitch() + { + $this->validation->isValidBank("0"); + $this->assertTrue($this->validation->isValidAccount("0")); + + $this->validation->isValidBank("10000000"); + $this->assertFalse($this->validation->isValidAccount("0")); + + $this->validation->isValidBank("0"); + $this->assertTrue($this->validation->isValidAccount("0")); + } + + /** + * Tests isValidBank() + * + * @see ContextValidation::isValidBank() + */ + public function testValidBank() + { + $this->assertTrue($this->validation->isValidBank("10000000")); + $this->assertFalse($this->validation->isValidBank("0")); + } + + /** + * Tests isValidAccount() + * + * @see ContextValidation::isValidAccount() + */ + public function testValidAccount() + { + // set context + $this->validation->isValidBank("10000000"); + + $this->assertTrue($this->validation->isValidAccount("12345")); + $this->assertFalse($this->validation->isValidAccount("0")); + } + + /** + * Tests filter validation + * + * @see ContextValidation::getValidAccountFilterCallback() + * @see ContextValidation::getValidBankFilterCallback() + */ + public function testFilterValidation() + { + // Valid bank context + $this->assertTrue( + filter_var( + "10000000", + FILTER_CALLBACK, + $this->validation->getValidBankFilterCallback() + ) + ); + $this->assertTrue( + filter_var( + "12345", + FILTER_CALLBACK, + $this->validation->getValidAccountFilterCallback() + ) + ); + $this->assertFalse( + filter_var( + "0", + FILTER_CALLBACK, + $this->validation->getValidAccountFilterCallback() + ) + ); + + // Invalid bank context, account always valid + $this->assertFalse( + filter_var( + "12345", + FILTER_CALLBACK, + $this->validation->getValidBankFilterCallback() + ) + ); + $this->assertTrue( + filter_var( + "0", + FILTER_CALLBACK, + $this->validation->getValidAccountFilterCallback() + ) + ); + } + + /** + * Test an invalid context + * + * @see ContextValidation::getValidAccountFilterCallback() + * @expectedException malkusch\bav\InvalidContextException + */ + public function testFilterInvalidContext() + { + filter_var( + "0", + FILTER_CALLBACK, + $this->validation->getValidAccountFilterCallback() + ); + } + + /** + * Test an invalid context + * + * @see ContextValidation::isValidAccount() + * @expectedException malkusch\bav\InvalidContextException + */ + public function testInvalidContext() + { + $this->validation->isValidAccount("12345"); + } +} diff --git a/tests/unit/DataConstraintTest.php b/tests/unit/DataConstraintTest.php new file mode 100644 index 00000000..03cf81f1 --- /dev/null +++ b/tests/unit/DataConstraintTest.php @@ -0,0 +1,149 @@ +setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + self::$pdo->exec("DROP TABLE IF EXISTS bank"); + self::$pdo->exec( + "CREATE TEMPORARY TABLE bank ( + id int primary key, + blz char(8), + isMain tinyint(1), + name varchar(58), + plz varchar(5), + city varchar(35), + shortterm varchar(27), + pan char(5), + bic varchar(11), + validator char(2), + index(blz), + index(name), + index(shortterm), + index(pan), + index(bic) + ) engine=MEMORY" + ); + + $fp = fopen(__DIR__ . '/../../data/banklist.txt', 'r'); + if (! is_resource($fp)) { + throw new RuntimeException('I/O-Error'); + + } + + $insert = self::$pdo->prepare( + "INSERT INTO bank + ( id, blz, isMain, name, plz, city, shortterm, pan, bic, validator) + VALUES (:id, :blz, :isMain, :name, :plz, :city, :shortTerm, :pan, :bic, :validator)" + ); + $insert->bindParam(':id', $id); + $insert->bindParam(':blz', $blz); + $insert->bindParam(':isMain', $isMain); + $insert->bindParam(':name', $name); + $insert->bindParam(':plz', $plz); + $insert->bindParam(':city', $city); + $insert->bindParam(':shortTerm', $shortTerm); + $insert->bindParam(':pan', $pan); + $insert->bindParam(':bic', $bic); + $insert->bindParam(':validator', $validator); + + while ($line = fgets($fp)) { + $blz = substr($line, 0, 8); + $isMain = ($line[8] === '1') ? 1 : 0; + $name = trim(substr($line, 9, 58)); + $plz = trim(substr($line, 67, 5)); + $city = trim(substr($line, 72, 35)); + $shortTerm = trim(substr($line, 107, 27)); + $pan = trim(substr($line, 134, 5)); + $bic = trim(substr($line, 139, 11)); + $validator = substr($line, 150, 2); + $id = substr($line, 152, 6); + + $insert->execute(); + + } + fclose($fp); + } + + /** + * @return Array + */ + public function provideParsedLines() + { + $parser = new FileParser(); + $lines = array(); + + for ($i = 0; $i < $parser->getLines(); $i++) { + $line = $parser->readLine($i); + $blz = mb_substr($line, 0, 8, 'UTF-8'); + $type = mb_substr($line, FileParser::TYPE_OFFSET, FileParser::TYPE_LENGTH, 'UTF-8'); + + $lines[] = array($blz, $type); + } + + return $lines; + } + + /** + * @dataProvider provideParsedLines + */ + public function testParser($blz, $type) + { + $this->assertRegExp('~^\d{8}$~', $blz); + $this->assertRegExp('~^[\dA-Z]\d$~', $type); + } + + /** + * Every bankID should have exact one validator + */ + public function testValidatorCount() + { + $statement = self::$pdo->query( + "SELECT blz FROM bank GROUP BY blz HAVING count(DISTINCT validator) != 1" + ); + $this->assertFalse( + $statement->fetch(), + "bankID <-> validator is not n:1!" + ); + } + + /** + * Every bankID should have exact one mainAgency + */ + public function testMainAgency () + { + $statement = self::$pdo->query("SELECT blz FROM bank GROUP BY blz HAVING SUM(isMain) != 1"); + $this->assertFalse( + $statement->fetch(), + "Every bankID should have exact one mainAgency." + ); + } + + public function testBLZDatatype () + { + $statement = self::$pdo->query("SELECT blz FROM bank WHERE blz LIKE '0%'"); + $this->assertFalse( + $statement->fetch(), + "Every bankID should not start with 0." + ); + } +} diff --git a/tests/unit/DownloaderTest.php b/tests/unit/DownloaderTest.php new file mode 100644 index 00000000..5e637cd9 --- /dev/null +++ b/tests/unit/DownloaderTest.php @@ -0,0 +1,108 @@ + + */ +class DownloaderTest extends TestCase +{ + + /** + * Returns URIs and the expected md5 sum of their contents. + * + * @return String[][] + */ + public function provideTestURIs() + { + return array( + array("http://www.gnu.org/licenses/gpl-2.0.txt", "b234ee4d69f5fce4486a80fdaf4a4263") + ); + } + + /** + * Tests downloadContent(); + * + * @param string $uri URI + * @param string $md5 expected MD5 sum + * @dataProvider provideTestURIs + * @see Downloader::downloadContent() + */ + public function testDownloadContent($uri, $md5) + { + $downloader = new Downloader(); + $content = $downloader->downloadContent($uri); + $this->assertEquals($md5, md5($content)); + } + + /** + * Tests downloadFile(); + * + * @param string $uri URI + * @param string $md5 expected MD5 sum + * @dataProvider provideTestURIs + * @see Downloader::downloadFile() + */ + public function testDownloadFile($uri, $md5) + { + $downloader = new Downloader(); + $file = $downloader->downloadFile($uri); + $this->assertEquals($md5, md5_file($file)); + unlink($file); + } + + /** + * Tests a sequence of downloadContent() and downloadFile(). + * + * @param string $uri URI + * @param string $md5 expected MD5 sum + * @dataProvider provideTestURIs + * @see Downloader::downloadFile() + * @see Downloader::downloadContent() + */ + public function testDownloadSequence($uri, $md5) + { + $downloader = new Downloader(); + + $content = $downloader->downloadContent($uri); + $this->assertEquals($md5, md5($content)); + + $file = $downloader->downloadFile($uri); + $this->assertEquals($md5, md5_file($file)); + unlink($file); + + $content = $downloader->downloadContent($uri); + $this->assertEquals($md5, md5($content)); + } + + /** + * Tests failing downloadContent(); + * + * @expectedException malkusch\bav\DownloaderException + * @see Downloader::downloadContent() + */ + public function testFailDownloadContent() + { + $downloader = new Downloader(); + $downloader->downloadContent("http://example.org/XXX"); + } + + /** + * Tests failing downloadFile(); + * + * @expectedException malkusch\bav\DownloaderException + * @see Downloader::downloadFile() + */ + public function testFailDownloadFile() + { + $downloader = new Downloader(); + $file = $downloader->downloadFile("http://example.org/XXX"); + } +} diff --git a/tests/unit/FileParserTest.php b/tests/unit/FileParserTest.php new file mode 100644 index 00000000..e6432f78 --- /dev/null +++ b/tests/unit/FileParserTest.php @@ -0,0 +1,160 @@ + + * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations + * @see FileParser + */ +class FileParserTest extends TestCase +{ + + /** + * Tests using the default file + * + * @see FileParser::__construct() + */ + public function testDefaultFile() + { + $parser = new FileParser(); + $this->assertEquals( + realpath(__DIR__ . "/../../data/banklist.txt"), + realpath($parser->getFile()) + ); + } + + /** + * Tests getAgency() + * + * @see FileParser::getAgency() + */ + public function testGetAgency() + { + $this->markTestIncomplete(); + } + + /** + * Tests getBank() + * + * @see FileParser::getBank() + */ + public function testGetBank() + { + $this->markTestIncomplete(); + } + + /** + * Tests getBankID() + * + * @see FileParser::getBankID() + */ + public function testGetBankID() + { + $this->markTestIncomplete(); + } + + /** + * Tests getLineLength() + * + * @see FileParser::getLineLength() + * @dataProvider provideTestGetLineLength + */ + public function testGetLineLength($lineLength, $file) + { + $parser = new FileParser($file); + $this->assertEquals($lineLength, $parser->getLineLength()); + } + + /** + * Test cases for testGetLineLength() + * + * @return array + * @see testGetLineLength() + */ + public function provideTestGetLineLength() + { + return array( + array(6, __DIR__ . "/../data/fileParserTest/simple.txt"), + array(170, __DIR__ . "/../data/fileParserTest/bb-excerpt.txt"), + ); + } + + /** + * Tests getLines() + * + * @see FileParser::getLines() + * @dataProvider provideTestGetLines + */ + public function testGetLines($lines, $file) + { + $parser = new FileParser($file); + $this->assertEquals($lines, $parser->getLines()); + } + + /** + * Test cases for testGetLines() + * + * @return array + * @see testGetLines() + */ + public function provideTestGetLines() + { + return array( + array(2, __DIR__ . "/../data/fileParserTest/simple.txt"), + array(10, __DIR__ . "/../data/fileParserTest/bb-excerpt.txt"), + ); + } + + /** + * Tests readLine() + * + * @see FileParser::readLine() + * @dataProvider provideTestReadLine + */ + public function testReadLine($file, $line, $expectedData) + { + $parser = new FileParser($file); + $data = $parser->readLine($line); + $this->assertEquals($expectedData, $data); + } + + /** + * Test cases for testReadLine() + * + * @return string[][] + * @see testReadLine() + */ + public function provideTestReadLine() + { + return array( + array( + __DIR__ . "/../data/fileParserTest/simple.txt", + 0, + "12345\n" + ), + array( + __DIR__ . "/../data/fileParserTest/simple.txt", + 1, + "67890" + ) + ); + } + + /** + * Tests seekLine() + * + * @see FileParser::seekLine() + */ + public function testSeekLine() + { + $this->markTestIncomplete(); + } +} diff --git a/tests/unit/FileUtilTest.php b/tests/unit/FileUtilTest.php new file mode 100644 index 00000000..1b1a5bdd --- /dev/null +++ b/tests/unit/FileUtilTest.php @@ -0,0 +1,70 @@ + + * @license WTFPL + */ +class FileUtilTest extends TestCase +{ + + /** + * Test only renaming in one filesystem. + */ + public function testSafeRenameOneFS() + { + $before = __DIR__ . "/../data/testSafeRenameBefore"; + $after = __DIR__ . "/../data/testSafeRenameAfter"; + + touch($before); + + $fileUtil = new FileUtil(); + $fileUtil->safeRename($before, $after); + + $this->assertFileExists($after); + + unlink($after); + } + + /** + * Tests a user configured temporary directory + */ + public function testSetConfiguredTempDirectory() + { + $directory = "/root"; + + $configuration = new DefaultConfiguration(); + $configuration->setTempDirectory($directory); + + $fileUtil = new FileUtil($configuration); + $this->assertEquals($directory, $fileUtil->getTempDirectory()); + } + + /** + * Tests getting a writable directory. + */ + public function testGetWritableTempDirectory() + { + $fileUtil = new FileUtil(); + $this->assertTrue(is_writable($fileUtil->getTempDirectory())); + } + + /** + * Tests getting /tmp. + * + * @requires OS Linux + */ + public function testLinuxTempDirectory() + { + $fileUtil = new FileUtil(); + $this->assertEquals("/tmp", $fileUtil->getTempDirectory()); + } +} diff --git a/tests/unit/FileValidatorTest.php b/tests/unit/FileValidatorTest.php new file mode 100644 index 00000000..ef8885c1 --- /dev/null +++ b/tests/unit/FileValidatorTest.php @@ -0,0 +1,90 @@ + + * @see BAV + */ +class FileValidatorTest extends TestCase +{ + + public function testValidate() + { + $backend = new FileDataBackend(); + $file = $backend->getFile(); + + $validator = new FileValidator(); + $validator->validate($file); + } + + /** + * @expectedException malkusch\bav\InvalidFilesizeException + */ + public function testInvalidFileSize() + { + $validator = new FileValidator(); + $validator->validate(__FILE__); + } + + /** + * @expectedException malkusch\bav\InvalidLineLengthException + */ + public function testInvalidLineLength() + { + $backend = new FileDataBackend(); + $file = $backend->getFile(); + + $invalidFile = __DIR__ . "/../data/invalidLength.txt"; + copy($file, $invalidFile); + + $fp = fopen($invalidFile, "c"); + fputs($fp, "invalid line\n"); + + $validator = new FileValidator(); + $validator->validate($invalidFile); + } + + /** + * @expectedException malkusch\bav\InvalidLineLengthException + */ + public function testNotConstantLineLength() + { + $backend = new FileDataBackend(); + $file = $backend->getFile(); + + $invalidFile = __DIR__ . "/../data/notConstantLength.txt"; + copy($file, $invalidFile); + + $fp = fopen($invalidFile, "a"); + fputs($fp, "X\n"); + + $validator = new FileValidator(); + $validator->validate($invalidFile); + } + + /** + * @expectedException malkusch\bav\FieldException + */ + public function testInvalidFirstLineContent() + { + $backend = new FileDataBackend(); + $file = $backend->getFile(); + + $invalidFile = __DIR__ . "/../data/invalidFirstLineContent.txt"; + copy($file, $invalidFile); + + $fp = fopen($invalidFile, "c"); + fputs($fp, "XXX"); + + $validator = new FileValidator(); + $validator->validate($invalidFile); + } +} diff --git a/tests/unit/LockTest.php b/tests/unit/LockTest.php new file mode 100644 index 00000000..4cbfe718 --- /dev/null +++ b/tests/unit/LockTest.php @@ -0,0 +1,139 @@ + + * @see Lock + */ +class LockTest extends TestCase +{ + + /** + * Tests checkedLock(). + * + * @see Lock::checkedLock() + */ + public function testCheckedLock() + { + $name = __FUNCTION__; + $checkLock = new Lock($name); + $lock = new Lock($name); + + $this->assertFalse($lock->checkedLock()); + $this->assertFalse($checkLock->nonblockingLock()); + + $lock->unlock(); + } + + /** + * Tests executeOnce(). + * + * @see Lock::executeOnce() + */ + public function testExecuteOnce() + { + $name = __FUNCTION__; + + $isExecuted = false; + $isExecutedCheck = false; + + $lock = new Lock($name); + $lock->executeOnce(function () use (&$isExecuted, &$isExecutedCheck, $name) { + $isExecuted = true; + + $checkLock = new Lock($name); + $checkLock->nonblockingExecuteOnce(function () use (&$isExecutedCheck) { + $isExecutedCheck = true; + }); + }); + + $this->assertTrue($isExecuted); + $this->assertFalse($isExecutedCheck); + } + + /** + * Tests lock(). + * + * @see Lock::lock() + */ + public function testLock() + { + $name = __FUNCTION__; + $checkLock = new Lock($name); + $lock = new Lock($name); + + $lock->lock(); + $this->assertFalse($checkLock->nonblockingLock()); + + $lock->unlock(); + } + + /** + * Tests nonblockingExecuteOnce(). + * + * @see Lock::nonblockingExecuteOnce() + */ + public function testNonblockingExecuteOnce() + { + $name = __FUNCTION__; + + $isExecuted = false; + $isExecutedCheck = false; + + $lock = new Lock($name); + $lock->nonblockingExecuteOnce(function () use (&$isExecuted, &$isExecutedCheck, $name) { + $isExecuted = true; + + $checkLock = new Lock($name); + $checkLock->nonblockingExecuteOnce(function () use (&$isExecutedCheck) { + $isExecutedCheck = true; + }); + }); + + $this->assertTrue($isExecuted); + $this->assertFalse($isExecutedCheck); + } + + /** + * Tests nonblockingLock(). + * + * @see Lock::nonblockingLock() + */ + public function testNonblockingLock() + { + $name = __FUNCTION__; + $checkLock = new Lock($name); + $lock = new Lock($name); + + $this->assertTrue($lock->nonblockingLock()); + $this->assertFalse($checkLock->nonblockingLock()); + + $lock->unlock(); + } + + /** + * Tests unlock(). + * + * @see Lock::unlock() + */ + public function testUnlock() + { + $name = __FUNCTION__; + $checkLock = new Lock($name); + $lock = new Lock($name); + + $lock->lock(); + $lock->unlock(); + $this->assertTrue($checkLock->nonblockingLock()); + + $checkLock->unlock(); + } +} diff --git a/tests/unit/StatementContainerTest.php b/tests/unit/StatementContainerTest.php new file mode 100644 index 00000000..ea124052 --- /dev/null +++ b/tests/unit/StatementContainerTest.php @@ -0,0 +1,56 @@ + + * @see StatementContainer + */ +class StatementContainerTest extends TestCase +{ + + /** + * @var StatementContainer + */ + private $statementContainer; + + public function setUp(): void + { + $this->statementContainer = new StatementContainer(PDOFactory::makePDO()); + } + + /** + * Tests two equal queries should return the same object + */ + public function testStoring() + { + $query = "SELECT :param as test FROM DUAL"; + $stmt1 = $this->statementContainer->prepare($query); + $stmt2 = $this->statementContainer->prepare($query); + + $this->assertSame($stmt1, $stmt2); + } + + /** + * Tests the query + */ + public function testQuery() + { + $query = "SELECT :param as test FROM DUAL"; + + $stmt = $this->statementContainer->prepare($query); + $stmt->execute(array(":param" => 5)); + $this->assertEquals(array("5"), $stmt->fetchAll(\PDO::FETCH_COLUMN)); + + $stmt2 = $this->statementContainer->prepare($query); + $stmt2->execute(array(":param" => 4)); + $this->assertEquals(array("4"), $stmt2->fetchAll(\PDO::FETCH_COLUMN)); + } +} diff --git a/tests/unit/URIPickerTest.php b/tests/unit/URIPickerTest.php new file mode 100644 index 00000000..b9888c2f --- /dev/null +++ b/tests/unit/URIPickerTest.php @@ -0,0 +1,70 @@ + + */ +class URIPickerTest extends TestCase +{ + + /** + * Provides URIPicker implementations. + * + * @return URIPicker[][] + */ + public function provideURIPicker() + { + return array( + array(new DOMURIPicker()), + ); + } + + /** + * Tests pickURI() + */ + public function testPickURI() + { + $picker = new DOMURIPicker(); + + $html = file_get_contents(__DIR__ . "/../data/bankleitzahlen_download.html"); + $uri = $picker->pickURI($html, new \DateTime('2016-04-26 00:00:00')); + + $this->assertEquals( + // @codingStandardsIgnoreStart + "/Redaktion/DE/Downloads/Aufgaben/Unbarer_Zahlungsverkehr/Bankleitzahlen/2016_06_05/blz_2016_03_07_txt.txt?__blob=publicationFile", + // @codingStandardsIgnoreEnd + $uri + ); + } + + /** + * Tests pickURI() + * + * @expectedException malkusch\bav\URIPickerException + */ + public function testFailPickURI() + { + $picker = new DOMURIPicker(); + + $html = "XXX"; + $picker->pickURI($html, new \DateTime()); + } + + /** + * All pickers are available on this platform. + */ + public function testIsAvailable() + { + $picker = new DOMURIPicker(); + + $this->assertTrue($picker->isAvailable()); + } +} diff --git a/tests/unit/Validator66_PR18_Test.php b/tests/unit/Validator66_PR18_Test.php new file mode 100644 index 00000000..af5c820d --- /dev/null +++ b/tests/unit/Validator66_PR18_Test.php @@ -0,0 +1,50 @@ + + * @license WTFPL + * @link https://github.com/bav-php/bav/pull/18 + */ +class Validator66_PR18_Test extends TestCase +{ + + /** + * Tests for Validator66 which produces the remainer 0 and 1. + * + * @param string $account The account id. + * @param bool $expected The expected validation result. + * + * @dataProvider provideTestRemainer0and1 + * @link https://www.mail-archive.com/aqbanking-devel@lists.sourceforge.net/msg01292.html + */ + public function testRemainer0and1($account, $expected) + { + $backend = $this->getMock("malkusch\bav\FileDataBackend"); + $bank = $this->getMock( + "malkusch\bav\Bank", array(), array($backend, 1, 66)); + + $validator = new Validator66($bank); + $this->assertEquals($expected, $validator->isValid($account)); + } + + /** + * Returns test cases for testRemainer0and1(). + * + * @return array Test cases. + */ + public function provideTestRemainer0and1() + { + return array( + array("0100001001", true), // 0 + array("0100201000", true), // 1 + ); + } +} diff --git a/tests/unit/Validator74_PR18_Test.php b/tests/unit/Validator74_PR18_Test.php new file mode 100644 index 00000000..a0a1b24f --- /dev/null +++ b/tests/unit/Validator74_PR18_Test.php @@ -0,0 +1,64 @@ + + * @license WTFPL + * @link https://github.com/bav-php/bav/pull/18 + */ +class Validator74_PR18_Test extends TestCase +{ + + /** + * Tests for Validator74 which produces accumulators which end from 1 to 14. + * + * A halfdecade seems to be understanded as 5, 15, 25, …. + * + * @param string $account The account id. + * @param bool $expected The expected validation result. + * + * @dataProvider provideTestAllHalfDecades + * @link https://www.mail-archive.com/aqbanking-devel@lists.sourceforge.net/msg01292.html + */ + public function testAllHalfDecades($account, $expected) + { + $backend = $this->getMock("malkusch\bav\FileDataBackend"); + $bank = $this->getMock( + "malkusch\bav\Bank", array(), array($backend, 1, 74)); + + $validator = new Validator74($bank); + $this->assertEquals($expected, $validator->isValid($account)); + } + + /** + * Returns test cases for testAllHalfDecades(). + * + * @return array Test cases. + */ + public function provideTestAllHalfDecades() + { + return array( + array("500004", true), // 5 - 1 = 4 + array("100003", true), // 5 - 2 = 3 + array("100102", true), // 5 - 3 = 2 + array("200001", true), // 5 - 4 = 1 + array("111000", true), // 15 - 5 = 10 (0) + array("200209", true), // 15 - 6 = 9 + array("200308", true), // 15 - 7 = 8 + array("200407", true), // 15 - 8 = 7 + array("200506", true), // 15 - 9 = 6 + array("200605", true), // 15 - 10 = 5 + array("190004", true), // 15 - 11 = 4 + array("200803", true), // 15 - 12 = 3 + array("200902", true), // 15 - 13 = 2 + array("144001", true), // 15 - 14 = 1 + ); + } +} diff --git a/tests/unit/ValidatorE3Test.php b/tests/unit/ValidatorE3Test.php new file mode 100644 index 00000000..97bb6f53 --- /dev/null +++ b/tests/unit/ValidatorE3Test.php @@ -0,0 +1,61 @@ +getMock('malkusch\bav\FileDataBackend'); + $bank = $this->getMock('malkusch\bav\Bank', [], [$backend, 1, 1]); + + $validator = new ValidatorE3($bank); + $this->assertEquals($expected, $validator->isValid($account)); + } + + /** + * Returns Deutsche Bundesbank E3 test accounts, see + * https://www.bundesbank.de/Redaktion/DE/Downloads/Aufgaben/Unbarer_Zahlungsverkehr/pruefzifferberechnungsmethoden.pdf?__blob=publicationFile + * + * @return array Test cases. + */ + public function getE3TestAccounts() + { + //['2345678909', false], ['5678901237', false] are not used, as those numbers result to true via alternative method + return [ + ['9290701', true], + ['539290858', true], + ['1501824', true], + ['1501832', true], + ['0123456789', false], + ['7414398260', false], + ['9290708', true], + ['539290854', true], + ['1501823', true], + ['1501831', true], + ['2345678909', true], + ['5678901237', true], + ['0123456789', false], + ['2345678901', false], + ['5678901234', false], + ['7414398260', false], + ]; + } +} diff --git a/tests/unit/ValidatorE4Test.php b/tests/unit/ValidatorE4Test.php new file mode 100644 index 00000000..e8a1908a --- /dev/null +++ b/tests/unit/ValidatorE4Test.php @@ -0,0 +1,55 @@ +getMock('malkusch\bav\FileDataBackend'); + $bank = $this->getMock('malkusch\bav\Bank', [], [$backend, 1, 1]); + + $validator = new ValidatorE4($bank); + $this->assertEquals($expected, $validator->isValid($account)); + } + + /** + * Returns Deutsche Bundesbank E4 test accounts, see + * https://www.bundesbank.de/Redaktion/DE/Downloads/Aufgaben/Unbarer_Zahlungsverkehr/pruefzifferberechnungsmethoden.pdf?__blob=publicationFile + * + * @return array Test cases. + */ + public function getE4TestAccounts() + { + //['1501824', false], ['1501832', false], ['9290701', false] are not used, as those numbers result to true via alternative method + return [ + ['1501836', true], + ['9290702', true], + ['539290858', true], + ['12345007', false], + ['87654005', false], + ['1501824', true], + ['1501832', true], + ['9290701', true], + ['12345007', false], + ['87654005', false], + ]; + } +} diff --git a/tests/unit/ValidatorFactoryTest.php b/tests/unit/ValidatorFactoryTest.php new file mode 100644 index 00000000..a3046e64 --- /dev/null +++ b/tests/unit/ValidatorFactoryTest.php @@ -0,0 +1,68 @@ + + * @license WTFPL + * @see ValidatorFactory + */ +class ValidatorFactoryTest extends TestCase +{ + + /** + * @var ValidatorFactory + */ + private $factory; + + protected function setUp(): void + { + $this->factory = new ValidatorFactory(); + } + + /** + * Tests build() + * + * @param string $type Validation type + * @see ValidatorFactory::build() + * @dataProvider provideTestBuild + */ + public function testBuild($type) + { + $bav = new BAV(); + $bank = new Bank($bav->getDataBackend(), null, $type); + + $validator = $this->factory->build($bank); + $this->assertInstanceOf("\\malkusch\\bav\\Validator$type", $validator); + } + + /** + * Test cases for testBuild() + * + * @return string[][] + * @see testBuild() + */ + public function provideTestBuild() + { + $cases = array(); + + $files = ClassFile::getClassFiles(__DIR__.'/../../classes/validator/validators/'); + foreach ($files as $class) { + if (! preg_match('~^Validator([A-Z0-9]{2})$~', $class->getName(), $matchType)) { + continue; + + } + $type = $matchType[1]; + $cases[] = array($type); + + } + + return $cases; + } +} diff --git a/tests/unit/ValidatorTest.php b/tests/unit/ValidatorTest.php new file mode 100644 index 00000000..d709b142 --- /dev/null +++ b/tests/unit/ValidatorTest.php @@ -0,0 +1,196 @@ + + * @license WTFPL + */ +class ValidatorTest extends TestCase +{ + + /** + * @var DataBackend + */ + private static $dataBackend; + + /** + * @var array This array contains all names of implemented algorithms as keys. + */ + private static $implementedBanks = array(); + + /** + * @var array all known banks + */ + private static $knownBanks = array(); + + /** + * @throws FileParserIOException + * @throws FileParserNotExistsException + */ + protected function setUp(): void + { + if (! empty(self::$dataBackend)) { + return; + + } + $container = new FileDataBackendContainer(); + + #self::$dataBackend = new PDODataBackend(PDOFactory::makePDO()); + self::$dataBackend = $container->getDataBackend(); + + + foreach (self::$dataBackend->getAllBanks() as $bank) { + self::$knownBanks[$bank->getValidationType()] = $bank; + + } + } + + /** + * @return Array + */ + public function provideBanks() + { + $this->setUp(); + + $banks = array(); + $files = ClassFile::getClassFiles(__DIR__.'/../../classes/validator/validators/'); + foreach ($files as $class) { + if (! preg_match('~^Validator([A-Z0-9]{2})$~', $class->getName(), $matchType)) { + continue; + + } + $validatorType = $matchType[1]; + $bank = array_key_exists($validatorType, self::$knownBanks) + ? self::$knownBanks[$validatorType] + : new Bank(self::$dataBackend, 12345678, $validatorType); + + $banks[] = array($bank); + self::$implementedBanks[$validatorType] = $bank; + + } + return $banks; + } + + /** + * @return Array + */ + public function provideAccountsAndBanksInAllLengths() + { + $providedAccountsAndBanks = array(); + foreach ($this->provideBanks() as $bank) { + $bank = $bank[0]; + for ($length = 0; $length <= 10; $length++) { + $providedAccountsAndBanks[] = array($bank, str_repeat(1, $length)); + + } + } + return $providedAccountsAndBanks; + } + + /** + * 0 - 0000000000 should always be invalid + * + * @param String $validatorType + * @throws ClassFileIOException + * @throws MissingClassException + * @dataProvider provideBanks + */ + public function testNullIsInvalid(Bank $bank) + { + for ($length = 0; $length <= 10; $length++) { + $account = str_pad("0", $length, "0", STR_PAD_LEFT); + $this->assertFalse( + $bank->isValid($account), + "{$bank->getBankID()}/{$bank->getValidationType()} $account should be invalid." + ); + + } + } + + /** + * Short accounts should not raise exception. + * + * @param int $account + * @throws ClassFileIOException + * @throws MissingClassException + * @dataProvider provideAccountsAndBanksInAllLengths + */ + public function testAccountLength(Bank $bank, $account) + { + $bank->isValid($account); + } + + /** + * @return Array + */ + public function provideTestAccounts() + { + $verifyArray = json_decode(file_get_contents(__DIR__ . '/../data/accounts.json')); + if (! is_array($verifyArray)) { + throw new \RuntimeException("couldn't parse accounts.json."); + + } + array_walk( + $verifyArray, + function (&$item) { + $item = array($item); + } + ); + return $verifyArray; + } + + /** + * Validator::isValid() with an int should raise a warning. + * + * @see Validator::isValid() + * @dataProvider provideBanks + * @expectedException \PHPUnit\Framework\Error\Warning + */ + public function testWarningForIsValidWithInt(Bank $bank) + { + $intAccount = 0020012357; + $bank->isValid($intAccount); + } + + /** + * @dataProvider provideTestAccounts + */ + public function testAccount(\stdClass $testCase) + { + if (! empty($testCase->blz)) { + $bank = new Bank(self::$dataBackend, $testCase->blz, $testCase->validator); + + } else { + $this->assertArrayHasKey($testCase->validator, self::$implementedBanks); + $bank = self::$implementedBanks[$testCase->validator]; + + $this->assertEquals($testCase->validator, $bank->getValidationType()); + + } + + $test = $this; + $checkAccounts = function ($account, $key, $isValid) use ($bank, $test, $testCase) { + $test->assertEquals( + $isValid, + $bank->isValid($account), + "Validator $testCase->validator validates wrongly for account $account." + ); + }; + + if (isset($testCase->valid)) { + array_walk($testCase->valid, $checkAccounts, true); + + } + if (isset($testCase->invalid)) { + array_walk($testCase->invalid, $checkAccounts, false); + + } + } +}