blob: 6289339a7af3113dbcce5596cc0ef66f35a32767 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2
3declare(strict_types=1);
4
5namespace Ddeboer\Imap;
6
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02007use Ddeboer\Imap\Exception\CreateMailboxException;
8use Ddeboer\Imap\Exception\DeleteMailboxException;
9use Ddeboer\Imap\Exception\InvalidResourceException;
10use Ddeboer\Imap\Exception\MailboxDoesNotExistException;
11
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010012/**
13 * A connection to an IMAP server that is authenticated for a user.
14 */
15interface 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 Benkard7b2a3a12021-08-16 10:57:25 +020034 *
35 * @throws InvalidResourceException If connection was closed
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010036 */
37 public function ping(): bool;
38
39 /**
40 * Get Mailbox quota.
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020041 *
42 * @return array<string, int>
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010043 */
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 Benkard7b2a3a12021-08-16 10:57:25 +020064 *
65 * @throws MailboxDoesNotExistException If mailbox does not exist
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010066 */
67 public function getMailbox(string $name): MailboxInterface;
68
69 /**
70 * Create mailbox.
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020071 *
72 * @throws CreateMailboxException
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010073 */
74 public function createMailbox(string $name): MailboxInterface;
75
76 /**
77 * Delete mailbox.
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020078 *
79 * @throws DeleteMailboxException
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010080 */
81 public function deleteMailbox(MailboxInterface $mailbox): void;
82}