public static function personId($check)
{
$pattern = '/^[0-9]{6}[-+A][0-9A-Z]{4}$/';
if (!(bool) preg_match($pattern, $check)) {
return false;
}
$date = \DateTime::createFromFormat('dmy', substr($check, 0, 6));
if ($date === false) {
return false;
}
$list = array_merge(range(0, 9), range('A', 'Y'));
foreach ($list as $key => $item) {
if (in_array($item, ['G', 'I', 'O', 'Q'], true)) {
unset($list[$key]);
}
$list[$key] = (string) $item;
}
$list = array_values($list);
return $check[strlen($check) - 1] === $list[intval(substr($check, 0, 6) . substr($check, 7, 3)) % 31];
}