设置响应状态

@param int $code 状态码
@param string $message 状态描述

@return $this
329629
public function setStatusCode(int $code, string $message = null)
    {
        $this->code = $code;
        $this->message = $message;

        return $this;
    }
270354
public function with(string $name, $value, ?int $code = null)
  {
    $this->with = array_merge([$name => $value], $this->with);

    if ($code != null) {
      $this->code = $code;
      return $this->send();
    }

    return $this;
  }
1299678
final public function add($code, $message) {

        if ( array_key_exists($code, $this->rpc_errors) ) {

            $this->logger->warning("Cannot add error $code: duplicate entry");

            return false;

        } else {

            $this->rpc_errors[$code] = $message;

            $this->logger->debug("Added error $code");

            return true;

        }

    }
596043
public function setCode(int $code, string $reasonPhrase = null): self
    {
        $this->code         = $code;
        $this->reasonPhrase = null === $reasonPhrase ? Http::reasonPhraseFor($code) : $reasonPhrase;
        return $this;
    }
713110
public function setMessage($message)
    {
        if (is_object($message)) {
            $message = (new ConvertObject($message))
                ->toArray();
        }
        $this->message = $message;
        return $this;
    }
941759
public static function create($code, $message = null, $category = null)
    {
        return new class($message, $code, $category) extends ControlledError
        {
            /**
             * @var string
             */
            protected $category;

            /**
             * @param string $message
             * @param string $code
             * @param null   $category
             */
            public function __construct($message, $code, $category = null)
            {
                if ($category) {
                    $this->category = $category;
                }
                parent:: __construct($message, $code);
            }

            /**
             * @return string
             */
            public function getCategory(): string
            {
                return $this->category ?? parent::getCategory();
            }
        };
    }
11439
public function setCode( $code = null)
	{
		// Require that the response be unlocked before changing it
		$this->requireUnlocked();
		$this->status = new Status($code);
		return $this;
	}
600841
public function setStatusCode($code, $message)
  {
    $this->meta->statusCode = $code;
    $this->meta->statusMessage = $message;
  }
667443
public function markCompleted($code = 0, $message = false)
    {
        $obj = parent::markCompleted($code, $message);
        $queue = $this->getQueueObject();
        if (!$this->didFail()) {
            $queue->deleteQueue();
        }

        return $obj;
    }
171304
public static function message($code)
    {
        if (array_key_exists($code, self::$messages)) {
            return self::$messages[$code];
        }

        return null;
    }
302410
protected function getDefaultMessage($code, $message): string
    {
        if ($code !== null && $message === null) {
            return ApiResponse::$statusTexts[$code]['message'];
        }

        return $message;
    }
730650
public function setUnhandledError($code, $message = '')
    {
        $this->unhandledError = ($code == 0) ? false : true;
        $this->errorCode      = $code;
        $this->errorText      = $message;

        return $this;
    }
446125
public function setSuccess($msg, $code = 0)
    {
        $this->data['success'] = true;
        $this->data['code']    = $code;
        $this->data['message'] = $msg;
        
        return $this;
    }
341784
public function signMessage(Swift_Message $message)
    {
        if (null === $this->signCertificate && null === $this->encryptCert) {
            return $this;
        }

        if ($this->signThenEncrypt) {
            $this->smimeSignMessage($message);
            $this->smimeEncryptMessage($message);
        } else {
            $this->smimeEncryptMessage($message);
            $this->smimeSignMessage($message);
        }
    }
1252400
public function setStatusCode($code, $text = null)
    {
        $code = intval($code);
        if ($code < 100 || $code > 999)
        {
            throw new InvalidArgumentException('Status code must be from 100 to 999');
        }
        $this->status = $code;
        $this->statusText = $text;
        return $this;
    }
1163523
public function setStatusCode($code)
    {
        $this->headerBag->setStatusCode($code);
        $this->statusCode = $code;

        return $this;
    }
120524
public function setStatusCode($statusCode, $message = null)
    {
        $this->statusCode = (int) $statusCode;

        // Add status message to meta array
        $this->addMeta(['status' => ['code' => (int) $statusCode]]);

        // Set optional status message if present
        if (!empty($message)) {
            $this->setStatusMessage($message);
        }

        return $this;
    }