<?php

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Manager;

use CpCreation\VitiCore\Bridge\Symfony\Bundle\Provider\SocialNetwork\SocialNetworkProviderInterface;

final class SocialNetworkProviderManager
{
    /** @var list<SocialNetworkProviderInterface> */
    private array $providers = [];

    public function addProvider(SocialNetworkProviderInterface $provider): void
    {
        $this->providers[] = $provider;
    }

    /**
     * @throws \RuntimeException
     */
    public function getMedias(string $network, int $count): mixed
    {
        foreach ($this->providers as $provider) {
            if ($provider->getNetwork() === $network) {
                return $provider->getMedias($count);
            }
        }

        throw new \RuntimeException('Pas de provider de réseau social trouvé');
    }
}
