protected function convertHost()
{
if (preg_match('#^(tcp|unix)://(.*)$#', $this->host, $matches)) {
if ($matches[1] == 'tcp') {
if (!preg_match('#^([^:]+)(:([0-9]+))?(/(.+))?$#', $matches[2], $matches)) {
throw new CredisException('Invalid host format; expected tcp://host[:port][/persistence_identifier]');
}
$this->host = $matches[1];
$this->port = (int) (isset($matches[3]) ? $matches[3] : 6379);
$this->persistent = isset($matches[5]) ? $matches[5] : '';
} else {
$this->host = $matches[2];
$this->port = NULL;
if (substr($this->host, 0, 1) != '/') {
throw new CredisException('Invalid unix socket format; expected unix:///path/to/redis.sock');
}
}
}
if ($this->port !== NULL && substr($this->host, 0, 1) == '/') {
$this->port = NULL;
}
}