<?php
/**
 * Email Click Rate Tile
 *
 * @package     EDD\Pro\CartRecovery\Admin\Reports\Endpoints\Tiles
 * @copyright   Copyright (c) 2026, Sandhills Development, LLC
 * @license     https://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.6.5
 */

namespace EDD\Pro\CartRecovery\Admin\Reports\Endpoints\Tiles;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

use EDD\Reports\Endpoints\Tiles\Tile;

/**
 * Email Click Rate Tile class.
 *
 * Displays the percentage of opened emails with link clicks in the selected date range.
 *
 * @since 3.6.5
 */
class ClickRate extends Tile {
	use Traits\Emails;

	/**
	 * Gets the tile endpoint ID.
	 *
	 * @since 3.6.5
	 * @return string
	 */
	protected function get_id(): string {
		return 'acr_click_rate';
	}

	/**
	 * Gets the tile label for display.
	 *
	 * @since 3.6.5
	 * @return string
	 */
	protected function get_label(): string {
		return __( 'Click Rate', 'easy-digital-downloads' );
	}

	/**
	 * Gets the tooltip content for the tile.
	 *
	 * @since 3.6.5
	 * @return string
	 */
	protected function get_tooltip(): string {
		return __( 'Percentage of opened emails with link clicks.', 'easy-digital-downloads' );
	}

	/**
	 * Gets the email click rate as a percentage.
	 *
	 * @since 3.6.5
	 * @return string
	 */
	protected function get_data(): string {
		$stats = $this->get_email_stats();

		return number_format_i18n( $stats['click_rate'], 2 ) . '%';
	}
}
