protected function encodeAuthority() : string
{
$authority = $this->getHost();
if (!$authority) {
return '';
}
if ('' !== $this->user) {
if ('' !== $this->password) {
$authority = sprintf('%s:%s@%s', encode($this->user), encode($this->password), $authority);
} else {
$authority = sprintf('%s@%s', encode($this->user), $authority);
}
}
$port = $this->getPort();
if ($port && $this->getPortForScheme() !== $port) {
$authority = sprintf('%s:%s', $authority, $this->getPort());
}
return $authority;
}