ManaPHP\Mvc\Router\Group::match PHP Method

match() public method

public match ( string $uri ) : array | false
$uri string
return array | false
    public function match($uri)
    {
        for ($i = count($this->_routes) - 1; $i >= 0; $i--) {
            $route = $this->_routes[$i];
            $matches = $route->match($uri);
            if ($matches !== false) {
                $parts = [];
                /** @noinspection ForeachSourceInspection */
                foreach ($matches as $k => $v) {
                    if (is_string($k)) {
                        $parts[$k] = $v;
                    }
                }
                foreach ($route->getPaths() as $k => $v) {
                    $parts[$k] = $v;
                }
                return $parts;
            }
        }
        if ($this->_useDefaultRoutes) {
            $paths = [];
            if ($uri === '/') {
                return $paths;
            }
            $parts = explode('/', trim($uri, '/'), 3);
            $count = count($parts);
            if ($count === 1) {
                $paths['controller'] = $parts[0];
            } elseif ($count === 2) {
                $paths['controller'] = $parts[0];
                /** @noinspection MultiAssignmentUsageInspection */
                $paths['action'] = $parts[1];
            } elseif ($count === 3) {
                $paths['controller'] = $parts[0];
                $paths['action'] = $parts[1];
                /** @noinspection MultiAssignmentUsageInspection */
                $paths['params'] = $parts[2];
            }
            if (isset($paths['controller']) && preg_match('#^[a-zA-Z0-9_-]+$#', $paths['controller']) !== 1) {
                return false;
            }
            if (isset($paths['action']) && preg_match('#^[a-zA-Z0-9_-]+$#', $paths['action']) !== 1) {
                return false;
            }
            return $paths;
        } else {
            return false;
        }
    }