Skip to content

selective-php/luhn

Repository files navigation

Luhn

Luhn (modulus 10 or mod 10 algorithm) for PHP

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Requirements

  • PHP 8.1+

Installation

composer require selective/luhn

Usage

Create a number

<?php

use Selective\Luhn\Luhn;

$luhn = new Luhn();

echo $luhn->create('7992739871'); // 3

Validate a number

<?php

use Selective\Luhn\Luhn;

$luhn = new Luhn();

$luhn->validate('79927398713'); // true
$luhn->validate('79927398710'); // false

License

  • MIT