class JsonRpcResponse implements Arrayable

Methods

__construct(array $content = [])

Create a JSON-RPC response.

static JsonRpcResponse
result(int|string $id, array $result)

Create a result response.

static JsonRpcResponse
notification(string $method, array $params)

Create a notification response.

static JsonRpcResponse
error(string|int|null $id, int $code, string $message, mixed $data = null)

Create an error response.

array
toArray()

Convert the response to an array.

string
toJson(int $options = 0)

Encode the response as JSON, replacing invalid text bytes.

Details

at line 19
__construct(array $content = [])

Create a JSON-RPC response.

Parameters

array $content

at line 28
static JsonRpcResponse result(int|string $id, array $result)

Create a result response.

Parameters

int|string $id
array $result

Return Value

JsonRpcResponse

at line 41
static JsonRpcResponse notification(string $method, array $params)

Create a notification response.

Parameters

string $method
array $params

Return Value

JsonRpcResponse

at line 52
static JsonRpcResponse error(string|int|null $id, int $code, string $message, mixed $data = null)

Create an error response.

Parameters

string|int|null $id
int $code
string $message
mixed $data

Return Value

JsonRpcResponse

at line 74
array toArray()

Convert the response to an array.

Return Value

array

at line 85
string toJson(int $options = 0)

Encode the response as JSON, replacing invalid text bytes.

Parameters

int $options

Return Value

string