Tipsy\Route::match PHP Метод

match() публичный Метод

public match ( $page )
    public function match($page)
    {
        if ($this->method() != '*') {
            $methods = explode(',', strtolower($this->method()));
            $match = false;
            foreach ($methods as $method) {
                if ($method == strtolower($this->tipsy()->request()->method())) {
                    $match = true;
                    break;
                }
            }
            if (!$match) {
                return false;
            }
        }
        // index page
        if (($this->_route === '' || $this->_route == '/') && ($page === '' || $page == '/')) {
            return $this;
        }
        $pathParams = [];
        if ($this->_regex) {
            if (preg_match($this->_route, $page, $matches)) {
                $this->_routeParams = $matches;
                return $this;
            }
        } else {
            $paths = explode('/', $this->_route);
            foreach ($paths as $key => $path) {
                if (strpos($path, ':') === 0) {
                    $pathParams[$key] = substr($path, 1);
                }
            }
            $r = preg_replace('/:[a-z]+/i', '.*', $this->_route);
            $r = preg_replace('/\\//', '\\/', $r);
            if (preg_match('/^' . $r . '$/' . ($this->_caseSensitive ? '' : 'i'), $page)) {
                $paths = explode('/', $page);
                foreach ($pathParams as $key => $path) {
                    $this->_routeParams->{$path} = $paths[$key];
                }
                return $this;
            }
        }
        return false;
    }