1 | <?php |
||
16 | class WritableMimePart |
||
17 | { |
||
18 | /** |
||
19 | * @var \ZBateson\MailMimeParser\Message\Writer\MimePartWriter the part |
||
20 | * writer for this MimePart |
||
21 | */ |
||
22 | protected $partWriter = null; |
||
23 | |||
24 | /** |
||
25 | * Registers the passed part as a child of the current part. |
||
26 | * |
||
27 | * If the $position parameter is non-null, adds the part at the passed |
||
28 | * position index. |
||
29 | * |
||
30 | * @param \ZBateson\MailMimeParser\Message\Part\MimePart $part |
||
31 | * @param int $position |
||
32 | */ |
||
33 | public function addPart(MimePart $part, $position = null) |
||
40 | |||
41 | /** |
||
42 | * Removes the child part from this part and returns its position or |
||
43 | * null if it wasn't found. |
||
44 | * |
||
45 | * Note that if the part is not a direct child of this part, the returned |
||
46 | * position is its index within its parent (calls removePart on its direct |
||
47 | * parent). |
||
48 | * |
||
49 | * @param \ZBateson\MailMimeParser\Message\Part\MimePart $part |
||
50 | * @return int or null if not found |
||
51 | */ |
||
52 | public function removePart(MimePart $part) |
||
66 | |||
67 | /** |
||
68 | * Removes all parts that are matched by the passed PartFilter. |
||
69 | * |
||
70 | * @param \ZBateson\MailMimeParser\Message\PartFilter $filter |
||
71 | */ |
||
72 | public function removeAllParts(PartFilter $filter = null) |
||
78 | |||
79 | |||
80 | /** |
||
81 | * Attaches the resource handle for the part's content. The attached handle |
||
82 | * is closed when the MimePart object is destroyed. |
||
83 | * |
||
84 | * @param resource $contentHandle |
||
85 | */ |
||
86 | public function attachContentResourceHandle($contentHandle) |
||
93 | |||
94 | /** |
||
95 | * Attaches the resource handle representing the original stream that |
||
96 | * created this part (including any sub-parts). The attached handle is |
||
97 | * closed when the MimePart object is destroyed. |
||
98 | * |
||
99 | * This stream is not modified or changed as the part is changed and is only |
||
100 | * set during parsing in MessageParser. |
||
101 | * |
||
102 | * @param resource $handle |
||
103 | */ |
||
104 | public function attachOriginalStreamHandle($handle) |
||
111 | |||
112 | |||
113 | /** |
||
114 | * Detaches the content resource handle from this part but does not close |
||
115 | * it. |
||
116 | */ |
||
117 | protected function detachContentResourceHandle() |
||
121 | |||
122 | /** |
||
123 | * Sets the content of the part to the passed string (effectively creates |
||
124 | * a php://temp stream with the passed content and calls |
||
125 | * attachContentResourceHandle with the opened stream). |
||
126 | * |
||
127 | * @param string $string |
||
128 | */ |
||
129 | public function setContent($string) |
||
136 | |||
137 | |||
138 | /** |
||
139 | * Adds a header with the given $name and $value. |
||
140 | * |
||
141 | * Creates a new \ZBateson\MailMimeParser\Header\AbstractHeader object and |
||
142 | * registers it as a header. |
||
143 | * |
||
144 | * @param string $name |
||
145 | * @param string $value |
||
146 | */ |
||
147 | public function setRawHeader($name, $value) |
||
151 | |||
152 | /** |
||
153 | * Removes the header with the given name |
||
154 | * |
||
155 | * @param string $name |
||
156 | */ |
||
157 | public function removeHeader($name) |
||
161 | |||
162 | |||
163 | /** |
||
164 | * Sets the parent part. |
||
165 | * |
||
166 | * @param \ZBateson\MailMimeParser\Message\Part\MessagePart $part |
||
167 | */ |
||
168 | public function setParent(MessagePart $part) |
||
172 | } |
||
173 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: