setIp($loginOrIp, $port); } elseif ($loginOrIp) { $this->setLogin($loginOrIp); } } /** * Get the server login * * @api * @return string */ public function getLogin() { return $this->login; } /** * Set the server login * * @api * @param string $login Server login * @return static */ public function setLogin($login) { $this->login = (string)$login; $this->ip = null; $this->port = null; return $this; } /** * Get the server ip * * @api * @return string */ public function getIp() { return $this->ip; } /** * Set the server ip and port * * @api * @param string $ip Server ip * @param int $port (optional) Server port * @return static */ public function setIp($ip, $port = null) { $this->login = null; $this->ip = (string)$ip; if ($port) { $this->setPort($port); } return $this; } /** * Get the server port * * @api * @return int */ public function getPort() { return $this->port; } /** * Set the server port * * @param int $port Server port * @return static */ public function setPort($port) { $this->port = (int)$port; return $this; } /** * @see Element::render() */ public function render(\DOMDocument $domDocument) { $domElement = $domDocument->createElement("add_favourite"); if ($this->login) { $loginElement = $domDocument->createElement("login", $this->login); $domElement->appendChild($loginElement); } else { $ipElement = $domDocument->createElement("ip", $this->ip . ":" . $this->port); $domElement->appendChild($ipElement); } return $domElement; } }