public function output(): void
    {
        header('HTTP/1.1 ' . $this->getStatusCode());

        // Output headers.
        foreach ($this->getHeaders() as $headerName => $headerValue) {
            header($headerName . ': ' . $headerValue);
        }

        // Set cookies.
        foreach ($this->getCookies() as $cookieName => $cookie) {
            /** @var ResponseCookieInterface $cookie */
            setcookie(
                $cookieName,
                $cookie->getValue(),
                $cookie->getExpiry() !== null ? $cookie->getExpiry()->getTimestamp() : 0,
                $cookie->getPath() !== null ? $cookie->getPath()->__toString() : '',
                $cookie->getDomain() !== null ? $cookie->getDomain()->__toString() : '',
                $cookie->isSecure(),
                $cookie->isHttpOnly()
            );
        }

        // Output content.
        echo $this->getContent();
    }