Skip to content
/ damm Public

A PHP library that calculates and verifies the check digit using the Damm algorithm.

Notifications You must be signed in to change notification settings

sunaoka/damm

Repository files navigation

Damm algorithm for PHP

Latest License PHP Test codecov


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)

About

A PHP library that calculates and verifies the check digit using the Damm algorithm.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages