<?php
/**
 * Deactivation handler.
 *
 * @package Carticy\Conversions\Core
 */

declare(strict_types=1);

namespace Carticy\Conversions\Core;

use Carticy\Conversions\Privacy\PrivacyService;

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

/**
 * Handles deactivation tasks.
 */
final class Deactivator {

	/**
	 * Run deactivation tasks.
	 */
	public static function deactivate(): void {
		PrivacyService::unschedule_retention();

		// Literal hook names: the queue class lives in the stripped premium
		// path, so the free build cannot reference its constants. Clearing a
		// never-scheduled hook is a no-op.
		if ( function_exists( 'wp_clear_scheduled_hook' ) ) {
			wp_clear_scheduled_hook( 'carticy_conversions_process_server_dispatch_queue' );
			wp_clear_scheduled_hook( 'carticy_conversions_server_dispatch_sweep' );
		}

		if ( function_exists( 'wc_get_logger' ) ) {
			wc_get_logger()->info(
				'Carticy Conversions deactivated',
				array( 'source' => 'carticy-conversions' )
			);
		}
	}
}
