public function __toString()
{
$domain = '';
$domain .= $this->scheme ? $this->scheme . '://' : '';
$domain .= $this->hostname;
if ($this->port !== null) {
switch ($this->scheme) {
case 'http':
$domain .= $this->port !== 80 ? ':' . $this->port : '';
break;
case 'https':
$domain .= $this->port !== 443 ? ':' . $this->port : '';
break;
default:
$domain .= isset($this->port) ? ':' . $this->port : '';
}
}
return $domain;
}