public function valid()
{
if (!$this->isUsed) {
$this->call->addIterableEvent($this->callEventFactory->createUsed());
$this->isUsed = true;
}
$key = key($this->array);
$isValid = null !== $key;
if ($this->isConsumed) {
return $isValid;
}
if ($isValid) {
$this->call->addIterableEvent($this->callEventFactory->createProduced($key, current($this->array)));
} else {
$this->call->setEndEvent($this->callEventFactory->createConsumed());
$this->isConsumed = true;
}
return $isValid;
}