Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Ddeboer\Imap; |
| 6 | |
| 7 | use DateTimeInterface; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 8 | use Ddeboer\Imap\Message\PartInterface; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 9 | use Ddeboer\Imap\Search\ConditionInterface; |
| 10 | |
| 11 | /** |
| 12 | * An IMAP mailbox (commonly referred to as a 'folder'). |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 13 | * |
| 14 | * @extends \IteratorAggregate<int, MessageInterface> |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 15 | */ |
| 16 | interface MailboxInterface extends \Countable, \IteratorAggregate |
| 17 | { |
| 18 | /** |
| 19 | * Get mailbox decoded name. |
| 20 | */ |
| 21 | public function getName(): string; |
| 22 | |
| 23 | /** |
| 24 | * Get mailbox encoded path. |
| 25 | */ |
| 26 | public function getEncodedName(): string; |
| 27 | |
| 28 | /** |
| 29 | * Get mailbox encoded full name. |
| 30 | */ |
| 31 | public function getFullEncodedName(): string; |
| 32 | |
| 33 | /** |
| 34 | * Get mailbox attributes. |
| 35 | */ |
| 36 | public function getAttributes(): int; |
| 37 | |
| 38 | /** |
| 39 | * Get mailbox delimiter. |
| 40 | */ |
| 41 | public function getDelimiter(): string; |
| 42 | |
| 43 | /** |
| 44 | * Get Mailbox status. |
| 45 | */ |
| 46 | public function getStatus(int $flags = null): \stdClass; |
| 47 | |
| 48 | /** |
| 49 | * Bulk Set Flag for Messages. |
| 50 | * |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 51 | * @param string $flag \Seen, \Answered, \Flagged, \Deleted, and \Draft |
| 52 | * @param array<int, int|string>|MessageIterator|string $numbers Message numbers |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 53 | */ |
| 54 | public function setFlag(string $flag, $numbers): bool; |
| 55 | |
| 56 | /** |
| 57 | * Bulk Clear Flag for Messages. |
| 58 | * |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 59 | * @param string $flag \Seen, \Answered, \Flagged, \Deleted, and \Draft |
| 60 | * @param array<int, int|string>|MessageIterator|string $numbers Message numbers |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 61 | */ |
| 62 | public function clearFlag(string $flag, $numbers): bool; |
| 63 | |
| 64 | /** |
| 65 | * Get message ids. |
| 66 | * |
| 67 | * @param ConditionInterface $search Search expression (optional) |
| 68 | */ |
| 69 | public function getMessages(ConditionInterface $search = null, int $sortCriteria = null, bool $descending = false, string $charset = null): MessageIteratorInterface; |
| 70 | |
| 71 | /** |
| 72 | * Get message iterator for a sequence. |
| 73 | * |
| 74 | * @param string $sequence Message numbers |
| 75 | */ |
| 76 | public function getMessageSequence(string $sequence): MessageIteratorInterface; |
| 77 | |
| 78 | /** |
| 79 | * Get a message by message number. |
| 80 | * |
| 81 | * @param int $number Message number |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 82 | * |
| 83 | * @return MessageInterface<PartInterface> |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 84 | */ |
| 85 | public function getMessage(int $number): MessageInterface; |
| 86 | |
| 87 | /** |
| 88 | * Get messages in this mailbox. |
| 89 | */ |
| 90 | public function getIterator(): MessageIteratorInterface; |
| 91 | |
| 92 | /** |
| 93 | * Add a message to the mailbox. |
| 94 | */ |
| 95 | public function addMessage(string $message, string $options = null, DateTimeInterface $internalDate = null): bool; |
| 96 | |
| 97 | /** |
| 98 | * Returns a tree of threaded message for the current Mailbox. |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 99 | * |
| 100 | * @return array<string, int> |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 101 | */ |
| 102 | public function getThread(): array; |
| 103 | |
| 104 | /** |
| 105 | * Bulk move messages. |
| 106 | * |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 107 | * @param array<int, int|string>|MessageIterator|string $numbers Message numbers |
| 108 | * @param MailboxInterface $mailbox Destination Mailbox to move the messages to |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 109 | * |
| 110 | * @throws \Ddeboer\Imap\Exception\MessageMoveException |
| 111 | */ |
| 112 | public function move($numbers, self $mailbox): void; |
| 113 | |
| 114 | /** |
| 115 | * Bulk copy messages. |
| 116 | * |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 117 | * @param array<int, int|string>|MessageIterator|string $numbers Message numbers |
| 118 | * @param MailboxInterface $mailbox Destination Mailbox to copy the messages to |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 119 | * |
| 120 | * @throws \Ddeboer\Imap\Exception\MessageCopyException |
| 121 | */ |
| 122 | public function copy($numbers, self $mailbox): void; |
| 123 | } |