/** * Retrieve a object of JSON-RPC request. * * @return object The request object. */ public static function getRequest() { if (static::$request == null) { $http = Http\Request::getInstance(); $body = $http->getBody(); static::$request = Request::fromJson($body); } return static::$request; }
/** * Returns the string representation of the exception. * * @return string the string representation of the exception. */ public function __toString() { if (PHP_SAPI === 'cli') { $context = Util\StringUtils::export($this->getContext()); $parts = [sprintf('[%d:%s] %s', $this->getCode(), $this->getName(), $this->getMessage()), ' #file ' . $this->getFile(), ' #line ' . $this->getLine(), ' #context ' . $context]; $parts[] = Util\DebugUtils::getBacktraceAsString($this); } else { $req = Http\Request::getInstance(); $data = ['context' => $this->getContext(), 'header' => $req->getHeader(), 'get' => $req->getFromGET(), 'post' => $req->getFromPOST(), 'cookie' => $req->getFromCookie()]; foreach ($data as $key => $val) { $data[$key] = Util\StringUtils::export($val); } $parts = [sprintf('[%d:%s] %s', $this->getCode(), $this->getName(), $this->getMessage()), ' #file ' . $this->getFile(), ' #line ' . $this->getLine(), ' #context ' . $data['context'], ' #domain ' . @$_SERVER['SERVER_NAME'], ' #path ' . $req->getPathInfo(), ' #auth ' . $req->getAuthType(), ' #method ' . $req->getMethod(), ' #get ' . $data['get'], ' #post ' . $data['post'], ' #cookie ' . $data['cookie']]; $parts[] = Util\DebugUtils::getBacktraceAsString($this); } return implode(PHP_EOL, $parts); }