komakino / modulus11
Installs: 158 763
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 1
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2025-01-08 19:26:08 UTC
README
Modulus11 algorithm implementation for PHP. The Modulus11 algorithm is used in some bank account numbers and national identity numbers.
Installation
To add this package as a dependency to your project, simply add a dependency on komakino/modulus11
to your project's composer.json
file.
{ "require": { "komakino/modulus11": "*" } }
Usage
use Komakino\Modulus11\Modulus11;
Factors
The standard factors for Modulus11 calculations are [2,3,4,5,6,7], looped. In some cases other factors are used. If your implementation requires custom factors, simply supply them as a second argument to any method.
Static methods
static bool validate(string|int $number, array $factors = null)
Validates a number.
Modulus11::validate('11223344'); // returns false Modulus11::validate('12345674'); // returns true
static int calculate(string|int $partial_number, array $factors = null)
Calculates the check digit of a number.
Modulus11::calculate('1122334'); // returns 6 Modulus11::calculate('1234567'); // returns 4
static string appendCheckDigit(string|int $partial_number, array $factors = null)
Calculates the check digit and returns number with check digit appended.
Modulus11::appendCheckDigit('1122334'); // returns 11223346 Modulus11::appendCheckDigit('1234567'); // returns 12345674