src/Net/URL2.php
public function setAuthority($authority)
    {
        $this->_userinfo = false;
        $this->_host     = false;
        $this->_port     = false;

        if (!preg_match('(^(([^\@]*)\@)?([^:]+)(:(\d*))?$)', $authority, $matches)) {
            return $this;
        }

        if ($matches[1]) {
            $this->_userinfo = $this->_encodeData($matches[2]);
        }

        $this->_host = $matches[3];
        if (isset($matches[5])) {
            $this->_port = $matches[5];
        }
        return $this;
    }
public function setAuthority($authority)
    {
        $this->_userinfo = false;
        $this->_host     = false;
        $this->_port     = false;

        if (!preg_match('(^(([^\@]*)\@)?([^:]+)(:(\d*))?$)', $authority, $matches)) {
            return $this;
        }

        if ($matches[1]) {
            $this->_userinfo = $this->_encodeData($matches[2]);
        }

        $this->_host = $matches[3];
        if (isset($matches[5])) {
            $this->_port = $matches[5];
        }
        return $this;
    }
Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify
false if there is no authority.

@param string|bool $authority a hostname or an IP address, possibly
with userinfo prefixed and port number
appended, e.g. "foo:bar@example.org:81".

@return $this