<?php
/**
 * Program participants option definition.
 *
 * @package RewardsWP
 */

namespace Awesomemotive\Rewardswp\Settings\Options\General;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Awesomemotive\Rewardswp\Abstracts\AbstractOption;
use Awesomemotive\Rewardswp\Interfaces\OptionInterface;

/**
 * Option for configuring who can participate in the rewards program (all customers or members only).
 */
class ProgramParticipantsOption extends AbstractOption implements OptionInterface {
	/**
	 * Get the setting key used in the option array.
	 *
	 * @since 1.1.0
	 *
	 * @return string
	 */
	public function get_name(): string {
		return 'program_participants';
	}

	/**
	 * Get the setting group.
	 *
	 * @since 1.1.0
	 *
	 * @return string
	 */
	public function get_group(): string {
		return 'general';
	}

	/**
	 * Get the default value for the setting.
	 *
	 * @since 1.1.0
	 *
	 * @return string
	 */
	public function get_default_value(): string {
		return 'all_customers'; // Default to allowing all customers (guests + members).
	}

	/**
	 * Get the label for the setting.
	 *
	 * @since 1.1.0
	 *
	 * @return string
	 */
	public function get_label(): string {
		return esc_html__( 'Program Participants', 'rewardswp' );
	}

	/**
	 * Get the type of the setting (text, textarea, select, etc).
	 *
	 * @since 1.1.0
	 *
	 * @return string
	 */
	public function get_type(): string {
		return 'radio';
	}

	/**
	 * Sanitize the value.
	 *
	 * @since 1.1.0
	 *
	 * @param mixed $value The value to be sanitized.
	 *
	 * @return string
	 */
	public function sanitize( $value ): string {
		return in_array( $value, [ 'all_customers', 'members_only' ], true ) ? $value : 'all_customers';
	}
}
