-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathMessageQueryInterface.php
More file actions
298 lines (243 loc) · 7.73 KB
/
MessageQueryInterface.php
File metadata and controls
298 lines (243 loc) · 7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php
namespace DirectoryTree\ImapEngine;
use BackedEnum;
use DirectoryTree\ImapEngine\Collections\MessageCollection;
use DirectoryTree\ImapEngine\Connection\ImapQueryBuilder;
use DirectoryTree\ImapEngine\Enums\ImapFetchIdentifier;
use DirectoryTree\ImapEngine\Enums\ImapSortKey;
use DirectoryTree\ImapEngine\Pagination\LengthAwarePaginator;
/**
* @mixin ImapQueryBuilder
*/
interface MessageQueryInterface
{
/**
* Don't mark messages as read when fetching.
*/
public function leaveUnread(): MessageQueryInterface;
/**
* Mark all messages as read when fetching.
*/
public function markAsRead(): MessageQueryInterface;
/**
* Set the limit and page for the current query.
*/
public function limit(int $limit, int $page = 1): MessageQueryInterface;
/**
* Get the set fetch limit.
*/
public function getLimit(): ?int;
/**
* Set the fetch limit.
*/
public function setLimit(int $limit): MessageQueryInterface;
/**
* Get the set page.
*/
public function getPage(): int;
/**
* Set the page.
*/
public function setPage(int $page): MessageQueryInterface;
/**
* Determine if the body of messages is being fetched.
*/
public function isFetchingBody(): bool;
/**
* Determine if the flags of messages is being fetched.
*/
public function isFetchingFlags(): bool;
/**
* Determine if the headers of messages is being fetched.
*/
public function isFetchingHeaders(): bool;
/**
* Determine if the size of messages is being fetched.
*/
public function isFetchingSize(): bool;
/**
* Determine if the body structure of messages is being fetched.
*/
public function isFetchingBodyStructure(): bool;
/**
* Fetch the flags of messages.
*/
public function withFlags(): MessageQueryInterface;
/**
* Fetch the body of messages.
*/
public function withBody(): MessageQueryInterface;
/**
* Fetch the headers of messages.
*/
public function withHeaders(): MessageQueryInterface;
/**
* Fetch the size of messages.
*/
public function withSize(): MessageQueryInterface;
/**
* Fetch the body structure of messages.
*/
public function withBodyStructure(): MessageQueryInterface;
/**
* Don't fetch the body of messages.
*/
public function withoutBody(): MessageQueryInterface;
/**
* Don't fetch the headers of messages.
*/
public function withoutHeaders(): MessageQueryInterface;
/**
* Don't fetch the flags of messages.
*/
public function withoutFlags(): MessageQueryInterface;
/**
* Don't fetch the size of messages.
*/
public function withoutSize(): MessageQueryInterface;
/**
* Don't fetch the body structure of messages.
*/
public function withoutBodyStructure(): MessageQueryInterface;
/**
* Set the fetch order.
*/
public function setFetchOrder(string $fetchOrder): MessageQueryInterface;
/**
* Get the fetch order.
*/
public function getFetchOrder(): string;
/**
* Set the fetch order to 'ascending'.
*/
public function setFetchOrderAsc(): MessageQueryInterface;
/**
* Set the fetch order to 'descending'.
*/
public function setFetchOrderDesc(): MessageQueryInterface;
/**
* Set the fetch order to show oldest messages first (ascending).
*/
public function oldest(): MessageQueryInterface;
/**
* Set the fetch order to show newest messages first (descending).
*/
public function newest(): MessageQueryInterface;
/**
* Set the sort key for server-side sorting (RFC 5256).
*/
public function setSortKey(ImapSortKey|string|null $key): MessageQueryInterface;
/**
* Get the sort key for server-side sorting.
*/
public function getSortKey(): ?ImapSortKey;
/**
* Set the sort direction for server-side sorting.
*/
public function setSortDirection(string $direction): MessageQueryInterface;
/**
* Get the sort direction for server-side sorting.
*/
public function getSortDirection(): string;
/**
* Sort messages by a field using server-side sorting (RFC 5256).
*/
public function sortBy(ImapSortKey|string $key, string $direction = 'asc'): MessageQueryInterface;
/**
* Sort messages by a field in descending order using server-side sorting.
*/
public function sortByDesc(ImapSortKey|string $key): MessageQueryInterface;
/**
* Count all available messages matching the current search criteria.
*/
public function count(): int;
/**
* Get the first message in the resulting collection.
*/
public function first(): ?MessageInterface;
/**
* Get the first message in the resulting collection or throw an exception.
*/
public function firstOrFail(): MessageInterface;
/**
* Get the messages matching the current query.
*/
public function get(): MessageCollection;
/**
* Append a new message to the folder.
*/
public function append(string $message, mixed $flags = null): int;
/**
* Execute a callback over each message via a chunked query.
*/
public function each(callable $callback, int $chunkSize = 10, int $startChunk = 1): void;
/**
* Execute a callback over each chunk of messages.
*/
public function chunk(callable $callback, int $chunkSize = 10, int $startChunk = 1): void;
/**
* Paginate the current query.
*/
public function paginate(int $perPage = 5, $page = null, string $pageName = 'page'): LengthAwarePaginator;
/**
* Find a message by the given identifier type or throw an exception.
*/
public function findOrFail(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid): MessageInterface;
/**
* Find a message by the given identifier type.
*/
public function find(int $id, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid): ?MessageInterface;
/**
* Destroy the given messages.
*/
public function destroy(array|int $uids, bool $expunge = false): void;
/**
* Add or remove a flag from all messages matching the current query.
*
* @param string $operation '+'|'-'
* @return int The number of messages affected.
*/
public function flag(BackedEnum|string $flag, string $operation, bool $expunge = false): int;
/**
* Mark all messages matching the current query as read.
*
* @return int The number of messages affected.
*/
public function markRead(): int;
/**
* Mark all messages matching the current query as unread.
*
* @return int The number of messages affected.
*/
public function markUnread(): int;
/**
* Mark all messages matching the current query as flagged.
*
* @return int The number of messages affected.
*/
public function markFlagged(): int;
/**
* Unmark all messages matching the current query as flagged.
*
* @return int The number of messages affected.
*/
public function unmarkFlagged(): int;
/**
* Delete all messages matching the current query.
*
* @return int The number of messages affected.
*/
public function delete(bool $expunge = false): int;
/**
* Move all messages matching the current query to the given folder.
*
* @return int The number of messages affected.
*/
public function move(string $folder, bool $expunge = false): int;
/**
* Copy all messages matching the current query to the given folder.
*
* @return int The number of messages affected.
*/
public function copy(string $folder): int;
}