=0;--$i) { $sum += $this->sumTable[$flip++ & 0x1][$number[$i]]; } // Multiply by 9 $sum *= 9; // Last digit of sum is check digit return (int)substr($sum,-1,1); } /** * Validate number against check digit * * @param string $number * @param integer $digit * @return boolean */ public function validate(string $number, int $digit) { $calculated = $this->calculate($number); if($digit == $calculated) { return true; } else { return false; } } }