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 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 7 | use Ddeboer\Imap\Exception\CreateMailboxException; |
| 8 | use Ddeboer\Imap\Exception\DeleteMailboxException; |
| 9 | use Ddeboer\Imap\Exception\InvalidResourceException; |
| 10 | use Ddeboer\Imap\Exception\MailboxDoesNotExistException; |
| 11 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 12 | /** |
| 13 | * A connection to an IMAP server that is authenticated for a user. |
| 14 | */ |
| 15 | interface ConnectionInterface extends \Countable |
| 16 | { |
| 17 | /** |
| 18 | * Get IMAP resource. |
| 19 | */ |
| 20 | public function getResource(): ImapResourceInterface; |
| 21 | |
| 22 | /** |
| 23 | * Delete all messages marked for deletion. |
| 24 | */ |
| 25 | public function expunge(): bool; |
| 26 | |
| 27 | /** |
| 28 | * Close connection. |
| 29 | */ |
| 30 | public function close(int $flag = 0): bool; |
| 31 | |
| 32 | /** |
| 33 | * Check if the connection is still active. |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 34 | * |
| 35 | * @throws InvalidResourceException If connection was closed |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 36 | */ |
| 37 | public function ping(): bool; |
| 38 | |
| 39 | /** |
| 40 | * Get Mailbox quota. |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 41 | * |
| 42 | * @return array<string, int> |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 43 | */ |
| 44 | public function getQuota(string $root = 'INBOX'): array; |
| 45 | |
| 46 | /** |
| 47 | * Get a list of mailboxes (also known as folders). |
| 48 | * |
| 49 | * @return MailboxInterface[] |
| 50 | */ |
| 51 | public function getMailboxes(): array; |
| 52 | |
| 53 | /** |
| 54 | * Check that a mailbox with the given name exists. |
| 55 | * |
| 56 | * @param string $name Mailbox name |
| 57 | */ |
| 58 | public function hasMailbox(string $name): bool; |
| 59 | |
| 60 | /** |
| 61 | * Get a mailbox by its name. |
| 62 | * |
| 63 | * @param string $name Mailbox name |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 64 | * |
| 65 | * @throws MailboxDoesNotExistException If mailbox does not exist |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 66 | */ |
| 67 | public function getMailbox(string $name): MailboxInterface; |
| 68 | |
| 69 | /** |
| 70 | * Create mailbox. |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 71 | * |
| 72 | * @throws CreateMailboxException |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 73 | */ |
| 74 | public function createMailbox(string $name): MailboxInterface; |
| 75 | |
| 76 | /** |
| 77 | * Delete mailbox. |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 78 | * |
| 79 | * @throws DeleteMailboxException |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 80 | */ |
| 81 | public function deleteMailbox(MailboxInterface $mailbox): void; |
| 82 | } |