code/http/url/url.php
public function setUrl($url)
    {
        if (!is_string($url) && !is_array($url) && !(is_object($url) && method_exists($url, '__toString')))
        {
            throw new \UnexpectedValueException(
                'The url must be a array as returned by parse_url() a string or object implementing __toString(), "'.gettype($url).'" given.'
            );
        }

        if(!is_array($url)) {
            $parts = parse_url((string) $url);
        } else {
            $parts = $url;
        }

        if (is_array($parts)) {
            foreach ($parts as $key => $value) {
                $this->$key = $value;
            }
        }

        return $this;
    }
public function setUrl($url)
    {
        if (!is_string($url) && !is_array($url) && !(is_object($url) && method_exists($url, '__toString')))
        {
            throw new \UnexpectedValueException(
                'The url must be a array as returned by parse_url() a string or object implementing __toString(), "'.gettype($url).'" given.'
            );
        }

        if(!is_array($url)) {
            $parts = parse_url((string) $url);
        } else {
            $parts = $url;
        }

        if (is_array($parts)) {
            foreach ($parts as $key => $value) {
                $this->$key = $value;
            }
        }

        return $this;
    }
public function setUrl ( $ url ) { if ( ! is_string ( $ url ) && ! is_array ( $ url ) && ! ( is_object ( $ url ) && method_exists ( $ url , '__toString' ) ) ) { throw new \ UnexpectedValueException ( 'The url must be a array as returned by parse_url() a string or object implementing __toString(), "' . gettype ( $ url ) . '" given.' ) ; } if ( ! is_array ( $ url ) ) { $ parts = parse_url ( ( string ) $ url ) ; } else { $ parts = $ url ; } if ( is_array ( $ parts ) ) { foreach ( $ parts as $ key => $ value ) { $ this -> $ key = $ value ; } } return $ this ; }
Parse the url from a string

Partial URLs are also accepted. setUrl() tries its best to parse them correctly. Function also accepts an
associative array like parse_url returns.

@param   string|array  $url Part(s) of an URL in form of a string or associative array like parse_url() returns
@throws  \UnexpectedValueException If the url is not an array a string or cannot be casted to one.
@return  HttpUrl
@see     parse_url()
Parse the url from a string