<?php
/**
 * The plugin deactivation class.
 *
 * @package Storeplugin\PDFInvoice
 * @since 1.0.0
 */

namespace Storeplugin\PDFInvoice;

defined('ABSPATH') || exit;

use Storeplugin\PDFInvoice\Framework\Contracts\ServiceInterface;
use Storeplugin\PDFInvoice\App\TempDir;

/**
 * The plugin deactivation class.
 *
 * @since 1.0.0
 */
class Deactivate implements ServiceInterface {
	/**
	 * Register the deactivation hook.
	 *
	 * @return void
	 * @since 1.0.0
	 */
	public function register(): void {
		register_deactivation_hook(NXTPDF_PATH, [$this, 'deactivate']);
	}

	/**
	 * Plugin deactivation handler.
	 *
	 * Flushes rewrite rules to clean up any custom routes or endpoints registered by the plugin.
	 * This ensures that the WordPress rewrite system is reset upon plugin deactivation.
	 *
	 * @return void
	 * @since 1.0.0
	 */
	public function deactivate(): void {
		TempDir::cleanup();

		// Uncomment if plugin registers custom post types or taxonomies
		// flush_rewrite_rules();
	}
}
