refactor: unify command complition checking

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-09-25 12:14:37 -04:00
parent 1b68c99521
commit 6a36e91cb4
21 changed files with 132 additions and 80 deletions
+7 -6
View File
@@ -129,9 +129,12 @@ final class ProtocolReader
if (str_starts_with($trimmed, $tag . ' ')) {
$parts = preg_split('/\s+/', $trimmed, 3) ?: [];
$status = strtoupper($parts[1] ?? '');
if ($status === 'NO' || $status === 'BAD') {
throw new ImapException(sprintf('FETCH command failed: %s', $trimmed));
}
CompletionChecker::assertSuccess('FETCH', new TaggedResponse(
$tag,
$status,
$parts[2] ?? '',
$trimmed,
));
return null; // Tagged OK without ever finding a literal → UID not found
}
@@ -145,9 +148,7 @@ final class ProtocolReader
$response = $this->readResponse();
if ($response instanceof TaggedResponse && $response->tag() === $tag) {
if (!$response->isOk()) {
throw new ImapException(sprintf('FETCH failed: %s', $response->text()));
}
CompletionChecker::assertSuccess('FETCH', $response);
return $response;
}
}