Check

@param string $directive
@param string $uri
@return bool
@throws \InvalidArgumentException
347074
private function check($directive, $uri)
    {
        $uriParser = new UriParser($uri);
        $uri = $uriParser->convertToFull($this->base);
        if ($this->base !== $uriParser->base()) {
            throw new \InvalidArgumentException('URI belongs to a different robots.txt');
        }
        if (($result = $this->checkOverride($uri)) !== false) {
            return $directive === $result;
        }
        // Path check
        return $this->checkPath($directive, $uri);
    }
412443
protected function isValidFile( $uri )
	{
		if( !file_exists( $uri ) )
			return FALSE;
		if( !$this->expires )
			return TRUE;
		return !$this->isExpired( $uri, $this->expires );
	}
292621
protected function isRelativeUri($uri)
    {
        if ($uri && !parse_url($uri, PHP_URL_SCHEME)) {
            if (!in_array($uri[0], [ '/', '#', '?' ])) {
                return true;
            }
        }

        return false;
    }
265207
public function checkAction( $action, $parameters = array(), $absolute = true )
  {
    try {
      $url = $this->_app['url']->action($action, $parameters, $absolute);
    } catch( InvalidArgumentException $e ) {
      return false;
    }

    return $url;
  }
943849
private function _validateState()
    {
        if (!$this->getAuthority()) {
            if (0 === strpos($this->path, '//')) {
                throw new InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
            }
            if (!$this->scheme && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
                throw new InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
            }
        } elseif (isset($this->path[0]) && $this->path[0] !== '/') {
            throw new InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
        }
    }
751919
public function isMatch(string $uri): bool {
        list($path) = explode('?', $uri, 2);
        if ($path === '') {
            $path = trim($this->conf['default'], '/');
        }
        /** @noinspection ReturnFalseInspection */
        $lastDotPos = strrpos($path, '.');
        $suffix = '';
        if (false !== $lastDotPos) {
            $suffix = substr($path, $lastDotPos + 1);
            $path = substr($path, 0, $lastDotPos);
        }
        $parts = explode('/', $path);
        $this->args = [];
        while (count($parts)) {
            $p = $parts;
            $lastPart =& $p[count($p) - 1];
            $lastPart = Toolkit::toCamelCase($lastPart, true);
            $className = 'action\\' . implode('\\', $p);
            $classNameAction = $className . 'Action';
            $this->action = null;
            if (class_exists($classNameAction)) {
                $this->action = new $classNameAction();
            } else if (class_exists($className)) {
                $this->action = new $className();
            }

            if ($this->action instanceof Action) {
                $this->action->suffix = $suffix;
                return true;
            } elseif ($this->action !== null) {
                X::logger()->warn('Class ' . get_class($this->action) .
                    " is in the action namespace but not an instance of x2ts\\route\\Action.\n" .
                    "Please check the inheriting chain.");
            }
            array_unshift($this->args, array_pop($parts));
        }

        return false;
    }
198118
public function validateUri($uri)
    {
        $query = http_build_query(array_merge(
            $this->getOptions()->buildOptions(),
            array('uri' => $uri)
        ));

        $context = stream_context_create(array(
            'http' => array(
                'method' => 'GET',
                'header' => 'User-Agent: HTMLValidator',
            )
        ));

        $data = $this->sendRequest($this->validatorUri . '?' . $query, $context);

        return $this->parseSOAP12Response($data);
    }
368705
public function canRead(string $uri): bool
    {
        // /book => all
        if (in_array(Acl::RULE_ALL, (array) $this->getPermissionsOf($this->getUriRoot($uri)))) {
            return true;
        }

        // /book/detail => all or read
        $permission = array_filter((array) $this->getPermissionsOf($uri), function($rule) {
            return ($rule == Acl::RULE_ALL || $rule == Acl::RULE_READ);
        });

        return !empty($permission);
    }
612646
public function validateOriginUri($origin)
    {
        $origin = (string)$origin;
        if (!$origin) {
            throw new InvalidArgumentException('Invalid URI');
        }

        $scheme = parse_url($origin, PHP_URL_SCHEME);
        if (!$scheme) {
            throw new InvalidArgumentException('Invalid scheme');
        }

        $host = parse_url($origin, PHP_URL_HOST);
        if (!$host) {
            throw new InvalidArgumentException("Invalid host");
        }

        return $origin;
    }
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;
    }
341970
public static function directiveHasArgument(DirectiveNode $directiveDefinition, string $name): bool
    {
        return (new Collection($directiveDefinition->arguments))
            ->contains(function (ArgumentNode $argumentNode) use ($name): bool {
                return $argumentNode->name->value === $name;
            });
    }
168299
public function setSelfAllowed(string $directive = '', bool $allow = false): self
    {
        if (!\in_array($directive, self::$directives)) {
            throw new \Exception('Directive ' . $directive . ' does not exist');
        }
        $this->policies[$directive]['self'] = $allow;
        return $this;
    }
1352147
public function checkUri($uris)
    {
        if (!$this->request) {
            return false;
        }

        foreach ((array)$uris as $uri) {
            if ($this->uri == $uri) {
                return true;
            }
        }

        return false;
    }
402078
protected function _parseFromString($uri)
    {
        if (false === $parts = parse_url($uri))
            throw new \InvalidArgumentException(sprintf(
                'Malformed uri (%s).'
                , $uri
            ));

        $this->scheme    = isset($parts['scheme'])   ? $parts['scheme']   : '';
        $this->userInfo  = isset($parts['user'])     ? $parts['user']     : '';
        $this->host      = isset($parts['host'])     ? $this->_filterHost($parts['host']) : '';
        $this->port      = isset($parts['port'])     ? $parts['port']     : null;
        $this->path      = isset($parts['path'])     ? $parts['path']     : '';
        $this->query     = isset($parts['query'])    ? $parts['query']    : '';
        $this->fragment  = isset($parts['fragment']) ? $parts['fragment'] : '';

        if (isset($parts['pass']))
            $this->userInfo .= ':' . $parts['pass'];
    }
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;
    }
869329
public function removeTemplateMapping($uri)
    {
        if (gettype($uri) !== 'string') {
            $msg = "The uri argument must be a string, '" . gettype($uri) . "' given.";
            throw new InvalidArgumentException($msg);
        }

        $templateMapping = &$this->getTemplateMapping();

        if (isset($templateMapping[$uri]) === true) {
            unset($templateMapping[$uri]);
        }
    }
452720
public function isIgnoredExtension($uri)
    {
        foreach ($this->ignoredExtensions as $ignoredExtension) {
            if (strpos($uri, $ignoredExtension) !== false) {
                return true;
            }
        }

        return false;
    }