public function setStatus($code, $reasonPhrase = null) {
        if (preg_match('`(?:HTTP/([\d.]+)\s+)?(\d{3})\s*(.*)`i', $code, $matches)) {
            $this->protocolVersion = $matches[1] ?: $this->protocolVersion;
            $code = (int)$matches[2];
            $reasonPhrase = $reasonPhrase ?: $matches[3];
        }

        if (empty($reasonPhrase) && isset(static::$reasonPhrases[$code])) {
            $reasonPhrase = static::$reasonPhrases[$code];
        }
        if (is_numeric($code)) {
            $this->setStatusCode((int)$code);
        }
        $this->setReasonPhrase((string)$reasonPhrase);
        return $this;
    }
public function setStatus($code, $reasonPhrase = null) {
        if (preg_match('`(?:HTTP/([\d.]+)\s+)?(\d{3})\s*(.*)`i', $code, $matches)) {
            $this->protocolVersion = $matches[1] ?: $this->protocolVersion;
            $code = (int)$matches[2];
            $reasonPhrase = $reasonPhrase ?: $matches[3];
        }

        if (empty($reasonPhrase) && isset(static::$reasonPhrases[$code])) {
            $reasonPhrase = static::$reasonPhrases[$code];
        }
        if (is_numeric($code)) {
            $this->setStatusCode((int)$code);
        }
        $this->setReasonPhrase((string)$reasonPhrase);
        return $this;
    }
public function setStatus ( $ code , $ reasonPhrase = null ) { if ( preg_match ( '`(?:HTTP/([\d.]+)\s+)?(\d{3})\s*(.*)`i' , $ code , $ matches ) ) { $ this -> protocolVersion = $ matches [ 1 ] ? : $ this -> protocolVersion ; $ code = ( int ) $ matches [ 2 ] ; $ reasonPhrase = $ reasonPhrase ? : $ matches [ 3 ] ; } if ( empty ( $ reasonPhrase ) && isset ( static :: $ reasonPhrases [ $ code ] ) ) { $ reasonPhrase = static :: $ reasonPhrases [ $ code ] ; } if ( is_numeric ( $ code ) ) { $ this -> setStatusCode ( ( int ) $ code ) ; } $ this -> setReasonPhrase ( ( string ) $ reasonPhrase ) ; return $ this ; }
Set the status of the response.

@param int|string $code Either the 3-digit integer result code or an entire HTTP status line.
@param string|null $reasonPhrase The reason phrase to go with the status code.
If no reason is given then one will be determined from the status code.
@return $this
Set the status of the response .