* @copyright (c) 2025, Robert Strutts * @license MIT */ namespace CodeHydrater\http; class response { protected string $content; protected int $status_code; protected array $headers; public function __construct( string $content = '', int $status_code = 200, array $headers = [] ) { $this->content = $content; $this->status_code = $status_code; $this->headers = $headers; } public function send(): void { http_response_code($this->status_code); foreach ($this->headers as $name => $value) { header("$name: $value"); } echo $this->content; } public function set_content(string $content): self { $this->content = $content; return $this; } public function set_status_code(int $code): self { $this->status_code = $code; return $this; } public function add_header(string $name, string $value): self { $this->headers[$name] = $value; return $this; } }