public function setServer($host, $port = 0)
{
if (!is_string($host)) {
throw new \InvalidArgumentException('Host name must be a string.');
}
if ($host[0] === '/') {
$this->path = 'unix://' . $host;
return $this;
}
if (substr($host, 0, 7) === 'unix://') {
$this->path = $host;
return $this;
}
$this->host = $host;
$port = intval($port);
if ($port < 0 || $port >= 65536) {
throw new \InvalidArgumentException('Port number must be an integer between 0 and 65536.');
}
$this->port = $port ?: 9312;
$this->path = '';
return $this;
}