https://github.com/srph/php-luhn
An implementation of Luhn algorithm (aka mod-10 algorithm) to PHP
https://github.com/srph/php-luhn
Last synced: about 1 month ago
JSON representation
An implementation of Luhn algorithm (aka mod-10 algorithm) to PHP
- Host: GitHub
- URL: https://github.com/srph/php-luhn
- Owner: srph
- Created: 2015-03-14T12:40:17.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-20T07:40:35.000Z (over 11 years ago)
- Last Synced: 2025-08-02T13:34:16.148Z (11 months ago)
- Language: PHP
- Size: 188 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# php-luhn [](https://travis-ci.org/srph/php-luhn?branch=master) [](https://packagist.org/packages/sroh/luhn) [](http://opensource.org/licenses/MIT)
An implementation of [Luhn algorithm (aka mod-10 algorithm)](http://en.wikipedia.org/wiki/Luhn_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:
```bash
$ composer require srph/luhn
```
## Usage
This library is very easy to use! Our `function` **only** accepts one `string` argument and `return`s a `boolean`.
```php
);
*/
SRPH\Luhn\luhn('79927398712') => true
?>
```
For PHP `>=v5.6`, you can use the `use function` (aka `import function`) syntax:
```php
true
?>
```
## Contribution
Feel free to submit any inquiry, question, issue or pull-request!
### Building
\* *For contributors or for learning purposes only.*
**Requirements**:
- [PHP `>=v5.x`](https://php.net) (Ehh?)
- [Composer](https://getcomposer.org) (Install development dependencies)
- [Git](https://git-scm.org) (To clone the repository)
First, clone the repository, and then install the development dependencies.
```bash
$ git clone https://github.com/srph/luhn.php.git && cd luhn.php
$ composer install
```
You're good to go.
### Automation
```bash
# 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](https://mit-license.org).
> [srph.github.io](http://srph.github.io) ·
> GitHub [@srph](https://github.com/srph) ·
> Twitter [@_srph](https://twitter.com/_srph)