src/Viserio/Component/Support/Str.php
public static function snake(string $value, string $delimiter = '_'): string
    {
        $key = $value;

        if (isset(static::$snakeCache[$key][$delimiter])) {
            return static::$snakeCache[$key][$delimiter];
        }

        if (! \ctype_lower($value)) {
            $value = self::normalizeScreamingCase($value);
            $value = \trim($value);
            $value = \mb_strtolower(\preg_replace('/(.)(?=[A-Z0-9])/u', '$1' . $delimiter, $value));
            $value = \preg_replace('/[_\s-]+/', $delimiter, $value);
        }

        return static::$snakeCache[$key][$delimiter] = $value;
    }
public static function snake(string $value, string $delimiter = '_'): string
    {
        $key = $value;

        if (isset(static::$snakeCache[$key][$delimiter])) {
            return static::$snakeCache[$key][$delimiter];
        }

        if (! \ctype_lower($value)) {
            $value = self::normalizeScreamingCase($value);
            $value = \trim($value);
            $value = \mb_strtolower(\preg_replace('/(.)(?=[A-Z0-9])/u', '$1' . $delimiter, $value));
            $value = \preg_replace('/[_\s-]+/', $delimiter, $value);
        }

        return static::$snakeCache[$key][$delimiter] = $value;
    }
Convert a string to snake case.

@see https://en.wikipedia.org/wiki/Snake_case

@param string $value
@param string $delimiter

@return string