blob: 067bdc288841e0023f9668137261d53646156f45 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2
3declare(strict_types=1);
4
5namespace Ddeboer\Imap;
6
7use DateTimeInterface;
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02008use Ddeboer\Imap\Message\PartInterface;
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01009use Ddeboer\Imap\Search\ConditionInterface;
10
11/**
12 * An IMAP mailbox (commonly referred to as a 'folder').
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020013 *
14 * @extends \IteratorAggregate<int, MessageInterface>
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010015 */
16interface 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 Benkard7b2a3a12021-08-16 10:57:25 +020051 * @param string $flag \Seen, \Answered, \Flagged, \Deleted, and \Draft
52 * @param array<int, int|string>|MessageIterator|string $numbers Message numbers
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010053 */
54 public function setFlag(string $flag, $numbers): bool;
55
56 /**
57 * Bulk Clear Flag for Messages.
58 *
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020059 * @param string $flag \Seen, \Answered, \Flagged, \Deleted, and \Draft
60 * @param array<int, int|string>|MessageIterator|string $numbers Message numbers
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010061 */
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 Benkard7b2a3a12021-08-16 10:57:25 +020082 *
83 * @return MessageInterface<PartInterface>
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010084 */
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 Benkard7b2a3a12021-08-16 10:57:25 +020099 *
100 * @return array<string, int>
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100101 */
102 public function getThread(): array;
103
104 /**
105 * Bulk move messages.
106 *
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200107 * @param array<int, int|string>|MessageIterator|string $numbers Message numbers
108 * @param MailboxInterface $mailbox Destination Mailbox to move the messages to
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100109 *
110 * @throws \Ddeboer\Imap\Exception\MessageMoveException
111 */
112 public function move($numbers, self $mailbox): void;
113
114 /**
115 * Bulk copy messages.
116 *
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200117 * @param array<int, int|string>|MessageIterator|string $numbers Message numbers
118 * @param MailboxInterface $mailbox Destination Mailbox to copy the messages to
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100119 *
120 * @throws \Ddeboer\Imap\Exception\MessageCopyException
121 */
122 public function copy($numbers, self $mailbox): void;
123}