Luhn
in package
Utility class for generating and validating Luhn numbers.
Luhn algorithm is used to validate credit card numbers, IMEI numbers, and National Provider Identifier numbers.
Tags
Table of Contents
- computeCheckDigit() : string
- generateLuhnNumber() : string
- Generate a Luhn compliant number.
- isValid() : bool
- Checks whether a number (partial number + check digit) is Luhn compliant
- checksum() : int
Methods
computeCheckDigit()
public
static computeCheckDigit(string $partialNumber) : string
Parameters
- $partialNumber : string
Return values
string —generateLuhnNumber()
Generate a Luhn compliant number.
public
static generateLuhnNumber(string $partialValue) : string
Parameters
- $partialValue : string
Return values
string —isValid()
Checks whether a number (partial number + check digit) is Luhn compliant
public
static isValid(string $number) : bool
Parameters
- $number : string
Return values
bool —checksum()
private
static checksum(string $number) : int
Parameters
- $number : string