Skip to content

Add sole() to message queries - #218

Merged
stevebauman merged 1 commit into
masterfrom
feature/message-query-sole
Nov 25, 2026
Merged

stevebauman merged 1 commit into
masterfrom
feature/message-query-sole

Conversation

@stevebauman

Copy link
Copy Markdown
Member

When you look up an email by its Message-ID and expect a single match, sole() lets you enforce that expectation in the query.

$message = $mailbox->inbox()->messages()->messageId($messageId)->sole();

sole() returns the message when exactly one match is available. It throws ItemNotFoundException when there are no matches and MultipleItemsFoundException when it finds a second. It checks the full filtered query regardless of pagination and fetches messages in batches of two as needed.

Custom implementations of MessageQueryInterface need to implement sole().

@stevebauman
stevebauman merged commit 406ea50 into master Nov 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant