@param string      $colorCode
@param string      $statusMinimal
@param string      $statusDetailed
@param null|string $streamMessage

@return string

@throws \Exception
353201
private function getFileResultTemplate($colorCode, $statusMinimal, $statusDetailed, $streamMessage = null)
    {
        $output = ($this->outputLevel > 1)
            ? $statusDetailed
            : $statusMinimal;

        return sprintf('%s%s %s%s%s',
            ($this->outputLevel > 1)
                ? PHP_EOL
                : null
            ,
            ($this->outputLevel > 1)
                ? '=>'
                : null
            ,
            (false === $this->preventAnsiColors)
                ? Color::setColor($colorCode, $output)
                : $output
            ,
            ($this->outputLevel > 1)
                ? PHP_EOL
                : null
            ,
            $streamMessage
        );
    }
789551
private function getHttpStatusCode($statusCode)
    {
        if ($statusCode >= 100 && $statusCode < 600) {
            return $statusCode;
        } elseif (
                FrontControllerException::BAD_REQUEST === $statusCode
                || FrontControllerException::INTERNAL_ERROR === $statusCode
                || FrontControllerException::NOT_FOUND === $statusCode
        ) {
            return $statusCode - FrontControllerException::UNKNOWN_ERROR;
        }

        return 500;
    }
625578
protected function renderStatically(int $statusCode, ?string $referenceCode): string
    {
        $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
        $referenceCodeMessage = ($referenceCode !== null) ? '<p>When contacting the maintainer of this application please mention the following reference code:<br /><br />' . $referenceCode . '</p>' : '';

        return '<!DOCTYPE html>
			<html>
				<head>
					<meta charset="UTF-8">
					<title>' . $statusCode . ' ' . $statusMessage . '</title>
					<style type="text/css">
						body {
							font-family: Helvetica, Arial, sans-serif;
							margin: 50px;
						}

						h1 {
						    color: #00ADEE;
							font-weight: normal;
						}
					</style>
				</head>
				<body>
                    <h1>' . $statusCode . ' ' . $statusMessage . '</h1>
                    <p>An internal error occurred.</p>
                    ' . $referenceCodeMessage . '
				</body>
			</html>';
    }
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
        );
    }
1222680
public function outputException(Tracker $tracker, Exception $e, $statusCode)
    {
        Common::sendResponseCode($statusCode);
        $this->logExceptionToErrorLog($e);

        if ($tracker->isDebugModeEnabled()) {
            Common::sendHeader('Content-Type: text/html; charset=utf-8');
            $trailer = '<span style="color: #888888">Backtrace:<br /><pre>' . $e->getTraceAsString() . '</pre></span>';
            $headerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Morpheus/templates/simpleLayoutHeader.tpl');
            $footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Morpheus/templates/simpleLayoutFooter.tpl');
            $headerPage = str_replace('{$HTML_TITLE}', 'Matomo &rsaquo; Error', $headerPage);

            echo $headerPage . '<p>' . $this->getMessageFromException($e) . '</p>' . $trailer . $footerPage;
        } else {
            $this->outputApiResponse($tracker);
        }
    }
249637
private static function errorJson($statusCode, $message)
    {
        $output = ['error' => $statusCode];

        if (!empty($message)) {
            $output['message'] = $message;
        }

        return json_encode($output);
    }
1093412
protected function createApiClientException(
        $statusCode,
        $message,
        $requestContents,
        $responseContents
    ): ApiClientException {
        return ExceptionFactory::create($statusCode, $message, $requestContents, $responseContents);
    }
901235
public function setStatus($code, $reasonPhrase = null)
    {
        $this->statusCode   = $code;
        $this->reasonPhrase = $reasonPhrase;
    }
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);
    }
766148
public function renderFailure($message = '', $code = 10000, $statusCode = 400, $errors = [], $description = '') {
        $data = is_array($message) ? $message : [
            'code' => $code,
            'message' => $message
        ];
        if (!isset($data['code'])) {
            $data['code'] = $code;
        }
        if (!isset($data['message']) && !is_array($message)) {
            $data['message'] = $message;
        }
        if (!empty($errors)) {
            $data['errors'] = $errors;
        }
        if (!empty($description)) {
            $data['description'] = $description;
        }
        return $this->render($data, $statusCode);
    }
1289552
public function success(int $statusCode, string $message, $data = null): JsonResponse
    {

        $this->setStatusCode($statusCode);

        $this->setMessage($message);

        $this->setData($data);


        $content['message'] = $this->getMessage();


        if (null !== $this->getCode()) {
            $content['code'] = $this->getCode();
        }


        $content['status_code'] = $this->getStatusCode();


        if (null !== $this->getData() && $this->getErrors() !== $this->getData()) {
            $content['data'] = $this->getData();
        }

        if (null !== $this->getErrors()) {
            $content['errors'] = $this->getErrors();
        }

        $content += $this->Hypermedia;

        return new JsonResponse($content, $this->getHttpStatusCode() ?: $this->getStatusCode());
    }
72853
private function getProgressTemplate($colorCode, $charMinimal, $charDetailed)
    {
        $output = ($this->outputLevel > 1)
            ? $charDetailed // detailed output required?
            : $charMinimal  // otherwise "normal" progress output will be provided
        ;

        return (false === $this->preventAnsiColors)
            ? $output = Color::setColor($colorCode, $output)
            : $output;
    }
630528
protected function _setStatus($code, $reasonPhrase = '')
    {
        if (!isset($this->_statusCodes[$code])) {
            throw new InvalidArgumentException(sprintf(
                'Invalid status code: %s. Use a valid HTTP status code in range 1xx - 5xx.',
                $code
            ));
        }

        $this->_status = $code;
        if (empty($reasonPhrase)) {
            $reasonPhrase = $this->_statusCodes[$code];
        }
        $this->_reasonPhrase = $reasonPhrase;
        $this->_setContentType();
    }
1349479
public static function statusClassFor(int $statusCode): string
    {
        $class = substr((string) $statusCode, 0, 1);
        return self::$statusClass[$class] ?? self::STATUS_CLASS_UNKNOWN;
    }
1011071
public function setHttpStatusCode($httpStatusCode) {
		if (Validator::checkHttpStatusCode($httpStatusCode) === false) {
			throw new InputException('can not use an invalid http status code');
		}
		
		$this->httpStatusCode = $httpStatusCode;
	}
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;
    }
702222
protected function getMetaResponse($meta, $statusCode = Response::HTTP_OK)
    {
        $this->checkParameters();

        /** @var ResponsesInterface $responses */
        $responses       = $this->getIntegration()->getFromContainer(ResponsesInterface::class);
        $encoder         = $this->codecMatcher->getEncoder();
        $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();
        $content         = $encoder->encodeMeta($meta);

        return $responses->getResponse($statusCode, $outputMediaType, $content, $this->supportedExtensions);
    }