Ejemplo n.º 1
0
 /**
  * Factory for creating a request object specific to
  * a json rpc call (eg. no POST, GET or other data.
  *
  * @param $method
  * @param array $params
  * @return Request
  */
 public static function createRPC($method, $params = array())
 {
     $req = JSON::encode(array('jsonrpc' => '2.0', 'id' => null, 'method' => $method, 'params' => $params));
     return new self(array(), array(), array(), array(), array(), array(), $req);
 }
Ejemplo n.º 2
0
 /**
  * Returns a formatted response object for a jsonrpc response
  * @return string
  */
 public function toJSON()
 {
     return JSON::encode($this->toArray(), Server::$debug);
 }
Ejemplo n.º 3
0
 /**
  * @covers \PG\JsonRpc\BatchResult::toArray
  * @covers \PG\JsonRpc\AbstractResult::toJSON
  */
 public function testToJson()
 {
     $batch = new BatchResult($this->app, array(new Result('id', 'some_result')));
     $json = $batch->toJSON();
     $this->assertEquals(JSON::encode(array(array('jsonrpc' => '2.0', 'result' => 'some_result', 'id' => 'id'))), $json);
 }