1 | <?php |
||
24 | class PartStreamRegistry |
||
25 | { |
||
26 | /** |
||
27 | * @var array Array of handles, with message IDs as keys. |
||
28 | */ |
||
29 | private $registeredHandles; |
||
30 | |||
31 | /** |
||
32 | * @var int[] number of registered part stream handles with message IDs as |
||
33 | * keys |
||
34 | */ |
||
35 | private $numRefCountsForHandles; |
||
36 | |||
37 | /** |
||
38 | * Registers an ID for the passed resource handle. |
||
39 | * |
||
40 | * @param string $id |
||
41 | * @param resource $handle |
||
42 | */ |
||
43 | 1 | public function register($id, $handle) |
|
50 | |||
51 | /** |
||
52 | * Unregisters the given message ID and closes the associated resource |
||
53 | * handle. |
||
54 | * |
||
55 | * @param string $id |
||
56 | */ |
||
57 | 1 | protected function unregister($id) |
|
62 | |||
63 | /** |
||
64 | * Increases the reference count for streams using the resource handle |
||
65 | * associated with the message id. |
||
66 | * |
||
67 | * @param int $messageId |
||
68 | */ |
||
69 | 1 | public function increaseHandleRefCount($messageId) |
|
73 | |||
74 | /** |
||
75 | * Decreases the reference count for streams using the resource handle |
||
76 | * associated with the message id. Once the reference count hits 0, |
||
77 | * unregister is called. |
||
78 | * |
||
79 | * @param int $messageId |
||
80 | */ |
||
81 | 1 | public function decreaseHandleRefCount($messageId) |
|
88 | |||
89 | /** |
||
90 | * Returns the resource handle with the passed $id. |
||
91 | * |
||
92 | * @param string $id |
||
93 | * @return resource |
||
94 | */ |
||
95 | 1 | public function get($id) |
|
102 | |||
103 | /** |
||
104 | * Attaches a stream filter on the passed resource $handle for the part's |
||
105 | * encoding. |
||
106 | * |
||
107 | * @param \ZBateson\MailMimeParser\Message\MimePart $part |
||
108 | * @param resource $handle |
||
109 | */ |
||
110 | private function attachEncodingFilterToStream(MimePart $part, $handle) |
||
130 | |||
131 | /** |
||
132 | * Attaches a mailmimeparser-encode stream filter based on the part's |
||
133 | * defined charset. |
||
134 | * |
||
135 | * @param \ZBateson\MailMimeParser\Message\MimePart $part |
||
136 | * @param resource $handle |
||
137 | */ |
||
138 | private function attachCharsetFilterToStream(MimePart $part, $handle) |
||
149 | |||
150 | /** |
||
151 | * Creates a part stream handle for the start and end position of the |
||
152 | * message stream, and attaches it to the passed MimePart. |
||
153 | * |
||
154 | * @param MimePart $part |
||
155 | * @param Message $message |
||
156 | * @param int $start |
||
157 | * @param int $end |
||
158 | */ |
||
159 | public function attachContentPartStreamHandle(MimePart $part, Message $message, $start, $end) |
||
172 | |||
173 | /** |
||
174 | * Creates a part stream handle for the start and end position of the |
||
175 | * message stream, and attaches it to the passed MimePart. |
||
176 | * |
||
177 | * @param MimePart $part |
||
178 | * @param Message $message |
||
179 | * @param int $start |
||
180 | * @param int $end |
||
181 | */ |
||
182 | public function attachOriginalPartStreamHandle(MimePart $part, Message $message, $start, $end) |
||
193 | } |
||
194 |