plasmaconduit / luhn
Installs: 3 412
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- plasmaconduit/map: 0.1.*
Requires (Dev)
This package is not auto-updated.
Last update: 2016-11-19 07:47:40 UTC
README
An implementation of the Luhn algorithm for verifying the checksum of credit card numbers.
<?php use PlasmaConduit\Luhn; echo "The '4012888888881881' CC# is "; if (Luhn::validate("4012888888881881")) { echo "valid\n"; } else { echo "invalid\n"; }
Public Interface
namespace PlasmaConduit; class Luhn { /** * Takes a number and calculates the Luhn checksum of it * * @param {Int} $number - The number to calculate the checksum for * @return {Int} - The computed checksum */ static public function checksum($number); /** * Given an incomplete Luhn this calculates the check digit * * @param {Int} $number - The incomplete number to derive the check digit * @return {Int} - The derived check digit */ static public function getCheckDigit($number); /** * Given a complete Luhn this function returns true if it's valid * * @param {Int} $number - The Luhn to validate * @return {Boolean} - True on valid false otherwise */ static public function validate($number); }