<?php

/**
 * LolaCore — Hub Revocation Service
 *
 * @package LolaCore
 * @license GPL-2.0-or-later
 */

declare(strict_types=1);

namespace LolaCore\Hub;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Sovereign disconnect from the child site: master identity, scope, and fleet memory metadata.
 */
final class HubRevocationService
{
    public function __construct(
        private ?PairingRegistrar $pairing = null,
        private ?HubScope $scope = null,
        private ?HubMemoryTransparency $memory = null,
    ) {
        $this->pairing = $pairing ?? new PairingRegistrar();
        $this->scope   = $scope ?? new HubScope();
        $this->memory  = $memory ?? new HubMemoryTransparency();
    }

    /**
     * Disconnect the master immediately. The next remote order is rejected (no identity).
     */
    public function disconnect(): void
    {
        $this->pairing->disconnect();
        $this->scope->clearAll();
        $this->memory->clearReconcileMetadata();
    }
}
