Granam/String/StringTools.php
public static function camelCaseToSnakeCase($value): string
    {
        $value = ToString::toString($value);
        $parts = \preg_split('~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u', $value, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
        $underscored = \preg_replace('~_{2,}~', '_', \implode('_', $parts));

        return \strtolower($underscored);
    }
public static function camelCaseToSnakeCase($value): string
    {
        $value = ToString::toString($value);
        $parts = \preg_split('~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u', $value, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
        $underscored = \preg_replace('~_{2,}~', '_', \implode('_', $parts));

        return \strtolower($underscored);
    }
public static function camelCaseToSnakeCase ( $ value ) : string { $ value = ToString :: toString ( $ value ) ; $ parts = \ preg_split ( '~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u' , $ value , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ underscored = \ preg_replace ( '~_{2,}~' , '_' , \ implode ( '_' , $ parts ) ) ; return \ strtolower ( $ underscored ) ; }
Converts 'OnceUponATime' to 'once_upon_a_time'
@param string|StringInterface $value
@return string
@throws \Granam\Scalar\Tools\Exceptions\WrongParameterType
Converts OnceUponATime to once_upon_a_time