Country::current(), 'flag' => Country::flag(Country::current()), 'label' => Country::label(Country::current()), ], JSON_UNESCAPED_UNICODE); exit; } if ($method === 'POST') { $body = json_decode(file_get_contents('php://input') ?: '{}', true) ?: []; $code = strtoupper((string)($body['country'] ?? $_POST['country'] ?? '')); if (!Country::isValid($code)) { http_response_code(400); echo json_encode(['error' => 'Invalid country code. Expected AT, DE, CH or LI.']); exit; } Country::setCurrent($code); echo json_encode([ 'country' => Country::current(), 'flag' => Country::flag(Country::current()), 'label' => Country::label(Country::current()), 'ok' => true, ], JSON_UNESCAPED_UNICODE); exit; } http_response_code(405); echo json_encode(['error' => 'Method not allowed']);