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

        $url = self::fromArray(parse_url((string) $url));
        return $url;
    }
public static function fromString($url)
    {
        if (!is_string($url) && !(is_object($url) && method_exists($url, '__toString')))
        {
            throw new \UnexpectedValueException(
                'The url must be a string or object implementing __toString(), "'.gettype($url).'" given.'
            );
        }

        $url = self::fromArray(parse_url((string) $url));
        return $url;
    }
public static function fromString ( $ url ) { if ( ! is_string ( $ url ) && ! ( is_object ( $ url ) && method_exists ( $ url , '__toString' ) ) ) { throw new \ UnexpectedValueException ( 'The url must be a string or object implementing __toString(), "' . gettype ( $ url ) . '" given.' ) ; } $ url = self :: fromArray ( parse_url ( ( string ) $ url ) ) ; return $ url ; }
Build the url from a string

Partial URLs are also accepted. fromString tries its best to parse them correctly.

@param   string  $url
@throws  \UnexpectedValueException If the url is not a string or cannot be casted to one.
@return  HttpUrl
@see     parse_url()
Build the url from a string