*/ public function getChildIterator() : RecursiveIterator; /** * Returns the part that has a content type matching the passed mime type at * the given index, or null if there are no matching parts. * * Creates a filter that looks at the return value of * {@see IMessagePart::getContentType()} for all parts (including the * current part) and returns a matching one at the given 0-based index. * * @see IMultiPart::getAllPartsByMimeType() to get all parts that match a * mime type. * @see IMultiPart::getCountOfPartsByMimeType() to get a count of parts with * a mime type. * @param string $mimeType The mime type to find. * @param int $index Optional 0-based index (defaulting to '0'). * @return IMessagePart|null The part. */ public function getPartByMimeType(string $mimeType, int $index = 0) : ?IMessagePart; /** * Returns an array of all parts that have a content type matching the * passed mime type. * * Creates a filter that looks at the return value of * {@see IMessagePart::getContentType()} for all parts (including the * current part), returning an array of matching parts. * * @see IMultiPart::getPartByMimeType() to get a part by mime type. * @see IMultiPart::getCountOfPartsByMimeType() to get a count of parts with * a mime type. * @param string $mimeType The mime type to find. * @return IMessagePart[] An array of matching parts. */ public function getAllPartsByMimeType(string $mimeType) : array; /** * Returns the number of parts that have content types matching the passed * mime type. * * @see IMultiPart::getPartByMimeType() to get a part by mime type. * @see IMultiPart::getAllPartsByMimeType() to get all parts that match a * mime type. * @param string $mimeType The mime type to find. * @return int The number of matching parts. */ public function getCountOfPartsByMimeType(string $mimeType) : int; /** * Returns a part that has the given Content ID, or null if not found. * * Calls {@see IMessagePart::getContentId()} to find a matching part. * * @param string $contentId The content ID to find a part for. * @return IMessagePart|null The matching part. */ public function getPartByContentId(string $contentId) : ?IMessagePart; /** * Registers the passed part as a child of the current part. * * If the $position parameter is non-null, adds the part at the passed * position index, otherwise adds it as the last child. * * @param MessagePart $part The part to add. * @param int $position Optional insertion position 0-based index. */ public function addChild(MessagePart $part, ?int $position = null) : static; /** * Removes the child part from this part and returns its previous position * or null if it wasn't found. * * Note that if the part is not a direct child of this part, the returned * position is its index within its parent (calls removePart on its direct * parent). * * This also means that parts from unrelated parts/messages could be removed * by a call to removePart -- it will always remove the part from its parent * if it has one, essentially calling * ```php $part->getParent()->removePart(); ```. * * @param IMessagePart $part The part to remove * @return int|null The previous index position of the part within its old * parent. */ public function removePart(IMessagePart $part) : ?int; /** * Removes all parts below the current part. If a callable filter is * passed, removes only those matching the passed filter. The number of * removed parts is returned. * * Note: the current part will not be removed. Although the function naming * matches getAllParts, which returns the current part, it also doesn't only * remove direct children like getChildParts. Internally this function uses * getAllParts but the current part is filtered out if returned. * * @param callable $fnFilter Optional function accepting an IMessagePart and * returning true if the part should be included. * @return int The number of removed parts. */ public function removeAllParts(?callable $fnFilter = null) : int; }