public static function matches(string $str, string $pattern) : bool
    {
        if ($pattern === $str) {
            return true;
        }

        return (bool) preg_match('#^'.str_replace('\*', '.*', preg_quote($pattern, '#')).'\z'.'#', $str);
    }