public function parse($uri)
    {
        if (!$this->isValidString($uri)) {
            return null;
        }

        $pattern = new UriPattern();
        $pattern->allowNonAscii($this->mode !== self::MODE_RFC3986);

        if ($pattern->matchUri($uri, $match)) {
            try {
                return $this->buildUri($match);
            } catch (\InvalidArgumentException $exception) {
                return null;
            }
        }

        return null;
    }
public function parse($uri)
    {
        if (!$this->isValidString($uri)) {
            return null;
        }

        $pattern = new UriPattern();
        $pattern->allowNonAscii($this->mode !== self::MODE_RFC3986);

        if ($pattern->matchUri($uri, $match)) {
            try {
                return $this->buildUri($match);
            } catch (\InvalidArgumentException $exception) {
                return null;
            }
        }

        return null;
    }
public function parse ( $ uri ) { if ( ! $ this -> isValidString ( $ uri ) ) { return null ; } $ pattern = new UriPattern ( ) ; $ pattern -> allowNonAscii ( $ this -> mode !== self :: MODE_RFC3986 ) ; if ( $ pattern -> matchUri ( $ uri , $ match ) ) { try { return $ this -> buildUri ( $ match ) ; } catch ( \ InvalidArgumentException $ exception ) { return null ; } } return null ; }
Parses the URL using the generic URI syntax.

This method returns the `Uri` instance constructed from the components
parsed from the URL. The URL is parsed using either the absolute URI
pattern or the relative URI pattern based on which one matches the
provided string. If the URL cannot be parsed as a valid URI, null is
returned instead.

@param string $uri The URL to parse
@return Uri|null The parsed URL or null if the URL is invalid
Parses the URL using the generic URI syntax .