/** * @param ProviderInterface[] $providers */ public function __construct(array $providers) { $this->providers = new \SplObjectStorage(); foreach ($providers as $provider) { if (!$provider instanceof ProviderInterface) { throw new \RuntimeException(sprintf('"%s" is not a valid provder!', get_class($provider))); } $this->providers->attach($provider); } }
/** * Attach a provider to the chain. * * @param ProviderInterface $provider A ProviderInterface instance. */ public function addProvider(ProviderInterface $provider) { $this->providers->attach($provider); }