You are here

protected function Response::assertValidResponse in JSON-RPC 2.x

Same name and namespace in other branches
  1. 8 src/Object/Response.php \Drupal\jsonrpc\Object\Response::assertValidResponse()

Asserts that the response is valid.

1 call to Response::assertValidResponse()
Response::__construct in src/Object/Response.php
Response constructor.

File

src/Object/Response.php, line 148

Class

Response
Response object to help implement JSON RPC's spec for response objects.

Namespace

Drupal\jsonrpc\Object

Code

protected function assertValidResponse($version, $id, $result, $error) {
  assert(!is_null($result) xor !is_null($error), 'Either the result member or error member MUST be included, but both members MUST NOT be included.');
  assert($version === "2.0", 'A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0".');
  assert(is_string($id) || is_numeric($id) || is_null($id), 'An identifier established by the Client that MUST contain a String, Number, or NULL value if included.');
}