public function getPathParams(string $path): array
    {
        $pathParams = [];

        // Build out the regex
        $pattern = implode("\/", $this->getPatternParts());

        if( preg_match("/^{$pattern}$/", $path, $parts) ){

            // Grab all but the first match, because that will always be the full string.
            foreach( array_slice($parts, 1, count($parts) - 1) as $i => $param ) {
                $pathParams[$this->namedPathParameters[$i]] = $param;
            }
            
        }

        return $pathParams;
    }
public function getPathParams(string $path): array
    {
        $pathParams = [];

        // Build out the regex
        $pattern = implode("\/", $this->getPatternParts());

        if( preg_match("/^{$pattern}$/", $path, $parts) ){

            // Grab all but the first match, because that will always be the full string.
            foreach( array_slice($parts, 1, count($parts) - 1) as $i => $param ) {
                $pathParams[$this->namedPathParameters[$i]] = $param;
            }
            
        }

        return $pathParams;
    }
public function getPathParams ( string $ path ) : array { $ pathParams = [ ] ; // Build out the regex $ pattern = implode ( "\/" , $ this -> getPatternParts ( ) ) ; if ( preg_match ( "/^{$pattern}$/" , $ path , $ parts ) ) { // Grab all but the first match, because that will always be the full string. foreach ( array_slice ( $ parts , 1 , count ( $ parts ) - 1 ) as $ i => $ param ) { $ pathParams [ $ this -> namedPathParameters [ $ i ] ] = $ param ; } } return $ pathParams ; }
Extract the path parameters for the given URI.

Makes a key => value pair of path part names and their value.

Eg.

The route "books/{id}" with an actual URI of "books/1234"
will return:

[
"id" => "1234",
]

These named path params are used during Dependency Injection resolution
in the Kernel to pass off to the matched method parameter.

@param string $path
@return array<string, string>
Extract the path parameters for the given URI .