2017 © Pedro Peláez
 

library luhn-algorithm

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

image

nekman/luhn-algorithm

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  • Wednesday, June 20, 2018
  • by NEkman
  • Repository
  • 0 Watchers
  • 8 Stars
  • 9,329 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 11 Versions
  • 8 % Grown

The README.md

Luhn Algorithm

Build Status Coverage Status, (*1)

This is a zero dependency implementation of the Luhn Algorithm for PHP 7.4 and above. 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., (*2)

Installation

Install with Composer:, (*3)

composer require nekman/luhn-algorithm

Usage

In order to instantiate a new instance of the library, use the factory:, (*4)

```php use Nekman\LuhnAlgorithm\LuhnAlgorithmFactory;, (*5)

$luhn = LuhnAlgorithmFactory::create(); ```, (*6)

You can find the library facade in the LuhnAlgorithmInterface.php file., (*7)

The Number class is a container class that holds the actual number and the check digit. It does no validation nor does it calculate the check digit. It exists to clearly separate the number from the check digit and to define when the check digit exists or not. To simplify the process of validating a number you can use the named constructor Number::fromString() like this:, (*8)

use Nekman\LuhnAlgorithm\Number;

// Assume $creditCard is from a form.
$number = Number::fromString($creditCard);

if ($luhn->isValid($number)) {
    // Number is valid.
}

Alternatively, if you want to calculate the checksum or check digit for a number:, (*9)

use Nekman\LuhnAlgorithm\Number;

$number = new Number(12345);

$checksum = $luhn->calcChecksum($number);

$checkDigit = $luhn->calcCheckDigit($number);

Versioning

This project complies with Semantic Versioning., (*10)

Changelog

For a complete list of changes, and how to migrate between major versions, see releases page., (*11)

The Versions

20/06 2018

dev-master

9999999-dev

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

validation card credit credit card identification luhn identification number

22/05 2018

4.0.3

4.0.3.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

validation card credit identification luhn

22/05 2018

dev-php_70

dev-php_70

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

validation card credit identification luhn

16/05 2018

4.0.2

4.0.2.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

validation card credit identification luhn

27/02 2018

4.0.1

4.0.1.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

validation card credit identification luhn

27/02 2018

dev-improvements

dev-improvements

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

validation card credit identification luhn

26/02 2018

4.0.0

4.0.0.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

validation card credit identification luhn

19/02 2018

3.0.0

3.0.0.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

validation card credit identification luhn

19/02 2018

2.0.1

2.0.1.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Development Requires

validation credit card luhn identification number

01/06 2014

2.0.0

2.0.0.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Development Requires

validation credit card luhn identification number

13/03 2014

1.0.0

1.0.0.0

Implementation of the Luhn algorithm in PHP. Used in validation of credit card numbers and some national identification numbers.

  Sources   Download

MIT

The Requires

  • php >=4.0.0

 

The Development Requires

validation credit card luhn identification number