该包已被弃用且不再维护。未建议替代包。
关于该包最新版本(v0.1.0)的许可信息不可用。

v0.1.0 2013-02-13 05:50 UTC

This package is not auto-updated.

Last update: 2016-11-19 07:47:40 UTC


README

Build Status

这是一个实现Luhn算法的库,用于验证信用卡号的校验和。

<?php
use PlasmaConduit\Luhn;

echo "The '4012888888881881' CC# is ";
if (Luhn::validate("4012888888881881")) {
    echo "valid\n";
} else {
    echo "invalid\n";
}

公共接口

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);
}