public function findBranch(string $part): ?RouteBranch
    {
        // Try finding an exact match first.
        if( array_key_exists($part, $this->branches) ){
            return $this->branches[$part];
        }

        // Loop through each branch key and match it using a regex.
        foreach( $this->branches as $key => $branch ){
            if( preg_match("/^{$key}$/", $part) ){
                return $branch;
            }
        }

        return null;
    }
public function findBranch(string $part): ?RouteBranch
    {
        // Try finding an exact match first.
        if( array_key_exists($part, $this->branches) ){
            return $this->branches[$part];
        }

        // Loop through each branch key and match it using a regex.
        foreach( $this->branches as $key => $branch ){
            if( preg_match("/^{$key}$/", $part) ){
                return $branch;
            }
        }

        return null;
    }
public function findBranch ( string $ part ) : ? RouteBranch { // Try finding an exact match first. if ( array_key_exists ( $ part , $ this -> branches ) ) { return $ this -> branches [ $ part ] ; } // Loop through each branch key and match it using a regex. foreach ( $ this -> branches as $ key => $ branch ) { if ( preg_match ( "/^{$key}$/" , $ part ) ) { return $ branch ; } } return null ; }
Find the matching branch for the given URI path part.

@param string $part
@return RouteBranch|null
Find the matching branch for the given URI path part .