Automattic\WooCommerce\Internal\StockNotifications\AsyncTasks

NotificationsProcessor::parse_argsprivateWC 1.0

Parse the product ID from the arguments.

Method of the class: NotificationsProcessor{}

No Hooks.

Returns

Int.

Usage

// private - for code of main (parent) class only
$result = $this->parse_args( $product_id ): int;
$product_id(int) (required)
The product ID.

NotificationsProcessor::parse_args() code WC 10.3.6

private function parse_args( $product_id ): int {
	if ( empty( $product_id ) || ! is_numeric( $product_id ) ) {
		throw new \Exception( 'Invalid arguments.' );
	}

	$product_id = (int) $product_id;
	if ( $product_id <= 0 ) {
		throw new \Exception( 'Product ID is required.' );
	}

	return $product_id;
}