Response::__construct( int $statusCode,  $headers, string|null $body = null )

In this article

Constructor.

Parameters

$statusCodeintrequired
The HTTP status code.
string|list<string>> $headers The response headers.
$bodystring|nulloptional
The response body.

Default:null

Source

public function __construct(int $statusCode, array $headers, ?string $body = null)
{
    if ($statusCode < 100 || $statusCode >= 600) {
        throw new InvalidArgumentException('Invalid HTTP status code: ' . $statusCode);
    }
    $this->statusCode = $statusCode;
    $this->headers = new HeadersCollection($headers);
    $this->body = $body;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.