180 $str = preg_replace(
'/(\s)/',
'', $str);
181 $str = strtoupper($str);
184 if (!preg_match(
'/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $str)) {
189 for ($i = 0; $i < 9; $i++) {
190 $num[$i] = substr($str, $i, 1);
192 '@phan-var-force array<int<0,8>,string> $num';
195 if (preg_match(
'/(^[0-9]{8}[A-Z]{1}$)/', $str)) {
196 if ($num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr($str, 0, 8) % 23, 1)) {
204 $sum = (int) $num[2] + (
int) $num[4] + (int) $num[6];
205 for ($i = 1; $i < 8; $i += 2) {
206 $sum += intval(substr((
string) (2 * (
int) $num[$i]), 0, 1)) + intval(substr((
string) (2 * (
int) $num[$i]), 1, 1));
208 $n = 10 - (int) substr((
string) $sum, strlen((
string) $sum) - 1, 1);
211 if (preg_match(
'/^[KLM]{1}/', $str)) {
212 if ($num[8] == chr(64 + $n) || $num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr($str, 1, 8) % 23, 1)) {
220 if (preg_match(
'/^[ABCDEFGHJNPQRSUVW]{1}/', $str)) {
221 if ($num[8] == chr(64 + $n) || $num[8] == substr((
string) $n, strlen((
string) $n) - 1, 1)) {
229 if (preg_match(
'/^[T]{1}/', $str)) {
230 if ($num[8] == preg_match(
'/^[T]{1}[A-Z0-9]{8}$/', $str)) {
238 if (preg_match(
'/^[XYZ]{1}/', $str)) {
239 if ($num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr(str_replace(array(
'X',
'Y',
'Z'), array(
'0',
'1',
'2'), $str), 0, 8) % 23, 1)) {