public static function personId($check)
{
if (!preg_match('/^[0-9]{13}$/', $check)) {
return false;
}
list($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m) = str_split($check);
$checksum = 11 - (7 * ($a + $g) + 6 * ($b + $h) + 5 * ($c + $i) + 4 * ($d + $j) + 3 * ($e + $k) + 2 * ($f + $l)) % 11;
return $checksum == $m;
}
/** * test the jmbg method of RsValidation * * @return void */ public function testPersonId() { $this->assertTrue(RsValidation::personId('1707017170007')); $this->assertFalse(RsValidation::personId('1707017170008')); $this->assertFalse(RsValidation::personId('170701717000')); $this->assertFalse(RsValidation::personId('A707017170007')); }