<?php

namespace WC_Affiliate\Bootstrap;

defined( 'ABSPATH' ) || exit;

/**
 * Plugin Uninstaller Class
 *
 * Handles plugin uninstallation including cleaning up database tables,
 * removing options, and clearing scheduled events.
 *
 * @since   1.0.0
 * @package WC_Affiliate\Bootstrap
 */
class Uninstaller {

	/**
	 * Run uninstallation routines.
	 */
	public static function uninstall() {
		$uninstaller = new self();

		$uninstaller->remove_db_version();
	}

	/**
	 * Remove plugin options from the database.
	 *
	 * Cleans up the database version flag and all migration-related options so
	 * that a fresh reinstall is not contaminated by stale state from a previous
	 * activation. This prevents wc_affiliate_has_legacy_options() from
	 * misidentifying a fresh install as an existing legacy installation.
	 */
	protected function remove_db_version() {
		delete_option( 'wc_affiliate_db_version' );
		delete_option( 'wc_affiliate_plugin_user_status' );
		delete_option( 'wc_affiliate_plugin_migration_status' );
		delete_option( 'wc_affiliate_migration_notice_dismissed' );
		delete_option( 'wc_affiliate_activated' );
		delete_option( 'wc_affiliate_settings_migrated' );
	}
}
