<?php

declare(strict_types=1);

namespace App\SuperAdmin\Infrastructure\Security;

use App\Shared\Domain\Tenant\TenantId;

/**
 * Stores the currently selected tenant for a Super Admin session.
 *
 * When a Super Admin switches to an establishment context,
 * they get ROLE_ADMIN rights within that tenant scope.
 */
final class SuperAdminTenantContext
{
    private ?TenantId $currentTenantId = null;

    public function switchTo(TenantId $tenantId): void
    {
        $this->currentTenantId = $tenantId;
    }

    public function currentTenantId(): ?TenantId
    {
        return $this->currentTenantId;
    }

    public function hasTenant(): bool
    {
        return $this->currentTenantId !== null;
    }

    public function clear(): void
    {
        $this->currentTenantId = null;
    }
}
