<?php
/**
 * CreateEmailsTableUpgrade.php.
 *
 * @package RewardsWP
 */

namespace Awesomemotive\Rewardswp\Database\Upgrades;

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

use Awesomemotive\Rewardswp\Abstracts\AbstractDatabaseUpgrade;
use Awesomemotive\Rewardswp\Database\Tables\EmailsTable;

/**
 * Create Emails Table Upgrade
 *
 * Creates the emails table to store customizable email templates
 * for the RewardsWP email management system.
 *
 * @since 1.0.0
 */
/**
 * Class CreateEmailsTableUpgrade.
 */
class CreateEmailsTableUpgrade extends AbstractDatabaseUpgrade {
	/**
	 * The version this upgrade targets.
	 *
	 * @since 1.0.0
	 * @var string
	 */
	protected string $version = '1.1.0';

	/**
	 * Emails table instance.
	 *
	 * @since 1.0.0
	 * @var EmailsTable
	 */
	private EmailsTable $table;

	/**
	 * Constructor.
	 *
	 * @since 1.0.0
	 *
	 * @param EmailsTable $table The emails table instance.
	 */
	public function __construct( EmailsTable $table ) {
		$this->table = $table;
	}

	/**
	 * Run the upgrade.
	 *
	 * Creates the emails table in the database.
	 *
	 * @since 1.0.0
	 * @return void
	 */
	public function up(): void {
		$this->table->create_or_update_table();
	}
}
