Altax\Module\Server\Resource\Node::setOptions PHP Method

setOptions() public method

public setOptions ( $options )
    public function setOptions($options)
    {
        if (!is_array($options)) {
            throw new \RuntimeException("You must pass option as Array");
        }
        if (isset($options["host"])) {
            $this->host = $options["host"];
        }
        if (isset($options["port"])) {
            $this->port = $options["port"];
        }
        if (isset($options["key"])) {
            $this->key = $options["key"];
        }
        if (isset($options["username"])) {
            $this->username = $options["username"];
        }
        if (isset($options["agent"])) {
            $this->useAgent = (bool) $options["agent"];
        }
    }

Usage Example

Example #1
0
 public function testAccessors()
 {
     $node = new Node();
     $node->setName("test_node_name");
     $this->assertEquals("test_node_name", $node->getName());
     $this->assertEquals("test_node_name", $node->getHostOrDefault());
     $node->setHost("test.node.exsample.com");
     $this->assertEquals("test.node.exsample.com", $node->getHost());
     $this->assertEquals("test.node.exsample.com", $node->getHostOrDefault());
     $this->assertEquals(22, $node->getPortOrDefault());
     $node->setPort(2022);
     $this->assertEquals(2022, $node->getPort());
     $this->assertEquals(2022, $node->getPortOrDefault());
     $node->setDefaultKey("/path/to/default/private_key");
     $this->assertEquals("/path/to/default/private_key", $node->getDefaultKey());
     $this->assertEquals("/path/to/default/private_key", $node->getKeyOrDefault());
     $node->setKey("/path/to/private_key");
     $this->assertEquals("/path/to/private_key", $node->getKey());
     $this->assertEquals("/path/to/private_key", $node->getKeyOrDefault());
     $node->setDefaultUsername("default_ssh_connection_user");
     $this->assertEquals("default_ssh_connection_user", $node->getDefaultUsername());
     $this->assertEquals("default_ssh_connection_user", $node->getUsernameOrDefault());
     $node->setUsername("ssh_connection_user");
     $this->assertEquals("ssh_connection_user", $node->getUsername());
     $this->assertEquals("ssh_connection_user", $node->getUsernameOrDefault());
     try {
         $node->setOptions("aaa");
         $this->assertEquals(fales, true);
     } catch (\RuntimeException $e) {
         $this->assertEquals(true, true);
     }
 }
All Usage Examples Of Altax\Module\Server\Resource\Node::setOptions