Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce

Coupon_Code_Generator::extract_idsprivateWC 1.0

Extract integer IDs from an array of {id, title} objects.

Method of the class: Coupon_Code_Generator{}

No Hooks.

Returns

Array. Array of integer IDs.

Usage

// private - for code of main (parent) class only
$result = $this->extract_ids( $items ): array;
$items(array) (required)
Array of items with 'id' key.

Coupon_Code_Generator::extract_ids() code WC 10.9.4

private function extract_ids( array $items ): array {
	return array_map(
		function ( $item ): int {
			if ( ! is_array( $item ) ) {
				return 0;
			}
			$id = $item['id'] ?? 0;
			return is_numeric( $id ) ? (int) $id : 0;
		},
		$items
	);
}