Shortcut.

@param int    $statusCode
@param string $body

return \Mcustiel\Phiremock\Domain\Expectation
340755
public function thenRespond($statusCode, $body)
    {
        $response = HttpResponseBuilder::create($statusCode)
            ->andBody(new Body($body))
            ->build();

        return $this->createMockConfig($response);
    }
968572
public function hasStatusCode($statusCode)
    {
        try {
            $statusCode = $this->filterStatusCode($statusCode);
        } catch (InvalidArgumentException $e) {
            return false;
        }

        return isset($this->httpStatus[$statusCode]);
    }
1118558
protected function redirect(string $uri, int $statusCode = 302) : Response
    {
        return (new Response())
            ->setStatusCode($statusCode)
            ->setHeader('Location', $uri);
    }
808916
protected function makeHtmlResponse($statusCode)
    {
        $view = $this->getView();

        if ($statusCode !== SymfonyResponse::HTTP_OK) {
            $view->withErrors($this->getErrorBagForStatusCode($statusCode));
        }

        return new IlluminateHtmlResponse($view, $statusCode);
    }
242128
public function setStatus($statusCode)
    {
        $statusCode = @intval($statusCode);

        if ($statusCode < 100 || $statusCode > 599) {
            throw new HTTPException(
                'Invalid response status code'
            );
        } else {
            $this->status = $statusCode;
        }

        return $this;
    }
206554
public static function create(
        int $statusCode,
        string $message,
        string $request,
        string $response
    ): ApiClientException {
        switch ($statusCode) {
            case 400:
                $exception = new BadRequestException($message, $request, $response);
                break;
            case 401:
                $exception = new UnauthorizedException($message, $request, $response);
                break;
            case 403:
                $exception = new ForbiddenException($message, $request, $response);
                break;
            case 404:
                $exception = new NotFoundException($message, $request, $response);
                break;
            default:
                $exception = new ApiClientException($message, $statusCode, $request, $response);
                break;
        }
        return $exception;
    }
479457
protected function respond($response, $status, $body)
    {
        $response->status($status);

        $response->end($body);
    }
901235
public function setStatus($code, $reasonPhrase = null)
    {
        $this->statusCode   = $code;
        $this->reasonPhrase = $reasonPhrase;
    }
1176861
public function response($statusCode = null)
        {
            $response = $this->factory(__NAMESPACE__ . '\Response');

            if (is_numeric($statusCode)) {
                $response->status($statusCode);
            }

            return $response;
        }
949529
protected function setProtocol($statuscode)
    {
    	if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' || $statuscode == Response::SC_CONTINUE || $statuscode == Response::SC_SWITCHING_PROTOCOLS || $statuscode == Response::SC_TEMPORARY_REDIRECT) {
        	header('HTTP/1.1 ' . $statuscode);
        } elseif (empty($_SERVER['SERVER_PROTOCOL'])) {
    		header('HTTP/1.0 ' . $statuscode);
    	} else {
    		header($_SERVER['SERVER_PROTOCOL'] . ' ' . $statuscode);
    	}
    }
916547
protected function statusCodes($statusCode, $customDescription = null)
    {
        if ($customDescription) {
            $description = $customDescription;
        }
        if ($customDescription !== null || array_key_exists($statusCode, $this->defaultStatusCodes)) {
            if (!isset($description)) {
                $description = $this->defaultStatusCodes[$statusCode];
            }
            $description = !is_array($description) ? [$description] : $description;
            $this->addStatusCode($statusCode, $description);
        }

        return $this;
    }
1079338
public function getErrorResponse($errors, int $statusCode = self::HTTP_BAD_REQUEST, array $headers = [])
    {
        if (\is_iterable($errors) === true) {
            /** @var iterable $errors */
            $content = $this->getEncoder()->encodeErrors($errors);
        } else {
            \assert($errors instanceof ErrorInterface);
            $content = $this->getEncoder()->encodeError($errors);
        }

        return $this->createJsonApiResponse($content, $statusCode, $headers, true);
    }
1102046
protected function redirect($url, $statusCode = 302)
    {
        $response = new RedirectResponse($url, $statusCode);
        $this->getServiceLocator()->set('Response', $response);

        return $response;
    }
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;
        }
    }
901268
public function withStatus($code, $reasonPhrase = null)
    {
        if ($this->complete) {
            return $this;
        }

        $new = $this->psrResponse->withStatus($code, $reasonPhrase);
        return new self($new);
    }
1128672
protected function verifyErrorFormat($body, $httpStatusCode)
    {
        if (is_array($body) === false)
        {
            $this->throwServerError($body, $httpStatusCode);
        }

        if ((isset($body['error']) === false) or
            (isset($body['error']['code']) === false))
        {
            $this->throwServerError($body, $httpStatusCode);
        }

        $code = $body['error']['code'];

        if (Errors\ErrorCode::exists($code) === false)
        {
            $this->throwServerError($body, $httpStatusCode);
        }
    }
1023060
protected function _format($statusCode=null, $message=null, $body=false)
    {
        $format = [];
        // Status Code field is necessary
        $format['code'] = ($statusCode) 
            ?: $this->response->getStatusCode();
        // Message field
        if ($message) {
            $format['message'] = $message;
        }
        // Body field
        if ($body !== false) {
            $format['data'] = $body;
        }
        
        return $format;
    }