validate( $product_ids ); parent::__construct( $product_ids, $flags, $iteratorClass ); } /** * Get the value of the object. * * @return array */ public function get(): array { return $this->getArrayCopy(); } /** * @param int[] $product_ids An array of WooCommerce product IDs mapped to Google product IDs as their key. * * @throws InvalidValue When an invalid WooCommerce product ID or Google product ID is provided in the map. */ protected function validate( array $product_ids ) { foreach ( $product_ids as $google_id => $wc_product_id ) { $wc_product_id = filter_var( $wc_product_id, FILTER_VALIDATE_INT ); if ( false === $wc_product_id ) { throw InvalidValue::not_integer( 'product_id' ); } if ( ! is_string( $google_id ) ) { throw InvalidValue::not_string( 'google_id' ); } } } }