Set path expression

@param string $regex
@throws \rampage\core\xml\InvalidArgumentException
486677
public function setPathRegex($regex)
    {
        if ($regex === null) {
            $this->pathRegex = null;
            return $this;
        }

        $this->pathRegex = $regex;
        return $this;
    }
80042
protected function _deleteByRegexInner( $regex, $fname )
    {
        $sql = "UPDATE " . $this->dbTable( $regex ) . " SET mtime=-ABS(mtime), expired=1\nWHERE name REGEXP " . $this->_quote( $regex );
        if ( !$res = $this->_query( $sql, $fname ) )
        {
            $this->_fail( "Failed to delete files by regex: '$regex'" );
        }
        return true;
    }
1336620
public function setRegexp($regexp)
	{
		if (is_string($regexp))
		{
			$regexp = new Regexp($regexp);
		}

		$this->vars['regexp'] = $regexp;
		$this->resetSafeness();
		$this->evaluateSafeness();
	}
620328
public function setValue($value)
    {
        if (!is_string($value) || (is_object($value) && !method_exists($value, "__toString"))) {
            throw new InvalidArgumentException(sprintf(
                "Invalid argument given to %s, expected a string, %s given",
                __METHOD__,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        $value = (string) $value;

        if (null !== $regex = $this->getValidationRegex()) {
            if (! preg_match($regex, $value)) {
                throw new InvalidArgumentException(sprintf(
                    "The given value '%s' doesn't match the validation regular expression: %s",
                    $value,
                    $regex
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
326481
protected function setPath($path)
    {
        if ($path !== '' && !$this->isValidPath($path)) {
            throw new \InvalidArgumentException("Invalid path '$path'");
        }
        
        $this->path = (string)$path;
    }
1312087
public function setProjectRootRegex($projectRootRegex)
    {
        if ($projectRootRegex && @preg_match($projectRootRegex, null) === false) {
            throw new InvalidArgumentException('Invalid project root regex: '.$projectRootRegex);
        }

        $this->projectRootRegex = $projectRootRegex;
        $this->setStripPathRegex($projectRootRegex);
    }
333121
public function setRegexp($pattern)
    {
        $regexp = new RegularExpression();
        $regexp->setPattern($pattern);
        $this->_regexps[] = $regexp;
    }
478651
public function setPrefix(string $prefix): RouteInterface
    {
        if (!preg_match(
                "/^([A-Z]{1}[a-zA-Z_0-9]{1,31}(\/{1})?){1,5}$/",
                $prefix)) {
            throw new InvalidArgumentException(
                "Can't set prefix: invalid prefix " . $prefix);
        }
        $this->prefix = rtrim($prefix, "/");
        return $this;
    }
929902
public function buildFromDirectory($dir, $regex = null)
    {
        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator(
                $dir,
                FilesystemIterator::KEY_AS_PATHNAME
                | FilesystemIterator::CURRENT_AS_FILEINFO
                | FilesystemIterator::SKIP_DOTS
            )
        );

        if ($regex) {
            $iterator = new RegexIterator($iterator, $regex);
        }

        $this->buildFromIterator($iterator, $dir);
    }
701608
public function set($str)
	{
		if ($str instanceof Path) {
			$this->path->set($str->get());
		} else if ($str instanceof UrlPath) {
			$this->path->set($str->get());
		} else if (is_string($str)) {
			$this->path->set($str);
		} else {
			throw new \InvalidArgumentException('Unexpected type.');
		}
	}
1179845
public function setMatch(string $match) : self
    {
        if (substr($match, 0, 1) == '^' || substr($match, -1) == '$') {
            throw new \InvalidArgumentException(
                sprintf("Can't set start & end line on match for '%s'", $match)
            );
        }

        $this->match = $match;

        return $this;
    }
611385
public function setPath(array $path)
    {
        if (count($path) === 0) {
            $msg = "The path argument must be a non-empty array.";
            throw new InvalidArgumentException($msg);
        } else {
            $this->path = $path;
        }
    }
520379
public function setRouteDeclaration(string $doc, string $basePath = ''): Route
    {
        $regex_define = <<<'EOD'
(?(DEFINE)
    (?<d_quotes> \'(?>[^'\\]++|\\.)*\' | "(?>[^"\\]++|\\.)*" )
    (?<d_json_element> (?: \g<d_quotes> | [\w_]+ ) \s* : \s* \g<d_quotes> )
    (?<d_json> { \s* \g<d_json_element> (?: \s* , \s* \g<d_json_element> )* \s* } )
    (?<d_bool> true | false )
    (?<d_option> [\w_]+\s*=\s*(?: \g<d_json> | \g<d_quotes> | \g<d_bool> ) )
)
EOD;

        $matches = [];
        if (preg_match('~' . $regex_define . '^ \( \s* (?<route> \g<d_quotes> ) (?<options> (?: \s* , \s* \g<d_option> )+ )? \s* \) $ ~x', $doc, $matches) == 1) {
            // Treatment for base of path
            if (!empty($basePath)) {
                // Remove slash at the end of base path
                if (substr($basePath, -1) == '/') {
                    $basePath = substr($basePath, 0, -1);
                }
            }

            // Route
            $this->setRoute($basePath . substr($matches['route'], 1, -1));

            // Route parameters
            $this->parameters = [];
            $matchesParams = [];
            if (preg_match_all(self::REGEX_PARAMETER, $this->route, $matchesParams) > 0) {
                foreach ($matchesParams['name'] as $match) {
                    if (!isset($this->parameters[$match])) {
                        $parameter = new Parameter;
                        $parameter->setName($match);

                        $this->addParameter($parameter);
                    } else {
                        throw new BerliozException(sprintf('Parameter "%s" is declared more than one time', $match));
                    }
                }
            }

            // Options
            $this->route_options = [];
            if (!empty($matches['options'])) {
                $matchesOptions = [];
                if (preg_match_all('~' . $regex_define . '\s* , \s* (?<name> [\w_]+) \s* = \s* (?: (?<json> \g<d_json> ) | (?<bool> \g<d_bool> ) | (?<string> \g<d_quotes> ) ) \s* ~x', $matches['options'], $matchesOptions, PREG_SET_ORDER)) {
                    foreach ($matchesOptions as $matchOption) {
                        $optionName = $matchOption['name'];

                        if (!empty($matchOption['json'])) {
                            $optionValue = json_decode(addcslashes($matchOption['json'], '\\'), true);

                            if ($optionValue !== false) {
                                if (!isset($this->route_options[$optionName])) {
                                    $this->route_options[$optionName] = $optionValue;
                                } else {
                                    $this->route_options[$optionName] = array_merge($this->route_options[$optionName], $optionValue);
                                }
                            } else {
                                throw new BerliozException('Parse error of @route tag');
                            }
                        } else {
                            if (!empty($matchOption['bool'])) {
                                $this->route_options[$optionName] = $matchOption['bool'] == true;
                            } else {
                                if (!empty($matchOption['string'])) {
                                    $this->route_options[$optionName] = substr($matchOption['string'], 1, -1);
                                }
                            }
                        }
                    }
                }

                // Options: default values
                if (isset($this->route_options['defaults'])) {
                    foreach ($this->route_options['defaults'] as $key => $value) {
                        if (!is_null($this->getParameter($key))) {
                            $this->getParameter($key)->setHasDefaultValue(true);
                            $this->getParameter($key)->setDefaultValue($value);
                        }
                    }
                    unset($this->route_options['defaults']);
                }

                // Options: route requirements
                if (isset($this->route_options['requirements'])) {
                    foreach ($this->route_options['requirements'] as $key => $value) {
                        if (!is_null($this->getParameter($key))) {
                            if (preg_match('/^' . $value . '$/', null) !== false) {
                                $this->getParameter($key)->setRegexValidation($value);
                            } else {
                                throw new BerliozException(sprintf('Parameter "%s", requirement is not valid regex', $key));
                            }
                        }
                    }
                    unset($this->route_options['requirements']);
                }
            }
        } else {
            throw new BerliozException('Parse error of @route tag');
        }

        return $this;
    }
659606
public function setFragment($fragment)
    {
        if (preg_match(self::PATTERN_MATCH_FRAGMENT, $fragment) !== 1) {
            throw new \InvalidArgumentException('"' . $fragment . '" is not valid fragment as part of a URI.', 1184071252);
        }

        $this->fragment = $fragment;
    }
1197939
public function regex($regex, $error) {
        if ($this->_exist) {
            array_push($this->_constraints, ['type' => self::REGEX, 'value' => $regex, 'message' => $error]);
        }

        return $this;
    }
956454
public final void setRegex(@NonNull final Pattern regex) {
        Condition.INSTANCE.ensureNotNull(regex, "The regular expression may not be null");
        this.regex = regex;
    }
360577
protected function findRealPathFiles(string $regex, string $path) {
		if(!is_dir($path))
			return null;
				
		$files = $this->findFilesAsSplFileInfo($regex, $path);
		$result = [];
		
		foreach ($files as $item) {
			
			if($item instanceof SplFileInfo)
				$result[] = $item->getRealPath();			
		}
		
		return !empty($result) ? $result : null;
	}