srph/luhn

An implementation of Luhn algorithm (aka mod-10 algorithm) in PHP.

v0.1.0 2015-03-16 08:59 UTC

This package is not auto-updated.

Last update: 2024-12-25 10:37:05 UTC


README

An implementation of Luhn algorithm (aka mod-10 algorithm) to validate (verify the checksum of) credit card numbers in PHP.

* This was written to try out PHPUnit, but feel free to use it for anything as long as the MIT License permits.

Installation

To install this library, simply run composer require in your project's root directory:

$ composer require srph/luhn

Usage

This library is very easy to use! Our function only accepts one string argument and returns a boolean.

<?php
/**
 * SRPH\Luhn\luhn(<string>);
 */
SRPH\Luhn\luhn('79927398712') => true
?>

For PHP >=v5.6, you can use the use function (aka import function) syntax:

<?php
use function SRPH\Luhn\luhn;

echo luhn('79927398712') // => true
?>

Contribution

Feel free to submit any inquiry, question, issue or pull-request!

Building

* For contributors or for learning purposes only.

Requirements:

First, clone the repository, and then install the development dependencies.

$ git clone https://github.com/srph/luhn.php.git && cd luhn.php
$ composer install

You're good to go.

Automation

# ensure that you are in the root directory of the project
$ phpunit # run tests

Acknowledgement

php-luhn © 2015+, Kier Borromeo (srph). Released under the MIT License.

srph.github.io  ·  GitHub @srph  ·  Twitter @_srph