Elastica\Node\Info::get PHP Method

get() public method

Several params possible. Example 1: get('os', 'mem', 'total') returns total memory of the system the node is running on Example 2: get('os', 'mem') returns an array with all mem infos
public get ( ) : mixed
return mixed Data array entry or null if not found
    public function get()
    {
        $data = $this->getData();
        foreach (func_get_args() as $arg) {
            if (isset($data[$arg])) {
                $data = $data[$arg];
            } else {
                return;
            }
        }
        return $data;
    }

Usage Example

Example #1
0
 public function testGet()
 {
     $client = $this->_getClient();
     $names = $client->getCluster()->getNodeNames();
     $name = reset($names);
     $node = new Node($name, $client);
     $info = new NodeInfo($node);
     $this->assertNull($info->get('os', 'mem', 'total'));
     // Load os infos
     $info = new NodeInfo($node, array('os'));
     $this->assertInternalType('string', $info->get('os', 'mem', 'total'));
     $this->assertInternalType('array', $info->get('os', 'mem'));
     $this->assertNull($info->get('test', 'notest', 'notexist'));
 }