false, 'error' => $message], $status); } function json_body(): array { $body = json_decode(file_get_contents('php://input'), true); return is_array($body) ? $body : []; } function require_method(string $method): void { if ($_SERVER['REQUEST_METHOD'] !== $method) { json_error('Method not allowed', 405); } }