Determines the response class of a response code.

See the `CLASS_` constants for possible return values

@param int $statusCode

@throws InvalidArgumentException If the requested $statusCode is not valid

@return int
16478
public function getResponseClass($statusCode)
    {
        $responseClass = [
            1 => self::CLASS_INFORMATIONAL,
            2 => self::CLASS_SUCCESS,
            3 => self::CLASS_REDIRECTION,
            4 => self::CLASS_CLIENT_ERROR,
            5 => self::CLASS_SERVER_ERROR,
        ];

        $statusCode = $this->filterStatusCode($statusCode);

        return $responseClass[(int) substr($statusCode, 0, 1)];
    }
110286
public function withStatus($code, $reasonPhrase = '')
    {
        if (! isset($this->statusTexts[$code])) {
            throw new \InvalidArgumentException("Invalid status code. [{$code}]");
        }

        $this->statusCode   = $code;
        $this->reasonPhrase = $reasonPhrase ?: $this->statusTexts[$code];

        return $this;
    }
303106
public final function withStatus(
       $code,
       $reasonPhrase = ""): ResponseInterface
   {
       try {
           $response = $this->with("statusCode", $code);
           $response->setStatus((int) $code, $reasonPhrase);
       } catch (InvalidArgumentException $e) {
           throw new InvalidArgumentException(
               "Can't get instance for status: " . $e->getMessage());
       }
       return $response;
   }
490068
public static function getName($code)
    {
        if (!isset(self::$codesDescriptions[$code])) {
            throw new InvalidArgumentException("Invalid code $code specified");
        }

        return self::$codesDescriptions[$code];
    }
1096033
private function getDebugTraceResponse(\Exception $exception, $statusCode)
    {
        $request = $this->application->getRequest();
        $response = (new \Symfony\Component\Debug\ExceptionHandler())->createResponse($exception);
        $response->setStatusCode($statusCode);

        if (in_array('application/json', $request->getAcceptableContentTypes())) {
            $response = new JsonResponse($response->getContent(), $response->getStatusCode(), $response->headers->all());
        }

        return $response;
    }
479111
public function setStatus(int $statusCode):ResponseBuilder
    {
        if ($statusCode < 400 || $statusCode >= 600) {
            throw new InvalidArgumentException("{$statusCode} is not a valid error HTTP status code.");
        }
        return parent::setStatus($statusCode);
    }
292131
protected function validateResponse($statusCode) {
        switch($statusCode) {
            case 204:
                throw new Exceptions\RateLimitException('Too many requests');
            case 403:
                throw new Exceptions\InvalidApiKeyException(sprintf('Key %s is invalid', $this->_apiKey));
            default:
                return;
        }
    }
195544
public static function reasonPhraseFor(int $statusCode): string
    {
        if (isset(self::$reasonPhrases[$statusCode])) {
            return self::$reasonPhrases[$statusCode];
        }

        throw new \InvalidArgumentException(
                'Invalid or unknown HTTP status code ' . $statusCode
        );
    }
340755
public function thenRespond($statusCode, $body)
    {
        $response = HttpResponseBuilder::create($statusCode)
            ->andBody(new Body($body))
            ->build();

        return $this->createMockConfig($response);
    }
660497
protected function filterStatusCode($code)
    {
        $code = filter_var($code, FILTER_VALIDATE_INT, ['options' => [
            'min_range' => self::MINIMUM,
            'max_range' => self::MAXIMUM,
        ]]);
        if (!$code) {
            throw new InvalidArgumentException(
                'The submitted code must be a positive integer between '.self::MINIMUM.' and '.self::MAXIMUM
            );
        }

        return $code;
    }
1353612
protected function validateStatusCode(int $code): int
    {
        if (!is_numeric($code) || is_float($code) || 100 > $code || 599 < $code) {
            throw new InvalidStatusException(
                'Invalid status code. Must be an integer between 100 and 599, inclusive.'
            );
        }

        return $code;
    }
541325
protected function guessFile($statusCode)
    {
        $fileName = sprintf('%s/%s.html', $this->templatePath, (int) $statusCode);

        if (is_readable($fileName)) {
            return $fileName;
        } else {
            return $this->defaultErrorFileName;
        }
    }
133422
protected static function filterStatus($code)
    {
        if (! is_integer($code) || $code < StatusCode::STATUS_CODE_MIN || $code > StatusCode::STATUS_CODE_MAX) {
            throw new InvalidArgumentException(sprintf(
                'Invalid status code provided; must be an integer between %d and %d, inclusive; received %s',
                StatusCode::STATUS_CODE_MIN,
                StatusCode::STATUS_CODE_MAX,
                (is_object($code) ? get_class($code) : gettype($code))
            ));
        }

        return $code;
    }
1162996
protected function filtreCode($code)
    {
        if (is_numeric($code)) {
            $code = (int) $code;
        }
        if (!isset($this->reasonPhraseDefault[ $code ])) {
            throw new \InvalidArgumentException('Status code is invalid.');
        }

        return $code;
    }
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;
    }
175969
public function setStatusCode($code)
	{
		if (!array_key_exists($code, self::$statusCodeMap)) {
			throw new InvalidArgumentException(sprintf('The HTTP stauts code %s is unknown.', $code));
		}

		$this->statusCode = $code;

		return $this;
	}
136176
private function mockHttpResponse($statusCode, $streamMock)
    {
        $mockedHttpResponse = $this->mocker->mockCollaborator(ResponseInterface::class);
        $mockedHttpResponse->shouldReceive('getStatusCode')->once()->andReturn($statusCode);
        $mockedHttpResponse->shouldReceive('getBody')->once()->andReturn($streamMock);

        return $mockedHttpResponse;
    }