diff --git a/formwork/src/Http/Response.php b/formwork/src/Http/Response.php index d7c00ed9..fd47dcb7 100644 --- a/formwork/src/Http/Response.php +++ b/formwork/src/Http/Response.php @@ -90,7 +90,7 @@ public function prepare(Request $request): static */ public function sendStatus(): void { - Header::status($this->responseStatus); + Header::sendStatus($this->responseStatus); } /** diff --git a/formwork/src/Http/Utils/Header.php b/formwork/src/Http/Utils/Header.php index 55fff1c0..78e1b532 100644 --- a/formwork/src/Http/Utils/Header.php +++ b/formwork/src/Http/Utils/Header.php @@ -14,24 +14,12 @@ class Header /** * Send an HTTP response status code - * - * @param bool $send Whether to send status code or return - * @param bool $exit Whether to exit from the script after sending the status code - * - * @return string|null */ - public static function status(ResponseStatus $responseStatus, bool $send = true, bool $exit = false) + public static function sendStatus(ResponseStatus $responseStatus): void { $protocol = $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1'; $responseStatus = implode(' ', [$protocol, $responseStatus->value]); - if (!$send) { - return $responseStatus; - } header($responseStatus); - if ($exit) { - exit; - } - return null; } /** @@ -60,7 +48,7 @@ public static function contentType(string $mimeType): void */ public static function notFound(): void { - static::status(ResponseStatus::NotFound); + static::sendStatus(ResponseStatus::NotFound); } /** @@ -73,7 +61,7 @@ public static function redirect(string $uri, ResponseStatus $responseStatus = Re if ($responseStatus->type() !== ResponseStatusType::Redirection) { throw new InvalidArgumentException(sprintf('Invalid response status "%s" for redirection, only 3XX statuses are allowed', $responseStatus->value)); } - static::status($responseStatus); + static::sendStatus($responseStatus); static::send('Location', $uri); exit; }