Luhn Template Generator

2.0.1 2024-02-15 00:37 UTC

This package is auto-updated.

Last update: 2024-11-15 02:34:13 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License Build Status

Luhn

Templated Luhn generator and validator.

This is an implementation of the Luhn Algorithm for PHP. The Luhn Algorithm is used to validate things like credit cards and national identification numbers. More information on the algorithm can be found at Wikipedia.

Installation

Install with Composer:

composer require tankfairies/luhn 

Usage

Instantiate a new instance of the library:

Generate numeric Luhn e.g. USR-7950-8874 : -

use Tankfairies\Luhn\Luhn;

$luhn = new Luhn(new SimpleNum());
$luhn->setTemplate('USR-####-####');

$token = $luhn->generate();

Generate alpha numeric Luhn e.g. USR-0tm6-e2h4 : -

use Tankfairies\Luhn\Luhn;

$luhn = new Luhn(new SimpleAlnum());
$luhn->setTemplate('USR-####-####');

$token = $luhn->generate();

Validate a Luhn (returns true or false): -

use Tankfairies\Luhn\Luhn;

$luhn = new Luhn();
$luhn->validate('USR-f36x-x79n9');

Copyright and license

The tankfairies/luhn library is Copyright (c) 2019 Tankfairies (https://tankfairies.com) and licensed for use under the MIT License (MIT).