success = $success; $this->data = $data; $this->error = $error; $this->rawResponse = $rawResponse; } /** * 构造成功结果 * @param mixed $data 业务数据 * @param mixed $rawResponse 原始返回 * @return Result */ public static function success($data = null, $rawResponse = null) { return new self(true, $data, '', $rawResponse); } /** * 构造失败结果 * @param string $error 错误信息 * @param mixed $rawResponse 原始返回 * @return Result */ public static function fail($error, $rawResponse = null) { return new self(false, null, $error, $rawResponse); } /** * 是否成功 * @return bool */ public function isSuccess() { return $this->success === true; } }