<?php
/**
 * Base class for track date initializers.
 *
 * @package Ealab\Deployer
 */

namespace Ealab\Deployer\Tracking\ItemTracker\TrackDateInitializer;

use Dakwamine\Component\ComponentBasedObject;
use DateTime;
use Ealab\Deployer\Tracking\ItemTracker\ItemTrackerBase;
use Ealab\Deployer\Utility\Date;
use Throwable;

/**
 * Base class for track date initializers.
 *
 * A track date initializer defines the track date that will be used by an untracked item
 * when its tracker is enabled for the first time.
 *
 * It is used mostly on the plugin activation.
 */
class TrackDateInitializerBase extends ComponentBasedObject {
	/**
	 * The ID of this initializer.
	 *
	 * @return string
	 */
	public static function getId(): string {
		return 'base';
	}

	/**
	 * Gets the initial track date for the given local ID.
	 *
	 * @param ItemTrackerBase $item_tracker The item tracker containing the item to track.
	 * @param int|string      $local_id The local ID.
	 *     Can be the auto-incremented value or a composite key string (PHP serialized value).
	 *
	 * @return DateTime The datetime that can be used as the initial track date.
	 *
	 * @throws Throwable Could not create the date.
	 */
	public function getInitialTrackDate(ItemTrackerBase $item_tracker, $local_id): DateTime {
		return Date::getZeroDate();
	}
}
