src/Http/Message/Response.php
private function setStatusCode($code, $reasonPhrase = ''): void
    {
        if (
            !\is_numeric($code) || \is_float($code) ||
            $code < static::MIN_STATUS_CODE_VALUE ||
            $code > static::MAX_STATUS_CODE_VALUE
        ) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid status code "%s"; must be an integer between %d and %d, inclusive',
                \is_scalar($code) ? $code : \gettype($code),
                static::MIN_STATUS_CODE_VALUE,
                static::MAX_STATUS_CODE_VALUE
            ));
        }

        if (!\is_string($reasonPhrase)) {
            throw new \InvalidArgumentException(\sprintf(
                'Unsupported response reason phrase; must be a string, received %s',
                \is_object($reasonPhrase) ? \get_class($reasonPhrase) : \gettype($reasonPhrase)
            ));
        }

        if ($reasonPhrase === '' && isset($this->phrases[$code])) {
            $reasonPhrase = self::$phrases[$code];
        }

        $this->reasonPhrase = $reasonPhrase;
        $this->statusCode = (int) $code;
    }
private function setStatusCode($code, $reasonPhrase = ''): void
    {
        if (
            !\is_numeric($code) || \is_float($code) ||
            $code < static::MIN_STATUS_CODE_VALUE ||
            $code > static::MAX_STATUS_CODE_VALUE
        ) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid status code "%s"; must be an integer between %d and %d, inclusive',
                \is_scalar($code) ? $code : \gettype($code),
                static::MIN_STATUS_CODE_VALUE,
                static::MAX_STATUS_CODE_VALUE
            ));
        }

        if (!\is_string($reasonPhrase)) {
            throw new \InvalidArgumentException(\sprintf(
                'Unsupported response reason phrase; must be a string, received %s',
                \is_object($reasonPhrase) ? \get_class($reasonPhrase) : \gettype($reasonPhrase)
            ));
        }

        if ($reasonPhrase === '' && isset($this->phrases[$code])) {
            $reasonPhrase = self::$phrases[$code];
        }

        $this->reasonPhrase = $reasonPhrase;
        $this->statusCode = (int) $code;
    }
private function setStatusCode ( $ code , $ reasonPhrase = '' ) : void { if ( ! \ is_numeric ( $ code ) || \ is_float ( $ code ) || $ code < static :: MIN_STATUS_CODE_VALUE || $ code > static :: MAX_STATUS_CODE_VALUE ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid status code "%s"; must be an integer between %d and %d, inclusive' , \ is_scalar ( $ code ) ? $ code : \ gettype ( $ code ) , static :: MIN_STATUS_CODE_VALUE , static :: MAX_STATUS_CODE_VALUE ) ) ; } if ( ! \ is_string ( $ reasonPhrase ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Unsupported response reason phrase; must be a string, received %s' , \ is_object ( $ reasonPhrase ) ? \ get_class ( $ reasonPhrase ) : \ gettype ( $ reasonPhrase ) ) ) ; } if ( $ reasonPhrase === '' && isset ( $ this -> phrases [ $ code ] ) ) { $ reasonPhrase = self :: $ phrases [ $ code ] ; } $ this -> reasonPhrase = $ reasonPhrase ; $ this -> statusCode = ( int ) $ code ; }
Set a valid status code.

@param int    $code
@param string $reasonPhrase

@throws \InvalidArgumentException on an invalid status code.
Set a valid status code .