public static function createFromString($url)
    {
        if (!is_string($url)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'url'; expecting a string"
            );
        }

        $ret = new Url;
        if (($url = trim($url)) === '') {
            return $ret;
        }

        if (($url = parse_url($url)) === false) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'url'; ".
                "url parsing failed"
            );
        }

        foreach ($url as $k => $v) {
            $fn = 'set'.ucfirst($k);
            call_user_func([$ret, $fn], $v);
        }
        return $ret;
    }