HTTPConnection::getHost PHP Method

getHost() public method

public getHost ( ) : string
return string
    public function getHost()
    {
        if ($this->initialized) {
            $hostname = $this->getHostName();
            if ($this->secure && $this->port != HTTPConnection::HTTPS_PORT || !$this->secure && $this->port != HTTPConnection::HTTP_PORT) {
                return $hostname . ':' . $this->port;
            } else {
                return $hostname;
            }
        } else {
            throw new BadMethodCallException('Conexão não inicializada');
        }
    }

Usage Example

 public function open(HTTPConnection $httpConnection)
 {
     $error = null;
     $errno = 0;
     $this->handler = fsockopen($httpConnection->getHost(), $httpConnection->getPort(), $errno, $error, $httpConnection->getConnectionTimeout());
 }