Set status.
@param  int    $code
@param  string $text
@return self
508238
public function setStatus(int $code, string $text = null): self
    {
        if ($text == null) {
            $text = Status::getTextByCode($code);
        }

        $this->status->setCode($code);
        $this->status->setText($text);

        return $this;
    }
913314
public function setStatus(int $code, string $status)
    {
        return $this
            ->set('code', $code)
            ->setHeader('Status', $status);
    }
730218
public function withStatus($code = 200)
    {
        if (!array_key_exists($code, self::$responseCodes)) {
            throw new \Exception('That header code '.$code.' is not allowed.');
        }

        $this->code = $code;
        $this->reasonPhrase = self::$responseCodes[$code];

        return $this;
    }
11439
public function setCode( $code = null)
	{
		// Require that the response be unlocked before changing it
		$this->requireUnlocked();
		$this->status = new Status($code);
		return $this;
	}
345358
public function setCode($code, $message)
    {
        $this->message = $message;
        $this->code    = (int)$code;

        return $this;
    }
751358
public function setStatusCode($code, $text = null)
    {
        $this->statusCode = (int)$code;

        if ($text) {
            $this->statusText = $text;
        } elseif (isset($this->statusTexts[$code])) {
            $this->statusText = $this->statusTexts[$code];
        }

        return $this;
    }
1332126
public function setText($text)
    {
        if (!is_string($text)) {
            throw new InvalidArgumentException('string', 0);
        }

        $text = trim($text);

        if (strpos($text, '#') !== 0) {
            $text = '# ' . $text;
        }

        $this->text = $text;

        return $this;
    }
413192
public function setStatus(int $code) : self
    {
        if ($this->headerSent($file, $line)) {
            throw new \LogicException(sprintf("Headers is already sent in '%s:%s'", $file, $line));
        }

        $this->statusCode = $code;

        return $this;
    }
1360765
public function setStatusCode($statusCode)
    {
        $statusCode = intval($statusCode);
        $this->statusCode = ($statusCode > 0) ? $statusCode : self::RESPONSE_OK;
        return $this;
    }
1039560
public function redirect(string $location, int $code = Status::FOUND): self
    {
        $this->setStatus($code)->setHeader('Location', trim($location));

        return $this;
    }
1179160
function setCode( $code ) {
        $this->code = $code;
        $this->addHeader($this->getDefaultHeaderFromCode( $code ));
        return $this;
    }
1101566
private function fixateCode(int $code): self
    {
        $this->setCode($code);
        $this->fixed = true;
        return $this;
    }
518029
public function setStatus(int $statusCode): Response
	{
		if(isset($this->statusCodes[$statusCode]))
		{
			$this->statusCode = $statusCode;
		}

		return $this;
	}
1079970
protected function setTextFromCode(int $code, string $customText='')
  {
    if (strlen($customText)>0) {
      $this->statusText = $customText;
      return $customText;
    }

    switch ( $code ) {
      case 100: $this->statusText = 'Continue'; break;
      case 101: $this->statusText = 'Switching Protocols'; break;
      case 102: $this->statusText = 'Processing (WebDAV)'; break;

      case 200: $this->statusText = 'OK'; break;
      case 201: $this->statusText = 'Created'; break;
      case 202: $this->statusText = 'Accepted'; break;
      case 203: $this->statusText = 'Non-Authoritative Information'; break;
      case 204: $this->statusText = 'No Content'; break;
      case 205: $this->statusText = 'Reset Content'; break;
      case 206: $this->statusText = 'Partial Content'; break;
      case 207: $this->statusText = 'Multi-Status (WebDAV)'; break;
      case 208: $this->statusText = 'Already Reported (WebDAV)'; break;
      case 226: $this->statusText = 'IM Used'; break;

      case 300: $this->statusText = 'Multiple Choices'; break;
      case 301: $this->statusText = 'Moved Permanently'; break;
      case 302: $this->statusText = 'Found'; break;
      case 303: $this->statusText = 'See Other'; break;
      case 304: $this->statusText = 'Not Modified'; break;
      case 305: $this->statusText = 'Use Proxy'; break;
      case 307: $this->statusText = 'Temporary Redirect'; break;
      case 308: $this->statusText = 'Permanent Redirect (experiemental)'; break;

      case 400: $this->statusText = 'Bad Request'; break;
      case 401: $this->statusText = 'Unauthorized'; break;
      case 402: $this->statusText = 'Payment Required'; break;
      case 403: $this->statusText = 'Forbidden'; break;
      case 404: $this->statusText = 'Not Found'; break;
      case 405: $this->statusText = 'Method Not Allowed'; break;
      case 406: $this->statusText = 'Not Acceptable'; break;
      case 407: $this->statusText = 'Proxy Authentication Required'; break;
      case 408: $this->statusText = 'Request Timeout'; break;
      case 409: $this->statusText = 'Conflict'; break;
      case 410: $this->statusText = 'Gone'; break;
      case 411: $this->statusText = 'Length Required'; break;
      case 412: $this->statusText = 'Precondition Failed'; break;
      case 413: $this->statusText = 'Request Entity Too Large'; break;
      case 414: $this->statusText = 'Request-URI Too Long'; break;
      case 415: $this->statusText = 'Unsupported Media Type'; break;
      case 416: $this->statusText = 'Requested Range Not Satisfiable'; break;
      case 417: $this->statusText = 'Expectation Failed'; break;
      case 418: $this->statusText = 'I\'m a teapot (RFC 2324)'; break;
      case 420: $this->statusText = 'Enhance Your Calm (Twitter)'; break;
      case 422: $this->statusText = 'Unprocessable Entity (WebDAV))'; break;
      case 423: $this->statusText = 'Locked (WebDAV)'; break;
      case 424: $this->statusText = 'Failed Dependency (WebDAV)'; break;
      case 425: $this->statusText = 'Reserved for WebDAV'; break;
      case 426: $this->statusText = 'Upgrade Required'; break;
      case 428: $this->statusText = 'Precondition Required'; break;
      case 429: $this->statusText = 'Too Many Requests'; break;
      case 431: $this->statusText = 'Request Header Fields Too Large'; break;
      case 444: $this->statusText = 'No Response (Nginx)'; break;
      case 449: $this->statusText = 'Retry With (Microsoft)'; break;
      case 450: $this->statusText = 'Blocked by Windows Parental Controls (Microsoft)'; break;
      case 451: $this->statusText = 'Unavailable For Legal Reasons'; break;
      case 499: $this->statusText = 'Client Closed Request (Nginx)'; break;

      case 500: $this->statusText = 'Internal Server Error'; break;
      case 501: $this->statusText = 'Not Implemented'; break;
      case 502: $this->statusText = 'Bad Gateway'; break;
      case 503: $this->statusText = 'Service Unavailable'; break;
      case 504: $this->statusText = 'Gateway Timeout'; break;
      case 505: $this->statusText = 'HTTP Version Not Supported'; break;
      case 506: $this->statusText = 'Variant Also Negotiates (Experimental)'; break;
      case 507: $this->statusText = 'Insufficient Storage (WebDAV)'; break;
      case 508: $this->statusText = 'Loop Detected (WebDAV)'; break;
      case 509: $this->statusText = 'Bandwidth Limit Exceeded (Apache)'; break;
      case 510: $this->statusText = 'Not Extended'; break;
      case 511: $this->statusText = 'Network Authentication Required'; break;
      case 598: $this->statusText = 'Network read timeout error'; break;
      case 599: $this->statusText = 'Network connect timeout error'; break;

      default: $this->statusText = '(Unused)'; break;
    }

    # Return the text
    return $this->statusText;
  }
848015
public function setResponseCode($code)
    {
        if (!ResponseCode::isValid($code)) {
            throw new \InvalidArgumentException('setResponseCode(): Invalid HTTP response code given of value ' . strval($code));
        }

        $this->statusCode = $code;
        return $this;
    }
62748
public function setStatusHeader($code = 200)
    {
        if (!$this->controller->canEnd()) {
            return;
        }
        $this->response->status($code);
        return $this;
    }
1203361
public function statusCode($code = null, $reasonPhrase = null)
    {
        if (func_num_args() < 1 || empty($code)) {
            return $this->response->getStatusCode();
        }
        $this->response = $this->response->withStatus($code, $reasonPhrase);
        return $this;
    }