diff --git a/src/Connection/ImapQueryBuilder.php b/src/Connection/ImapQueryBuilder.php index 8b7a2cb..80db38f 100644 --- a/src/Connection/ImapQueryBuilder.php +++ b/src/Connection/ImapQueryBuilder.php @@ -173,6 +173,14 @@ public function keyword(string $value): static return $this->where(ImapSearchKey::Keyword, $value); } + /** + * Add a where "UNKEYWORD" clause to the query. + */ + public function unkeyword(string $value): static + { + return $this->where(ImapSearchKey::Unkeyword, $value); + } + /** * Add a where "ON" clause to the query. */ diff --git a/src/Enums/ImapSearchKey.php b/src/Enums/ImapSearchKey.php index 125a0be..1f8415d 100644 --- a/src/Enums/ImapSearchKey.php +++ b/src/Enums/ImapSearchKey.php @@ -26,6 +26,7 @@ enum ImapSearchKey: string case Deleted = 'DELETED'; case Flagged = 'FLAGGED'; case Keyword = 'KEYWORD'; + case Unkeyword = 'UNKEYWORD'; case Subject = 'SUBJECT'; case Smaller = 'SMALLER'; case Answered = 'ANSWERED'; diff --git a/tests/Unit/Connection/ImapQueryBuilderTest.php b/tests/Unit/Connection/ImapQueryBuilderTest.php index b686cf1..50a1e32 100644 --- a/tests/Unit/Connection/ImapQueryBuilderTest.php +++ b/tests/Unit/Connection/ImapQueryBuilderTest.php @@ -300,3 +300,11 @@ function (ImapQueryBuilder $q) { expect($builder->toImap())->toBe('LARGER 1024 SMALLER 1048576'); }); + +test('compiles KEYWORD condition', function () { + expect((new ImapQueryBuilder)->keyword('important')->toImap())->toBe('KEYWORD "important"'); +}); + +test('compiles UNKEYWORD condition', function () { + expect((new ImapQueryBuilder)->unkeyword('important')->toImap())->toBe('UNKEYWORD "important"'); +});