sunaoka / damm
A PHP library that calculates and verifies the check digit using the Damm algorithm.
v1.1.0
2024-10-30 04:26 UTC
Requires
- php: ^7.2 | ^8.0
Requires (Dev)
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^8.5 || ^9.6 || ^10.5 || ^11.4
This package is auto-updated.
Last update: 2024-11-30 04:40:40 UTC
README
A PHP library that calculates and verifies the check digit using the Damm algorithm.
Quasigroups are supported from order 3 to order 64 as well as order 10.
Installation
composer require sunaoka/damm
Usage
Quasigroup of order 10
<?php use Sunaoka\Damm\Damm; use Sunaoka\Damm\Order\Order10; $damm = new Damm('0123456789', new Order10()); echo $damm->calculate('572'); // => 4 var_dump($damm->validate('5724')); // => bool(true)
Quasigroup of order 62
<?php use Sunaoka\Damm\Damm; use Sunaoka\Damm\Order\Order62; $damm = new Damm('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', new Order62()); echo $damm->calculate('4MTYDKH0S0E'); // => D var_dump($damm->validate('4MTYDKH0S0ED')); // => bool(true)