<?php
/**
 * Maintenance Component
 *
 * Handles the maintenance sweep cron job for rescuing stalled carts.
 *
 * @package EDD\Pro\CartRecovery\Cron\Components
 * @copyright Copyright (c) 2026, Sandhills Development, LLC
 * @license https://opensource.org/licenses/GPL-3.0 GNU General Public License v3.0
 * @since 3.6.5
 */

namespace EDD\Pro\CartRecovery\Cron\Components;

use EDD\Cron\Components\Component;
use EDD\Pro\CartRecovery\Jobs\Maintenance as MaintenanceJob;

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

/**
 * Maintenance Component Class
 *
 * Subscribes to the maintenance sweep hook and delegates to the maintenance job.
 *
 * @since 3.6.5
 */
class Maintenance extends Component {

	/**
	 * The unique identifier for this component.
	 *
	 * @since 3.6.5
	 * @var string
	 */
	protected static $id = 'acr_maintenance';

	/**
	 * Get the subscribed events for maintenance jobs.
	 *
	 * @since 3.6.5
	 *
	 * @return array The array of hook => method mappings.
	 */
	public static function get_subscribed_events(): array {
		return array(
			'edd_acr_maintenance_sweep' => 'handle_maintenance_sweep',
		);
	}

	/**
	 * Handle maintenance sweep job.
	 *
	 * @since 3.6.5
	 *
	 * @return void
	 */
	public function handle_maintenance_sweep(): void {
		MaintenanceJob::handle();
	}
}
