WP_Interactivity_API::kebab_to_camel_caseprivateWP 1.0

Transforms a kebab-case string to camelCase.

Method of the class: WP_Interactivity_API{}

No Hooks.

Returns

String. The transformed camelCase string.

Usage

// private - for code of main (parent) class only
$result = $this->kebab_to_camel_case( $str ): string;
$str(string) (required)
The kebab-case string to transform to camelCase.

WP_Interactivity_API::kebab_to_camel_case() code WP 6.8.1

private function kebab_to_camel_case( string $str ): string {
	return lcfirst(
		preg_replace_callback(
			'/(-)([a-z])/',
			function ( $matches ) {
				return strtoupper( $matches[2] );
			},
			strtolower( rtrim( $str, '-' ) )
		)
	);
}