body = $body; $this->statusCode = $statusCode; $this->headers = $headers; } public function getStatusCode(): int { return $this->statusCode; } public function withStatus(int $code): self { $clone = clone $this; $clone->statusCode = $code; return $clone; } public function getHeaders(): array { return $this->headers; } public function withHeader(string $name, string $value): self { $clone = clone $this; $clone->headers[$name] = $value; return $clone; } public function getBody(): string { return $this->body; } public function withBody(string $body): self { $clone = clone $this; $clone->body = $body; return $clone; } public function send(): void { http_response_code($this->statusCode); foreach ($this->headers as $name => $value) { header("$name: $value"); } echo $this->body; } }