Response::withStatus( $code,  $reasonPhrase = '' ): static

In this article

Return

static

Source

public function withStatus($code, $reasonPhrase = ''): ResponseInterface
{
    if (!\is_int($code) && !\is_string($code)) {
        throw new \InvalidArgumentException('Status code has to be an integer');
    }
    $code = (int) $code;
    if ($code < 100 || $code > 599) {
        throw new \InvalidArgumentException(\sprintf('Status code has to be an integer between 100 and 599. A status code of %d was given', $code));
    }
    $new = clone $this;
    $new->statusCode = $code;
    if ((null === $reasonPhrase || '' === $reasonPhrase) && isset(self::PHRASES[$new->statusCode])) {
        $reasonPhrase = self::PHRASES[$new->statusCode];
    }
    $new->reasonPhrase = $reasonPhrase;
    return $new;
}

User Contributed Notes

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