<?php

namespace NoahVet\Reef\Security\IAM\TokenExchange;

use NoahVet\Reef\Security\Token\JWTDecoderInterface;
use Psr\Cache\CacheItemPoolInterface;

class CachedTokenExchangerFactory
{
    public function __construct(
        protected readonly CacheItemPoolInterface $cache,
        protected readonly DirectTokenExchanger $directTokenExchanger,
        protected readonly JWTDecoderInterface $JWTDecoder,
        protected readonly string $reefClientId,
    ) {
    }

    public function createCachedTokenExchanger(): TokenExchangerInterface
    {
        return new CachedTokenExchangerDecorator(
            $this->cache,
            $this->JWTDecoder,
            $this->reefClientId,
            $this->directTokenExchanger,
        );
    }
}
