Faker\Calculator\Luhn::computeCheckDigit PHP 메소드

computeCheckDigit() 공개 정적인 메소드

public static computeCheckDigit ( $partialNumber ) : string
$partialNumber
리턴 string
    public static function computeCheckDigit($partialNumber)
    {
        $checkDigit = self::checksum($partialNumber . '0');
        if ($checkDigit === 0) {
            return 0;
        }
        return (string) (10 - $checkDigit);
    }

Usage Example

예제 #1
0
파일: Luhn.php 프로젝트: fzaninotto/faker
 /**
  * Generate a Luhn compliant number.
  *
  * @param string $prefix
  * @return string
  */
 public static function generateLuhnNumber($partialValue)
 {
     if (!preg_match('/^\\d+$/', $partialValue)) {
         throw new InvalidArgumentException('Argument should be an integer.');
     }
     return $partialValue . Luhn::computeCheckDigit($partialValue);
 }
All Usage Examples Of Faker\Calculator\Luhn::computeCheckDigit