You are here

public function Response::__construct in Lockr 7.3

Parameters

int $status Status code:

array $headers Response headers:

string|null|resource|StreamInterface $body Response body:

string $version Protocol version:

string|null $reason Reason phrase (when empty a default will be used based on the status code):

File

vendor/guzzlehttp/psr7/src/Response.php, line 89

Class

Response
PSR-7 response implementation.

Namespace

GuzzleHttp\Psr7

Code

public function __construct($status = 200, array $headers = [], $body = null, $version = '1.1', $reason = null) {
  if (filter_var($status, FILTER_VALIDATE_INT) === false) {
    throw new \InvalidArgumentException('Status code must be an integer value.');
  }
  $this->statusCode = (int) $status;
  if ($body !== '' && $body !== null) {
    $this->stream = stream_for($body);
  }
  $this
    ->setHeaders($headers);
  if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
    $this->reasonPhrase = self::$phrases[$this->statusCode];
  }
  else {
    $this->reasonPhrase = (string) $reason;
  }
  $this->protocol = $version;
}