Sets the response status code.
@api
integer $code HTTP status code:
mixed $text HTTP status text:
If the status text is null it will be automatically populated for the known status codes and left empty otherwise.
\InvalidArgumentException When the HTTP status code is not valid
public function setStatusCode($code, $text = null) {
$this->statusCode = $code = (int) $code;
if ($this
->isInvalid()) {
throw new \InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code));
}
if (null === $text) {
$this->statusText = isset(self::$statusTexts[$code]) ? self::$statusTexts[$code] : '';
return $this;
}
if (false === $text) {
$this->statusText = '';
return $this;
}
$this->statusText = $text;
return $this;
}