/**
  * @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);
     }
 }
Example #2
0
 /**
  * Attach a provider to the chain.
  *
  * @param ProviderInterface $provider A ProviderInterface instance.
  */
 public function addProvider(ProviderInterface $provider)
 {
     $this->providers->attach($provider);
 }
Example #3
0
 /**
  * @param ProviderInterface $provider
  *
  * @return $this
  */
 public function removeProvider(ProviderInterface $provider)
 {
     $this->providers->removeElement($provider);
     return $this;
 }