status = $status; return $this; } public function addHeader(string $key, string $val): self { $this->headers[$key] = $val; return $this; } public function getBody(): self { return $this; } public function write(string $content): self { $this->body .= $content; return $this; } public function send(): void { http_response_code($this->status); foreach($this->headers as $key => $val) header("{$key}: {$val}"); echo $this->body; } public function json(array $data, int $status = 200): self { $this->setStatus($status); header("Content-Type: application/json"); $this->body = json_encode($data); return $this; } public function redirect(string $url, int $status = 302): void { http_response_code($status); header("Location: {$url}"); exit; } }