Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\DependencyInjection\Argument; Chris@14: Chris@14: use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; Chris@14: use Symfony\Component\DependencyInjection\Reference; Chris@14: Chris@14: /** Chris@14: * Represents a collection of values to lazily iterate over. Chris@14: * Chris@14: * @author Titouan Galopin Chris@14: */ Chris@14: class IteratorArgument implements ArgumentInterface Chris@14: { Chris@14: private $values; Chris@14: Chris@14: /** Chris@14: * @param Reference[] $values Chris@14: */ Chris@14: public function __construct(array $values) Chris@14: { Chris@14: $this->setValues($values); Chris@14: } Chris@14: Chris@14: /** Chris@14: * @return array The values to lazily iterate over Chris@14: */ Chris@14: public function getValues() Chris@14: { Chris@14: return $this->values; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @param Reference[] $values The service references to lazily iterate over Chris@14: */ Chris@14: public function setValues(array $values) Chris@14: { Chris@14: foreach ($values as $k => $v) { Chris@14: if (null !== $v && !$v instanceof Reference) { Chris@17: throw new InvalidArgumentException(sprintf('An IteratorArgument must hold only Reference instances, "%s" given.', \is_object($v) ? \get_class($v) : \gettype($v))); Chris@14: } Chris@14: } Chris@14: Chris@14: $this->values = $values; Chris@14: } Chris@14: }