public static function snakeCase(string $value, bool $toLowerCase = false, string $separator = '_'): string
    {
        $replace = strtolower(preg_replace(
            ['/\s+/', '/\s/', '/(?|([a-z\d])([A-Z])|([^\^])([A-Z][a-z]))/', '/[-_]+/'],
            [' ', $separator, '$1' . $separator . '$2', $separator],
            trim($value)
        ));
        return $toLowerCase ? strtolower($replace) : $replace;
    }
public static function snakeCase(string $value, bool $toLowerCase = false, string $separator = '_'): string
    {
        $replace = strtolower(preg_replace(
            ['/\s+/', '/\s/', '/(?|([a-z\d])([A-Z])|([^\^])([A-Z][a-z]))/', '/[-_]+/'],
            [' ', $separator, '$1' . $separator . '$2', $separator],
            trim($value)
        ));
        return $toLowerCase ? strtolower($replace) : $replace;
    }
public static function snakeCase ( string $ value , bool $ toLowerCase = false , string $ separator = '_' ) : string { $ replace = strtolower ( preg_replace ( [ '/\s+/' , '/\s/' , '/(?|([a-z\d])([A-Z])|([^\^])([A-Z][a-z]))/' , '/[-_]+/' ] , [ ' ' , $ separator , '$1' . $ separator . '$2' , $ separator ] , trim ( $ value ) ) ) ; return $ toLowerCase ? strtolower ( $ replace ) : $ replace ; }
Snake case.

@param string $value
@param bool $toLowerCase Default false.
@param string $separator Default '_'.
@return string
Snake case .