Bluz\Validator\Rule\CreditCard::verifyMod10 PHP Method

verifyMod10() private method

Verify by Mod10
private verifyMod10 ( string $input ) : boolean
$input string
return boolean
    private function verifyMod10($input)
    {
        $sum = 0;
        $input = strrev($input);
        for ($i = 0; $i < strlen($input); $i++) {
            $current = substr($input, $i, 1);
            if ($i % 2 == 1) {
                $current *= 2;
                if ($current > 9) {
                    $firstDigit = $current % 10;
                    $secondDigit = ($current - $firstDigit) / 10;
                    $current = $firstDigit + $secondDigit;
                }
            }
            $sum += $current;
        }
        return $sum % 10 == 0;
    }