parseMany($responses) as $summary) { if ($message !== null) { throw new ImapException('FETCH returned multiple messages for a single-message request.'); } $message = $summary; } if ($message === null) { throw new ImapException('FETCH did not return a message summary.'); } return $message; } /** * @return Generator */ public function parseMany(ResponseStream $responses): Generator { foreach ($responses as $response) { if ($response instanceof UntaggedResponse && MessageParser::isFetchMessage($response->payload())) { yield MessageParser::parse($response->raw()); continue; } if ($response instanceof TaggedResponse) { if (!$response->isOk()) { throw new ImapException('FETCH failed: ' . $response->text()); } return; } } throw new ImapException('FETCH did not receive a tagged completion response.'); } }