*/ private const MAP = [ 'A' => 'at', 'AT' => 'at', 'AUT' => 'at', 'B' => 'be', 'CA' => 'ca', 'CH' => 'ch', 'CZ' => 'cz', 'D' => 'de', 'DEU' => 'de', 'DK' => 'dk', 'E' => 'es', 'ES' => 'es', 'F' => 'fr', 'FI' => 'fi', 'FL' => 'li', 'FR' => 'fr', 'GR' => 'gr', 'GRE' => 'gr', 'HR' => 'hr', 'HRV' => 'hr', 'HU' => 'hu', 'I' => 'it', 'IL' => 'il', 'IR' => 'ie', 'IS' => 'is', 'IT' => 'it', 'LT' => 'lt', 'LV' => 'lv', 'MT' => 'mt', 'N' => 'no', 'NL' => 'nl', 'PL' => 'pl', 'PRT' => 'pt', 'PT' => 'pt', 'RUS' => 'ru', 'S' => 'se', 'SI' => 'si', 'SLO' => 'sk', 'UK' => 'gb', 'USA' => 'us', 'ZA' => 'za', ]; /** * Tokens already reported in this process, so a master data file full of the same * unknown token produces one log line rather than one per hotel. * * @var array */ private array $reported = []; public function __construct( private readonly LoggerInterface $logger, ) { } /** * @param string|null $token the raw `hotel/land` value * * @return string|null lowercase ISO-2, or null when absent, empty or unmappable */ public function map(?string $token): ?string { if (null === $token) { return null; } $normalized = strtoupper(trim($token)); if ('' === $normalized) { return null; } if (isset(self::MAP[$normalized])) { return self::MAP[$normalized]; } if (false === isset($this->reported[$normalized])) { $this->reported[$normalized] = true; $this->logger->warning('Unmapped BusPro country token', ['token' => $token]); } return null; } }