/** {@inheritdoc} */ public function getIterator() { /** @var \Iterator $iterator */ $iterator = null; do { $this->stopwatch->start($this->client, 'rpc_response'); if (null === $iterator) { if ($this->collection instanceof \IteratorAggregate) { $iterator = $this->collection->getIterator(); } elseif ($this->collection instanceof \Iterator) { $iterator = $this->collection; } $iterator->rewind(); } $value = $iterator->current(); $this->stopwatch->start($this->client, 'rpc_response'); $iterator->next(); (yield $value); } while ($iterator->valid()); }