header($header); if (! is_string($value) || strlen($value) !== 2) { continue; } $code = strtoupper($value); if (! in_array($code, ['XX', 'T1'], true)) { return $code; } } return null; } public static function countryLabel(?string $code): string { if ($code === null || $code === '') { return 'Unknown'; } if (function_exists('locale_get_display_region')) { $name = locale_get_display_region('_'.$code, 'en'); return is_string($name) && $name !== '' ? $name : $code; } return $code; } }