Automattic\WooCommerce\Internal\PushNotifications\Entities

PushToken::set_device_localepublicWC 10.6.0

Validates and sets the device locale.

Method of the class: PushToken{}

No Hooks.

Returns

null. Nothing (null).

Usage

$PushToken = new PushToken();
$PushToken->set_device_locale( $device_locale ): void;
$device_locale(string) (required)
The locale of the device the token belongs to.

Changelog

Since 10.6.0 Introduced.

PushToken::set_device_locale() code WC 10.8.1

public function set_device_locale( string $device_locale ): void {
	$result = PushTokenValidator::validate( compact( 'device_locale' ), array( 'device_locale' ) );

	if ( is_wp_error( $result ) ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
		throw new PushTokenInvalidDataException( $result->get_error_message() );
	}

	$this->device_locale = trim( $device_locale );
}