Tells if the URI string is valid for the current parser mode.
@param string $uri The URI to validate
@return bool True if the string is valid, false if not
161615
private function isValidString($uri)
    {
        if (preg_match('/^[\\x00-\\x7F]*$/', $uri)) {
            return true;
        } elseif ($this->mode === self::MODE_RFC3986) {
            return false;
        }

        // Validate UTF-8 via regular expression to avoid mbstring dependency
        $pattern =
            '/^(?>
                [\x00-\x7F]+                       # ASCII
              | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
              |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding over longs
              | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
              |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
              |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
              | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
              |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
            )*$/x';

        return (bool) preg_match($pattern, $uri);
    }
202931
private function isAccessAuthorized($uri)
    {
        foreach ($this->forbiddenUriPatterns as $forbiddenUriPattern)
        {
            if (preg_match("@$forbiddenUriPattern@", $uri))
            {
                return false;
            }
        }
        return true;
    }
625297
public function fromString($uri)
    {
        if (is_numeric($uri)) { //Could be a valid url
            $uri = '' . $uri;
        }
        if (!is_string($uri)) {
            $uri = '';
        }
        $this->setRelative();
        if (0 === strpos($uri, '//')) {
            $this->setAbsolute();
        }
        $parsed_url = parse_url($uri);
        if (!$parsed_url) {
            return $this;
        }
        if (array_key_exists('scheme', $parsed_url)) {
            $this->setAbsolute();
        }
        foreach ($parsed_url as $urlPart => $value) {
            $method = 'set' . ucfirst($urlPart);
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
        return $this;
    }
940964
public function isValidUriString($uriString)
    {
        $uriString = '/' . ltrim($uriString, '/');

        if (strtolower($uriString) === $this->path) {
            $this->closureParameters = array_merge(
                $this->closureParameters,
                array_filter(explode('/', $uriString))
            );

            return true;
        } elseif (false !== ($matches = $this->getParseUriString($uriString))) {
            $parameters = [];
            $closure = new \ReflectionFunction($this->closure);

            if (is_string(key($matches))) {
                foreach ($closure->getParameters() as $index => $parameter) {
                    if (($class = $parameter->getClass()) instanceof \ReflectionClass) {
                        $className = $class->getName();
                        if (class_exists($className)) {
                            if (isset($matches[ $parameter->name ])) {
                                $parameters[ $index ] = new $className($matches[ $parameter->name ]);
                            }
                        }
                    } elseif (isset($matches[ $parameter->name ])) {
                        $parameters[ $index ] = $matches[ $parameter->name ];
                    } else {
                        $parameters[ $index ] = null;
                    }
                }
            } else {
                foreach ($closure->getParameters() as $index => $parameter) {
                    if (isset($matches[ $index ])) {
                        $parameters[ $index ] = $matches[ $index ];
                    } else {
                        $parameters[ $index ] = null;
                    }
                }
            }

            $this->closureParameters = $parameters;

            return true;
        }

        return false;
    }
334480
private function validateUri(string $uri): void
    {
        if (filter_var($uri, FILTER_VALIDATE_URL) === false) {
            throw new InvalidArgumentException(sprintf('%s is not a valid uri', $uri));
        }
    }
1356525
public function setCurrentURI($uri) {
        if(is_string($uri) && !empty(trim($uri))){
            $this->currentURI = $uri;
            $this->currentArray = Levels::getCurrent($this->navigation, $this->currentURI);
        }
        else{
            throw new InvalidArgumentException(
                '$uri must be a valid string when seting the current URI'
            );
        }
        return $this;
    }
1202057
public static function isValid($httpUri): bool
    {
        if ($httpUri instanceof self) {
            return true;
        }

        if (empty($httpUri) || !is_string($httpUri)) {
            return false;
        }

        try {
            self::fromString($httpUri);
        } catch (MalformedUri $murle) {
            return false;
        }

        return true;
    }
204042
public static function check($uri)
    {
        try {
            $uri = self::factory($uri);
        } catch (Exception $e) {
            return false;
        }

        return $uri->valid();
    }
1172895
public function match($uri)
    {
        // Normalization of the url of the nagivator.
        if (preg_match('~(.*)/$~', $uri, $match)) {
            $uri = end($match);
        }

        // Normalization of the path defined by the programmer.
        if (preg_match('~(.*)/$~', $this->path, $match)) {
            $this->path = end($match);
        }

        // We go straight back to gain performance.
        if ($this->path === $uri) {
            return true;
        }

        // We check the length of the path defined by the programmer
        // with that of the current url in the user's browser.
        $path = implode('', preg_split('/(\/:[a-z0-9-_]+\?)/', $this->path));

        if (count(explode('/', $path)) != count(explode('/', $uri))) {
            if (count(explode('/', $this->path)) != count(explode('/', $uri))) {
                return false;
            }
        }

        // Copie de l'url
        $path = $uri;

        // In case the developer did not add of constraint on captured variables
        if (empty($this->with)) {
            $path = preg_replace('~:\w+(\?)?~', '([^\s]+)$1', $this->path);

            preg_match_all('~:([a-z-0-9_-]+?)\?~', $this->path, $this->keys);

            $this->keys = end($this->keys);

            return $this->checkRequestUri($path, $uri);
        }

        // In case the developer has added constraints
        // on the captured variables
        if (!preg_match_all('~:([\w]+)?~', $this->path, $match)) {
            return $this->checkRequestUri($path, $uri);
        }

        $tmp_path = $this->path;

        $this->keys = end($match);

        // Association of criteria personalized.
        foreach ($this->keys as $key) {
            if (array_key_exists($key, $this->with)) {
                $tmp_path = preg_replace('~:' . $key . '~', '(' . $this->with[$key] . ')', $tmp_path);
            }
        }

        // Clear the custom criteria association table.
        $this->with = [];

        // In the case where the different path one recovers, one recovers the one in $tmp_path
        if ($tmp_path != $this->path) {
            $path = $tmp_path;
        }

        // Url check and path PARSER
        return $this->checkRequestUri($path, $uri);
    }
612394
public static function parseUri(string $uri){
        if(1 !== preg_match(static::REGEX_URI, $uri, $m)){
            return false;
        }

        $result = [
            "scheme"    => $m["scheme"] ?? "",
            "userinfo"  => $m["userinfo"] ?? "",
            "host"      => $m["host"] ?? "",
            "port"      => "" === $m["port"] ? null : (int)$m["port"],
            "path"      => $m["path"] ?? "",
            "query"     => $m["query"] ?? "",
            "fragment"  => $m["fragment"] ?? "",
        ];

        return $result;
    }
1247015
public static function validateURI($uri) {
        if(!empty(trim($uri))){
            return filter_var(trim($uri), FILTER_VALIDATE_URL);
        }
        return false;
    }
305183
private function parse($uri)
	{
		$parts = parse_url($uri);

		if ($parts === false)
			throw new \InvalidArgumentException("The source URI `{$uri}` appears to be malformed");

		//	special handling of mailto: scheme
		if (($parts['scheme'] ?? null) === 'mailto')
		{
			if (isset($parts['host']) || isset($parts['user']) || isset($parts['pass']) || isset($parts['fragment']) || isset($parts['query']) || isset($parts['port']) || empty($parts['path']) || $parts['path'][0] === '/')
				throw new \InvalidArgumentException("The source email address `{$uri}` appears to be malformed");

			$parts = parse_url('mailto://' . $parts['path']);	//	we 'fool' the parser by adding '//' before the email address, this allows parse_url() to detect the 'authority` components (user@domain)

			if ($parts === false)
				throw new \InvalidArgumentException("The source email address `{$uri}` appears to be malformed");
		}

		$this->fromArray($parts);
	}
763238
public function check($uri)
    {
        $url = parse_url($uri);
        if (isset($url['query'])) {
            parse_str($url['query'], $params);
        } else {
            $params = [];
        }

        if (empty($params[$this->parameter])) {
            return false;
        }

        $hash = $params[$this->parameter];
        unset($params[$this->parameter]);

        return $this->computeHash($this->buildUrl($url, $params)) === $hash;
    }
35398
private function checkRequestUri($path, $uri)
    {
        if (strstr($path, '?') == '?') {
            $uri = rtrim($uri, '/').'/';
        }

        // Url check and path PARSER
        $path = str_replace('~', '\\~', $path);

        if (preg_match('~^'. $path . '$~', $uri, $match)) {
            array_shift($match);

            $this->match = str_replace('/', '', $match);

            return true;
        }

        return false;
    }
478420
public static function isValidAsCookieDomain($uri)
    {
        $domain = self::getDomain($uri);
        if (!empty($domain)) {
            if (preg_match("/^[a-z0-9\-]+(?:[a-z0-9\-]\.)+/iu", $domain) > 0) {
                $returnValue = true;
            } else {
                $returnValue = false;
            }
        } else {
            $returnValue = false;
        }

        return $returnValue;
    }
587982
public static function hasExtension(string $uri, string $extension): bool
    {
        $extension       = '.' . ltrim($extension, '.');
        $uriLength       = mb_strlen($uri);
        $extensionLength = mb_strlen($extension);
        if ($extensionLength > $uriLength) {
            return false;
        }

        return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0;
    }
966061
private static function isValidUri(array $uri): bool
    {
        if (!self::isValidUriScheme($uri['scheme'])) {
            return false;
        }
        if (!self::isValidUriPath($uri['path'])) {
            return false;
        }
        if (!self::isValidUriQuery($uri['query'])) {
            return false;
        }
        if (!self::isValidUriFragment($uri['fragment'])) {
            return false;
        }
        if (!self::isValidUriAuthority($uri['authority'])) {
            return false;
        }

        return true;
    }