Automattic\WooCommerce\Internal\PushNotifications\Entities

PushToken::set_user_idpublicWC 10.4.0

Validates and sets the user ID.

Method of the class: PushToken{}

No Hooks.

Returns

null. Nothing (null).

Usage

$PushToken = new PushToken();
$PushToken->set_user_id( $user_id ): void;
$user_id(int) (required)
The ID of the user who owns the token.

Changelog

Since 10.4.0 Introduced.

PushToken::set_user_id() code WC 10.8.1

public function set_user_id( int $user_id ): void {
	$result = PushTokenValidator::validate( compact( 'user_id' ), array( 'user_id' ) );

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

	$this->user_id = $user_id;
}