src/Util/StringUtil.php
public static function fqcnToBlockPrefix(string $fqcn): string
    {
        // Non-greedy ("+?") to match "type" suffix, if present
        if (preg_match('~([^\\\\]+?)(type)?$~i', $fqcn, $matches)) {
            return strtolower(
                preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], $matches[1])
            );
        }
    }
public static function fqcnToBlockPrefix(string $fqcn): string
    {
        // Non-greedy ("+?") to match "type" suffix, if present
        if (preg_match('~([^\\\\]+?)(type)?$~i', $fqcn, $matches)) {
            return strtolower(
                preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], $matches[1])
            );
        }
    }
Converts a fully-qualified class name to a block prefix.

@param string $fqcn The fully-qualified class name

@return string|null The block prefix or null if not a valid FQCN