/**
  * Create a resource iterator
  *
  * @param CommandInterface $data    Command used for building the iterator
  * @param array            $options Iterator options.
  *
  * @return ResourceIteratorInterface
  */
 public function build($data, array $options = null)
 {
     if (!$data instanceof CommandInterface) {
         throw new InvalidArgumentException('The first argument must be an ' . 'instance of CommandInterface');
     }
     // Determine the name of the class to load
     $className = $this->baseNamespace . '\\' . Inflector::camel($data->getName()) . 'Iterator';
     return new $className($data, $options);
 }
 /**
  * {@inheritdoc}
  */
 public function factory($name, array $args = array())
 {
     // Determine the class to instantiate based on the namespace of the
     // current client and the default location of commands
     $prefix = $this->client->getConfig('command.prefix');
     if (!$prefix) {
         // The prefix can be specified in a factory method and is cached
         $prefix = implode('\\', array_slice(explode('\\', get_class($this->client)), 0, -1)) . '\\Command\\';
         $this->client->getConfig()->set('command.prefix', $prefix);
     }
     $class = $prefix . str_replace(' ', '\\', ucwords(str_replace('.', ' ', Inflector::camel($name))));
     // Create the concrete command if it exists
     if (class_exists($class)) {
         return new $class($args);
     }
 }