WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php
protected function transform( $string, $regex, $transform_type = 'full' ) {

		switch ( $transform_type ) {
			case 'case':
				return strtolower( $string );

			case 'punctuation':
				return preg_replace( $regex, '_', $string );

			case 'full':
			default:
				return preg_replace( $regex, '_', strtolower( $string ) );
		}
	}
protected function transform( $string, $regex, $transform_type = 'full' ) {

		switch ( $transform_type ) {
			case 'case':
				return strtolower( $string );

			case 'punctuation':
				return preg_replace( $regex, '_', $string );

			case 'full':
			default:
				return preg_replace( $regex, '_', strtolower( $string ) );
		}
	}
Transform an arbitrary string to lowercase and replace punctuation and spaces with underscores.

@param string $string         The target string.
@param string $regex          The punctuation regular expression to use.
@param string $transform_type Whether to a partial or complete transform.
Valid values are: 'full', 'case', 'punctuation'.
@return string