public static function toUnderscore($string)
    {
        if (!is_string($string)) {
            throw new \InvalidArgumentException('Not a string');
        }

        $transCoder = Transcoder::create('ASCII');
        $string = $transCoder->transcode(trim($string));
        $words = explode(' ', $string);

        return implode('_', array_filter(array_map([static::class, 'wordToUnderscored'], $words)));
    }
public static function toUnderscore($string)
    {
        if (!is_string($string)) {
            throw new \InvalidArgumentException('Not a string');
        }

        $transCoder = Transcoder::create('ASCII');
        $string = $transCoder->transcode(trim($string));
        $words = explode(' ', $string);

        return implode('_', array_filter(array_map([static::class, 'wordToUnderscored'], $words)));
    }
public static function toUnderscore ( $ string ) { if ( ! is_string ( $ string ) ) { throw new \ InvalidArgumentException ( 'Not a string' ) ; } $ transCoder = Transcoder :: create ( 'ASCII' ) ; $ string = $ transCoder -> transcode ( trim ( $ string ) ) ; $ words = explode ( ' ' , $ string ) ; return implode ( '_' , array_filter ( array_map ( [ static :: class , 'wordToUnderscored' ] , $ words ) ) ) ; }
Converts a string to underscore version.
Also tries to filter out higher UTF-8 chars.

@param string $string

@throws \Ddeboer\Transcoder\Exception\UnsupportedEncodingException
@throws \Ddeboer\Transcoder\Exception\ExtensionMissingException
@throws \InvalidArgumentException

@return string
Converts a string to underscore version . Also tries to filter out higher UTF - 8 chars .