Skip to content

Commit 1c5c94c

Browse files
authored
Merge pull request #148 from DirectoryTree/unkeyword
Add unkeyword support
2 parents 8ca11d5 + 469b0c4 commit 1c5c94c

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/Connection/ImapQueryBuilder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ public function keyword(string $value): static
173173
return $this->where(ImapSearchKey::Keyword, $value);
174174
}
175175

176+
/**
177+
* Add a where "UNKEYWORD" clause to the query.
178+
*/
179+
public function unkeyword(string $value): static
180+
{
181+
return $this->where(ImapSearchKey::Unkeyword, $value);
182+
}
183+
176184
/**
177185
* Add a where "ON" clause to the query.
178186
*/

src/Enums/ImapSearchKey.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum ImapSearchKey: string
2626
case Deleted = 'DELETED';
2727
case Flagged = 'FLAGGED';
2828
case Keyword = 'KEYWORD';
29+
case Unkeyword = 'UNKEYWORD';
2930
case Subject = 'SUBJECT';
3031
case Smaller = 'SMALLER';
3132
case Answered = 'ANSWERED';

tests/Unit/Connection/ImapQueryBuilderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,11 @@ function (ImapQueryBuilder $q) {
300300

301301
expect($builder->toImap())->toBe('LARGER 1024 SMALLER 1048576');
302302
});
303+
304+
test('compiles KEYWORD condition', function () {
305+
expect((new ImapQueryBuilder)->keyword('important')->toImap())->toBe('KEYWORD "important"');
306+
});
307+
308+
test('compiles UNKEYWORD condition', function () {
309+
expect((new ImapQueryBuilder)->unkeyword('important')->toImap())->toBe('UNKEYWORD "important"');
310+
});

0 commit comments

Comments
 (0)