<?php
/**
 * Cookie expiration option definition.
 *
 * @package RewardsWP
 */

namespace Awesomemotive\Rewardswp\Settings\Options\Referrals;

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

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

/**
 * Option for configuring the referral cookie expiration (in days).
 */
class CookieExpirationOption extends AbstractOption implements OptionInterface {
	/**
	 * Get the setting key used in the option array.
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	public function get_name(): string {
		return 'cookie_expiration';
	}

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

	/**
	 * Get the default value for the setting.
	 *
	 * @since 1.0.0
	 *
	 * @return int
	 */
	public function get_default_value(): int {
		return 30;
	}

	/**
	 * Get the label for the setting.
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	public function get_label(): string {
		return esc_html__( 'Referral Cookie Duration', 'rewardswp' );
	}

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

	/**
	 * Ensure an int is returned when sanitizing.
	 *
	 * @since 1.0.0
	 *
	 * @param mixed $value The value to be sanitized.
	 *
	 * @return int
	 */
	public function sanitize( $value ): int {
		return absint( $value );
	}
}
