@param $pattern
@param $path
@param array $patterns

@return IDictionary
778960
public function parse($pattern, $path, array $patterns = []) {
        $patterns = $this->mergeWithLocalPatterns($patterns);
        $names = $this->extractParameterNames($pattern);
        $values = $this->extractParameterValues($pattern, $path, $patterns);
        $parameters = array_combine($names, array_pad($values, count($names), null));

        return new Dictionary($parameters);
    }
747265
public function grep($pattern)
    {
        $results = array_intersect_key($this->attributes, array_flip(
            RegexGuard::getGuard()->grep($pattern, array_keys($this->attributes))
        ));

        return new static($results);
    }
1100031
public function list_keys($pattern = '')
    {
        try {
            $keys = $this->gpg->getKeys($pattern);
            $result = array();

            foreach ($keys as $idx => $key) {
                $result[] = $this->parse_key($key);
                unset($keys[$idx]);
            }

            return $result;
        }
        catch (Exception $e) {
            return $this->get_error_from_exception($e);
        }
    }
80881
private function globRecursive($pattern)
    {
        $paths = glob($pattern);
        foreach ($paths as $path) {
            if (strpos($path, '.') === false) {
                $paths = array_merge($paths, $this->globRecursive($path . '/*'));
            }
        }
        return $paths;
    }
1357056
public function applyPattern(array $pattern, array $path)
    {
        $length = count($pattern);
        if ($length == 0 and count($path) > 0) {
            return null;
        }
        if ($length < count($path) and $pattern[$length - 1] != '**'
            and $pattern[$length - 1] != ':*') {
            return null;
        }
        $parameters = [];
        foreach ($pattern as $j => $part) {
            if ($part == '**' or $part == ':*') {
                $parameters = array_merge(
                    $parameters,
                    array_slice($path, $j)
                );
                break;
            } elseif (! isset($path[$j])) {
                return null;
            }
            if ($path[$j] == $part) {
                continue;
            }
            if ($part == '*') {
                $parameters[] = $path[$j];
                continue;
            }
            if (isset($part[0]) and $part[0] == ':') {
                $var = substr($part, 1);
                if (is_numeric($var)) {
                    $parameters[(int)$var] = $path[$j];
                } else {
                    $parameters[$var] = $path[$j];
                }
                continue;
            }
            return null;
        }
        return $parameters;
    }
1018146
protected static function transform(Pattern $pattern) {
        $result = [];
        $groups = [[$pattern]];

        while ($groups) {
            $children = array_shift($groups);
            $hasBranchPattern = false;
            foreach ($children as $c) {
                if ($c instanceof BranchPattern) {
                    $hasBranchPattern = true;
                    break;
                }
            }
            if ($hasBranchPattern) {
                /** @var BranchPattern $child */
                $child = null;
                foreach ($children as $key => $currentChild) {
                    if ($currentChild instanceof BranchPattern) {
                        $child = $currentChild;
                        unset($children[$key]);
                        break;
                    }
                }
                if ($child instanceof Either) {
                    foreach ($child->children as $c) {
                        $groups[] = array_merge([$c], $children);
                    }
                }
                else if ($child instanceof OneOrMore) {
                    $groups[] = array_merge($child->children, $child->children, $children);
                }
                else {
                    $groups[] = array_merge($child->children, $children);
                }
            }
            else {
                $result[] = $children;
            }
        }

        $rs = [];
        foreach ($result as $e) {
            $rs[] = new Required($e);
        }
        return new Either($rs);
    }
413598
public static function getByPattern(array $bundles, $pattern)
    {
        $pattern = trim($pattern, '/');
        $items = [];
        foreach ($bundles as $bundle) {
            /**
             * @var $bundle RouteBundle
             */
            if ($bundle->getPattern() == $pattern) {
                $items = $bundle;
            }
        }
        return $items;
    }
1287848
public function getTemplatesByPattern($pattern)
    {
        $templates = array();
        foreach ($this->manageableExt->keys() as $ext) {
            $templates = array_merge($templates, parent::getTemplatesByPattern($pattern.$ext));
        }

        return $templates;
    }
566449
public function map($pattern, $handler = null, $methods = '*')
    {
        $this->routes[$pattern] = [
            'handler' => $handler,
            'methods' => $methods,
        ];
    }
1134532
protected function filterPaths(array $paths, $pattern, array $extensions=[])
    {
        if (!$this->isFilterPattern($pattern) && !$extensions) {
            return $paths;
        }
        return array_filter($paths, function ($path) use ($pattern, $extensions) {
            return $this->filterPath($path, $pattern, $extensions);
        });
    }
471866
private function getRegexp(array $patterns): string
    {
        $regexps = [];
        foreach ($patterns as $pattern) {
            // Escape namespace
            $regex = preg_quote(ltrim($pattern, '\\'));

            // Wildcards * and **
            $regex = strtr($regex, ['\\*\\*' => '.*?', '\\*' => '[^\\\\]*?']);

            // If this class does not end by a slash, anchor the end
            if ('\\' !== substr($regex, -1)) {
                $regex .= '$';
            }

            $regexps[] = '^'.$regex;
        }

        return sprintf('{%s}', implode('|', $regexps));
    }
32731
private function getMethods($pattern = "/^action_/") {
		$methos = get_class_methods($this->class);
		$actions = array();

		foreach ($methos as $methodName) {
			if (preg_match($pattern, $methodName)) {
				array_push($actions, $methodName);
			}
		}
		return $actions;
	}
333480
public static function generate($pattern, array $data = [])
    {
        $route = static::replaceOptionalSegments($pattern, $data);
        $route = static::replaceWildCards($route, $data);

        return static::replaceAllSegments($route, $data);
    }
950606
public static function getValidKey($pattern, $arr) {
        $keys = array();
        foreach($arr as $key => $value) {
            if (preg_match($pattern, $key)){
                $keys[] = $key;
            }
        }

        return $keys;
    }
8932
public function map(array $methods, string $pattern, $callable) : RouteInterface
    {
        $route = $this->getRouter()->map($methods, $pattern, $callable);

        return $route;
    }
33835
private function matchPattern($pathName, $pattern)
    {
        if ($pattern[0] !== '/') {
            $pattern = '**/' . $pattern;
        }

        if (\fnmatch($pattern, $pathName)) {
            return true;
        }

        return false;
    }
649533
public function directories($directory, $pattern = '*')
    {
        $all = array_filter($this->listDirectory($directory), function ($path) {
            return $this->type($path) == 'dir';
        });

        return $this->filterPaths($all, $pattern);
    }