<?php
/**
 * Interface for scheduled tasks that run on a recurring basis.
 *
 * @package Awesomemotive\Rewardswp\Interfaces
 * @since 1.4.0
 */

namespace Awesomemotive\Rewardswp\Interfaces;

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

/**
 * Interface ScheduledTaskInterface
 *
 * Tasks implementing this interface are automatically dispatched by
 * TaskSchedulerController based on their recurrence. To add a new task,
 * create a class implementing this interface and register it in the
 * 'scheduled_task_classes' DI array.
 *
 * @since 1.4.0
 */
interface ScheduledTaskInterface {
	/**
	 * Get the recurrence interval for this task.
	 *
	 * @since 1.4.0
	 *
	 * @return string 'hourly' or 'daily'.
	 */
	public function get_recurrence(): string;

	/**
	 * Register any follow-up action hooks needed for pagination.
	 *
	 * Tasks that process items in batches should register their
	 * pagination hooks here (e.g., for pages 2+).
	 *
	 * @since 1.4.0
	 *
	 * @return void
	 */
	public function register_hooks(): void;

	/**
	 * Execute the task (first page/batch).
	 *
	 * Called by the group dispatcher. Should kick off the first batch
	 * of processing. Pagination for subsequent batches is handled
	 * via hooks registered in register_hooks().
	 *
	 * @since 1.4.0
	 *
	 * @return void
	 */
	public function run(): void;
}
