<?php
namespace boru\ai\Asset;

class AssetProviderRegistry
{
    /** @var AssetProviderInterface[] */
    protected $providers = array();

    public function register(AssetProviderInterface $provider)
    {
        $this->providers[$provider->providerName()] = $provider;
        return $this;
    }

    public function has($providerName)
    {
        return isset($this->providers[$providerName]);
    }

    public function get($providerName)
    {
        if (!$this->has($providerName)) {
            throw new \InvalidArgumentException('Unknown asset provider: ' . $providerName);
        }
        return $this->providers[$providerName];
    }

    public function all()
    {
        return $this->providers;
    }
}
