Automattic\WooCommerce\Internal\PushNotifications\Entities

PushToken::__constructpublicWC 10.6.0

Creates a new PushToken instance with the given data.

Method of the class: PushToken{}

No Hooks.

Returns

null. Nothing (null).

Usage

$PushToken = new PushToken();
$PushToken->__construct( $data );
$data(array)
Optional array with keys: id, user_id, token, device_uuid, platform, origin.
Default: array()

Changelog

Since 10.6.0 Introduced.

PushToken::__construct() code WC 10.8.1

public function __construct( array $data = array() ) {
	if ( array_key_exists( 'id', $data ) ) {
		$this->set_id( (int) $data['id'] );
	}

	if ( array_key_exists( 'user_id', $data ) ) {
		$this->set_user_id( (int) $data['user_id'] );
	}

	if ( array_key_exists( 'token', $data ) ) {
		$this->set_token( (string) $data['token'] );
	}

	if ( array_key_exists( 'device_uuid', $data ) ) {
		$this->set_device_uuid( (string) $data['device_uuid'] );
	}

	if ( array_key_exists( 'platform', $data ) ) {
		$this->set_platform( (string) $data['platform'] );
	}

	if ( array_key_exists( 'origin', $data ) ) {
		$this->set_origin( (string) $data['origin'] );
	}

	if ( array_key_exists( 'device_locale', $data ) ) {
		$this->set_device_locale( (string) $data['device_locale'] );
	}

	if ( array_key_exists( 'metadata', $data ) ) {
		$this->set_metadata( (array) $data['metadata'] );
	}
}