self::OUTBOUND_BOOKING, self::INBOUND_TRAVEL => self::INBOUND_BOOKING, default => throw new \InvalidArgumentException("Unknown travel direction: $travelDirection"), }; } /** * Maps booking direction code to travel direction code. * * @param string $bookingDirection The booking direction code ('H' or 'R') * * @return string The travel direction code ('HIN' or 'RUECK') * * @throws \InvalidArgumentException When direction code is not recognized */ public static function bookingToTravel(string $bookingDirection): string { return match ($bookingDirection) { self::OUTBOUND_BOOKING => self::OUTBOUND_TRAVEL, self::INBOUND_BOOKING => self::INBOUND_TRAVEL, default => throw new \InvalidArgumentException("Unknown booking direction: $bookingDirection"), }; } /** * Gets all outbound direction codes. * * @return string[] Array of outbound direction codes in all formats */ public static function getOutboundCodes(): array { return [self::OUTBOUND_TRAVEL, self::OUTBOUND_BOOKING]; } /** * Gets all inbound direction codes. * * @return string[] Array of inbound direction codes in all formats */ public static function getInboundCodes(): array { return [self::INBOUND_TRAVEL, self::INBOUND_BOOKING]; } /** * Checks if a direction code is outbound. * * @param string $direction The direction code to check * * @return bool True if the direction is outbound, false otherwise */ public static function isOutbound(string $direction): bool { return in_array($direction, self::getOutboundCodes(), true); } /** * Checks if a direction code is inbound. * * @param string $direction The direction code to check * * @return bool True if the direction is inbound, false otherwise */ public static function isInbound(string $direction): bool { return in_array($direction, self::getInboundCodes(), true); } /** * Validates that a direction code is recognized. * * @param string $direction The direction code to validate * * @return bool True if the direction is valid, false otherwise */ public static function isValid(string $direction): bool { return self::isOutbound($direction) || self::isInbound($direction); } }