<?php

namespace NoahVet\Reef\Security\Policy;

use NoahVet\Reef\Application\Security\UseCase\BatchSyncPoliciesUseCaseInterface;
use NoahVet\Reef\Application\Security\UseCase\ExecutePoliciesUseCase;
use NoahVet\Reef\Application\Security\UseCase\SyncPoliciesUseCaseInterface;
use NoahVet\Reef\Domain\Security\Port\PolicyResultPublisherInterface;

/**
 * @deprecated inject SyncPoliciesUseCase / BatchSyncPoliciesUseCase directly instead
 */
class PolicyManagerFactory
{
    private PolicyResultPublisherInterface $policyResultPublisher;

    private SyncPoliciesUseCaseInterface $syncPoliciesUseCase;

    private BatchSyncPoliciesUseCaseInterface $batchSyncPoliciesUseCase;

    private ExecutePoliciesUseCase $executePoliciesUseCase;

    public function __construct(
        PolicyResultPublisherInterface $policyResultPublisher,
        SyncPoliciesUseCaseInterface $syncPoliciesUseCase,
        BatchSyncPoliciesUseCaseInterface $batchSyncPoliciesUseCase,
        ExecutePoliciesUseCase $executePoliciesUseCase,
    ) {
        $this->policyResultPublisher = $policyResultPublisher;
        $this->syncPoliciesUseCase = $syncPoliciesUseCase;
        $this->batchSyncPoliciesUseCase = $batchSyncPoliciesUseCase;
        $this->executePoliciesUseCase = $executePoliciesUseCase;
    }

    public function create(string $bearer): PolicyManager
    {
        return new PolicyManager(
            $this->policyResultPublisher,
            $this->syncPoliciesUseCase,
            $this->batchSyncPoliciesUseCase,
            $this->executePoliciesUseCase,
        );
    }
}
