private static function matchBasename($baseName, $pattern, $firstWildcard, $flags)
    {
        if ($firstWildcard === false) {
            if ($pattern === $baseName) {
                return true;
            }
        } elseif ($flags & self::PATTERN_ENDSWITH) {
            /* "*literal" matching against "fooliteral" */
            $n = StringHelper::byteLength($pattern);
            if (StringHelper::byteSubstr($pattern, 1, $n) === StringHelper::byteSubstr($baseName, -$n, $n)) {
                return true;
            }
        }

        $fnmatchFlags = 0;
        if ($flags & self::PATTERN_CASE_INSENSITIVE) {
            $fnmatchFlags |= FNM_CASEFOLD;
        }

        return fnmatch($pattern, $baseName, $fnmatchFlags);
    }
private static function matchBasename($baseName, $pattern, $firstWildcard, $flags)
    {
        if ($firstWildcard === false) {
            if ($pattern === $baseName) {
                return true;
            }
        } elseif ($flags & self::PATTERN_ENDSWITH) {
            /* "*literal" matching against "fooliteral" */
            $n = StringHelper::byteLength($pattern);
            if (StringHelper::byteSubstr($pattern, 1, $n) === StringHelper::byteSubstr($baseName, -$n, $n)) {
                return true;
            }
        }

        $fnmatchFlags = 0;
        if ($flags & self::PATTERN_CASE_INSENSITIVE) {
            $fnmatchFlags |= FNM_CASEFOLD;
        }

        return fnmatch($pattern, $baseName, $fnmatchFlags);
    }
private static function matchBasename ( $ baseName , $ pattern , $ firstWildcard , $ flags ) { if ( $ firstWildcard === false ) { if ( $ pattern === $ baseName ) { return true ; } } elseif ( $ flags & self :: PATTERN_ENDSWITH ) { /* "*literal" matching against "fooliteral" */ $ n = StringHelper :: byteLength ( $ pattern ) ; if ( StringHelper :: byteSubstr ( $ pattern , 1 , $ n ) === StringHelper :: byteSubstr ( $ baseName , - $ n , $ n ) ) { return true ; } } $ fnmatchFlags = 0 ; if ( $ flags & self :: PATTERN_CASE_INSENSITIVE ) { $ fnmatchFlags |= FNM_CASEFOLD ; } return fnmatch ( $ pattern , $ baseName , $ fnmatchFlags ) ; }
Performs a simple comparison of file or directory names.

Based on match_basename() from dir.c of git 1.8.5.3 sources.

@param string $baseName file or directory name to compare with the pattern
@param string $pattern the pattern that $baseName will be compared against
@param integer|boolean $firstWildcard location of first wildcard character in the $pattern
@param integer $flags pattern flags
@return boolean whether the name matches against pattern
Performs a simple comparison of file or directory names .