<?php
/**
 * Recovery 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;

/**
 * Recovery Rate Tile class.
 *
 * Displays the cart recovery rate as a percentage in the selected date range.
 *
 * @since 3.6.5
 */
class RecoveryRate extends Tile {
	use Traits\Carts;

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

	/**
	 * Gets the tile label for display.
	 *
	 * @since 3.6.5
	 * @return string
	 */
	protected function get_label(): string {
		return __( 'Recovery 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 abandoned carts that were recovered.', 'easy-digital-downloads' );
	}

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

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