Webiny\Component\Rest\Response\Router::doesPatternMatch PHP Method

doesPatternMatch() private method

Checks if $pattern matches $url.
private doesPatternMatch ( string $pattern, array $data, string $url ) : boolean
$pattern string Pattern that will be used for matching.
$data array An array holding the information about the parameters.
$url string Url upon we will try to do the match.
return boolean True is returned if $pattern matches $url, otherwise false.
    private function doesPatternMatch($pattern, $data, $url)
    {
        // we need regex only if we need to match some parameters
        if (count($data['params']) <= 0) {
            $endingUrl = substr($url, strrpos($url, $pattern));
            if ($endingUrl == $pattern) {
                return [];
            }
        } else {
            $pattern = str_replace('/', '\\/', $pattern);
            preg_match('/' . $pattern . '$/', $url, $matches);
            if (isset($matches[0])) {
                array_shift($matches);
                return $matches;
            }
        }
        return false;
    }