LinkORB\Component\Etcd\Client::getNode PHP Method

getNode() public method

Retrieve the value of a key
public getNode ( string $key, array $flags = null ) : array
$key string
$flags array the extra query params
return array
    public function getNode($key, array $flags = null)
    {
        $query = array();
        if ($flags) {
            $query = array('query' => $flags);
        }
        $request = $this->guzzleclient->get($this->buildKeyUri($key), null, $query);
        $response = $request->send();
        $body = $response->json();
        if (isset($body['errorCode'])) {
            throw new KeyNotFoundException($body['message'], $body['errorCode']);
        }
        return $body['node'];
    }

Usage Example

Ejemplo n.º 1
0
 public function testGetNode()
 {
     $key = 'node_key';
     $setdata = $this->client->set($key, 'node_value');
     $node = $this->client->getNode($key);
     $this->assertJsonStringEqualsJsonString(json_encode($node), json_encode($setdata['node']));
 }