public static function matchesPattern($pattern, $givenString)
    {
        if ($pattern == $givenString) {
            return true;
        }

        $pattern = preg_quote($pattern, '#');
        $pattern = str_replace('\*', '.*', $pattern) . '\z';

        return (bool)preg_match('#^' . $pattern . '#', $givenString);
    }