src/Router.php
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;
    }
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;
    }
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 ; }
Apply a path pattern to a path.

@param string[] $pattern Path pattern.
@param string[] $path Path.
@return string[]|null An array of path parameters or null if not a match.
Apply a path pattern to a path .