<?php
/**
 * ActiveTrail Consent Helper
 *
 * Single source of truth for reading marketing consent from POST/posted_data.
 * WooCommerce may send the checkbox as activetrail_consent or billing_activetrail_consent.
 *
 * @package ActiveTrail_WooCommerce
 * @since 1.0.0
 */

// Prevent direct access.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * ActiveTrail Consent Helper
 */
class ActiveTrail_Consent_Helper {

	/**
	 * Check if consent was given in posted/request data.
	 *
	 * @param array $data Posted data (e.g. $_POST or $posted_data from checkout).
	 * @return bool True if activetrail_consent or billing_activetrail_consent is set and truthy.
	 */
	public static function has_consent_from_data( array $data ): bool {
		return (
			! empty( $data['activetrail_consent'] ) ||
			! empty( $data['billing_activetrail_consent'] )
		);
	}
}
