src/Knp/DictionaryBundle/Dictionary/Factory/Iterator.php
public function create(string $name, array $config): Dictionary
    {
        if (!isset($config['service'])) {
            throw new InvalidArgumentException(sprintf(
                'The "service" config key must be set for the dictionary named "%s".',
                $name
            ));
        }

        $service = $this->container->get($config['service']);

        if (false === $service instanceof Traversable) {
            throw new InvalidArgumentException(sprintf(
                'You must provide a valid instance of Traversable for the dictionary named "%s".',
                $name
            ));
        }

        return new Dictionary\Iterator($name, $callable);
    }
public function create(string $name, array $config): Dictionary
    {
        if (!isset($config['service'])) {
            throw new InvalidArgumentException(sprintf(
                'The "service" config key must be set for the dictionary named "%s".',
                $name
            ));
        }

        $service = $this->container->get($config['service']);

        if (false === $service instanceof Traversable) {
            throw new InvalidArgumentException(sprintf(
                'You must provide a valid instance of Traversable for the dictionary named "%s".',
                $name
            ));
        }

        return new Dictionary\Iterator($name, $callable);
    }
{@inheritdoc}

@throw InvalidArgumentException if there is some problem with the config.