Get the status message string for a given HTTP response code.

@param int $code The HTTP response code.

@returns string The string representation of the status code.
18954
public static function getStatusMessage($code) {
    if (array_key_exists($code, self::$status_messages)) {
      return self::$status_messages[$code];
    }
    return sprintf("Unknown Code %d", $code);
  }
823824
public static function code($code = 200) : String
    {
        $messages = Datatype::multikey(self::$messages);

        if( isset($messages[$code]) )
        {
            return $messages[$code];
        }

        return false;
    }
170790
public function getMessageString($errorCode)
	{
		return isset($this->errorMessages[$errorCode]) ? $this->errorMessages[$errorCode] : null;
	}
89810
public static function status(
    /*int*/ $code,
    /*string*/ $message = null
  ) {
    // General header as response.
    $header =
      @intval($code) .
      (!$message ? '' : ' ' . $message);

    // Send status for both CGI and non-CGI web servers.
    header(self::getProtocol() . ' ' . $header);
    header('Status: ' . $header);
  }
268412
public function withStatusCode(int $code)
    {
        if ($this->statusCode == $code) {
            return $this;
        }

        $that = clone($this);
        $that->statusCode = $code;
        return $that;
    }
1271407
public static function __(string $code) : string
    {
        $t = self::getInstance();
        if (!isset($t->translations[$code])) {
            return $code;
        }
        return $t->translations[$code];
    }
1351575
public function getName(string $code): string
    {
        $result = $code;

        if (empty($code)) {
            throw new InvalidArgumentException("Code must be a non-empty string.");
        }

        $languages = $this->getSupported();
        if (!empty($languages[$code])) {
            $result = $languages[$code];
        }

        return $result;
    }
63902
protected function getStatusMessage($code)
    {
        return (
            isset($this->statusMessages[$code])
                ? $this->statusMessages[$code] : $this->statusMessages[500]
        );
    }
377674
public function getMessageByCode(& $code, array $data = null)
    {
        // If we do not use a reference, then that defeats the purpose of
        // making the $errorMap a static property.
        $map = &static::getErrorMap();

        // When you can't find the code, use a default one.
        if (!\array_key_exists($code, $map)) {
            $code = static::UNKNOWN;
        }

        if (\is_array($data) && count($data) > 0) {
            return \vsprintf($map[$code], $data);
        }

        return $map[$code];
    }
1335684
function status($code) {
		$reason=@constant('self::HTTP_'.$code);
		if (PHP_SAPI!='cli')
			header($_SERVER['SERVER_PROTOCOL'].' '.$code.' '.$reason);
		return $reason;
	}
1137572
protected function getResponseDescription($code)
  {
    $codes = array(

      // Informational 1xx
      100 => 'Continue',
      101 => 'Switching Protocols',
      // Success 2xx
      200 => 'OK',
      201 => 'Created',
      202 => 'Accepted',
      203 => 'Non-Authoritative Information',
      204 => 'No Content',
      205 => 'Reset Content',
      206 => 'Partial Content',
      // Redirection 3xx
      300 => 'Multiple Choices',
      301 => 'Moved Permanently',
      302 => 'Found', // 1.1
      303 => 'See Other',
      304 => 'Not Modified',
      305 => 'Use Proxy',
      // 306 is deprecated but reserved
      307 => 'Temporary Redirect',
      // Client Error 4xx
      400 => 'Bad Request',
      401 => 'Unauthorized',
      402 => 'Payment Required',
      403 => 'Forbidden',
      404 => 'Not Found',
      405 => 'Method Not Allowed',
      406 => 'Not Acceptable',
      407 => 'Proxy Authentication Required',
      408 => 'Request Timeout',
      409 => 'Conflict',
      410 => 'Gone',
      411 => 'Length Required',
      412 => 'Precondition Failed',
      413 => 'Request Entity Too Large',
      414 => 'Request-URI Too Long',
      415 => 'Unsupported Media Type',
      416 => 'Requested Range Not Satisfiable',
      417 => 'Expectation Failed',
      // Server Error 5xx
      500 => 'Internal Server Error',
      501 => 'Not Implemented',
      502 => 'Bad Gateway',
      503 => 'Service Unavailable',
      504 => 'Gateway Timeout',
      505 => 'HTTP Version Not Supported',
      509 => 'Bandwidth Limit Exceeded'
    );

    $result = (isset($codes[$code])) ? $codes[$code] : 'Unknown Status Code';

    return $result;
  }
418967
public function getStatus($code) {

        $filename = __DIR__.'/../../data/'.substr($code, 0,1).'.json';
        if(file_exists($filename)) {
            return json_decode(file_get_contents($filename), true)[$code];
        }
        return [];
    }
891801
public static function messageFromHttpStatusCode($httpStatusCode)
    {
        $message = sprintf('HTTP %s', $httpStatusCode);
        switch ($httpStatusCode) {
            case 400:
                $message .= ' Bad Request (invalid parameters for the API endpoint)';
                break;
            case 401:
                $message .= ' Unauthorized (check that your API key is correct)';
                break;
            case 403:
                $message .= ' Forbidden (you do not have access to this API endpoint)';
                break;
            case 404:
                $message .= ' API Endpoint not found or parameters were incorrect. Check method and URL';
                break;
            case 429:
                $message .= ' Rate limit hit, decrease request speed';
                break;
            case 500:
                $message .= ' Server error (Mobius error)';
                break;
            case 503:
                $message .= ' Server temporarily offline for maintenance';
                break;
        }

        return $message;
    }
82044
public static function rpcCodeFromHttpStatusCode($httpStatusCode)
    {
        if (array_key_exists($httpStatusCode, self::$httpStatusCodeToRpcCodeMap)) {
            return self::$httpStatusCodeToRpcCodeMap[$httpStatusCode];
        }
        return ApiStatus::UNRECOGNIZED_CODE;
    }
841141
public static function vendorToHttp($code = Code::OK): int
    {
        if (Code::OK === $code) {
            return HttpCode::HTTP_OK;
        }

        switch ($code) {
            case Code::CANCELLED:
                return HttpCode::HTTP_CLIENT_CLOSED_REQUEST;

            case Code::UNKNOWN:
                return HttpCode::HTTP_INTERNAL_SERVER_ERROR;

            case Code::INVALID_ARGUMENT:
                return HttpCode::HTTP_BAD_REQUEST;

            case Code::DEADLINE_EXCEEDED:
                return HttpCode::HTTP_GATEWAY_TIMEOUT;

            case Code::NOT_FOUND:
                return HttpCode::HTTP_NOT_FOUND;

            case Code::ALREADY_EXISTS:
                return HttpCode::HTTP_CONFLICT;

            case Code::PERMISSION_DENIED:
                return HttpCode::HTTP_FORBIDDEN;

            case Code::UNAUTHENTICATED:
                return HttpCode::HTTP_UNAUTHORIZED;

            case Code::RESOURCE_EXHAUSTED:
                return HttpCode::HTTP_TOO_MANY_REQUESTS;

            // questionable... may not always be etag related.
            case Code::FAILED_PRECONDITION:
                return HttpCode::HTTP_PRECONDITION_FAILED;

            case Code::ABORTED:
                return HttpCode::HTTP_CONFLICT;

            case Code::OUT_OF_RANGE:
                return HttpCode::HTTP_BAD_REQUEST;

            case Code::UNIMPLEMENTED:
                return HttpCode::HTTP_NOT_IMPLEMENTED;

            case Code::INTERNAL:
                return HttpCode::HTTP_INTERNAL_SERVER_ERROR;

            case Code::UNAVAILABLE:
                return HttpCode::HTTP_SERVICE_UNAVAILABLE;

            case Code::DATA_LOSS:
                return HttpCode::HTTP_INTERNAL_SERVER_ERROR;

            default:
                return HttpCode::HTTP_UNPROCESSABLE_ENTITY;
        }
    }
985060
public function setStatus(int $code): Response
    {
        # `Status::getText` will throw an exception for invalid status codes
        $this->statusText = Status::getText($code);
        $this->statusCode = $code;
        return $this;
    }
506277
public function getResponse(int $code): Response
    {
        if (!isset($this->responses[$code])) {
            if (isset($this->responses[0])) {
                // Return default response
                return $this->responses[0];
            }
            throw new \InvalidArgumentException(
                "Operation '{$this->getId()}' does not have a definition for status '$code'" .
                " (has " . implode(', ', array_keys($this->responses)) . ')'
            );
        }

        return $this->responses[$code];
    }