Automattic\WooCommerce\Admin\Features\OnboardingTasks

Task::convert_object_to_camelcase()public staticWC 1.0

Convert object keys to camelcase.

Method of the class: Task{}

No Hooks.

Return

Object.

Usage

$result = Task::convert_object_to_camelcase( $data );
$data(array) (required)
Data to convert.

Task::convert_object_to_camelcase() code WC 8.7.0

public static function convert_object_to_camelcase( $data ) {
	if ( ! is_array( $data ) ) {
		return $data;
	}

	$new_object = (object) array();

	foreach ( $data as $key => $value ) {
		$new_key              = lcfirst( implode( '', array_map( 'ucfirst', explode( '_', $key ) ) ) );
		$new_object->$new_key = $value;
	}

	return $new_object;
}