<?php

namespace NoahVet\Reef\Phpunit\RabbitMQ\Producer\Factory;

use NoahVet\Reef\Phpunit\RabbitMQ\Producer\MockedMQProducer;
use NoahVet\Reef\RabbitMQ\Producer\Factory\ReefMQProducerFactoryInterface;
use NoahVet\Reef\RabbitMQ\Producer\ReefMQProducerInterface;

class MockedMQProducerFactory implements ReefMQProducerFactoryInterface
{
    protected ?MockedMQProducer $mockedMQProducer = null;

    #[\Override]
    public function createAppProducer(string $appName): ReefMQProducerInterface
    {
        return new MockedMQProducer();
    }

    #[\Override]
    public function getProducer(): ReefMQProducerInterface
    {
        if (null === $this->mockedMQProducer) {
            $this->mockedMQProducer = new MockedMQProducer();
        }

        return $this->mockedMQProducer;
    }
}
