JsonRpc
in package
Table of Contents
Methods
- createResponseError() : array{jsonrpc: string, error: array, id: ?mixed}
- Create a response object (unsuccessful).
- createResponseSuccess() : array{jsonrpc: string, result: mixed, id: ?mixed}
- Create a response object (successful).
- run() : string
- Execute a JSON-RPC request and return a result.
- handleMethodCall() : array<string|int, mixed>
Methods
createResponseError()
Create a response object (unsuccessful).
public
static createResponseError(array{jsonrpc: string, method: string, params: array, id: ?mixed} $request, Throwable $t) : array{jsonrpc: string, error: array, id: ?mixed}
Parameters
- $request : array{jsonrpc: string, method: string, params: array, id: ?mixed}
- $t : Throwable
-
The exception which caused the request to fail.
Tags
Return values
array{jsonrpc: string, error: array, id: ?mixed}createResponseSuccess()
Create a response object (successful).
public
static createResponseSuccess(array{jsonrpc: string, method: string, params: array, id: ?mixed} $request, mixed $result) : array{jsonrpc: string, result: mixed, id: ?mixed}
Parameters
- $request : array{jsonrpc: string, method: string, params: array, id: ?mixed}
- $result : mixed
-
The result-value of the method call.
Tags
Return values
array{jsonrpc: string, result: mixed, id: ?mixed}run()
Execute a JSON-RPC request and return a result.
public
static run(string $requestLine, callable $dispatcher) : string
This adapter handles decoding, encoding, and conversion of exceptions.
Parameters
- $requestLine : string
-
JSON formatted RPC request
- $dispatcher : callable
-
Dispatch function - given a parsed/well-formed request, compute the result. Signature: function(string $method, mixed $params): mixed
Tags
Return values
string —JSON formatted RPC response
handleMethodCall()
protected
static handleMethodCall(mixed $request, mixed $dispatcher) : array<string|int, mixed>
Parameters
- $request : mixed
- $dispatcher : mixed