public function testParent() { $hf = $this->mockHeaderFactory; $part = new MimePart($hf); $parent = new MimePart($hf); $part->setParent($parent); $this->assertSame($parent, $part->getParent()); }
/** * Finds the boundaries for the current MimePart, reads its content and * creates and returns the next part, setting its parent part accordingly. * * @param resource $handle The handle to read from * @param \ZBateson\MailMimeParser\Message $message The current Message * @param \ZBateson\MailMimeParser\MimePart $part * @return MimePart */ protected function readMimeMessagePart($handle, Message $message, MimePart $part) { $boundary = $part->getHeaderParameter('Content-Type', 'boundary'); $skipFirst = true; $parent = $part; if (empty($boundary) || !preg_match('~multipart/\\w+~i', $part->getHeaderValue('Content-Type'))) { // either there is no boundary (possibly no parent boundary either) and message is read // till the end, or we're in a boundary already and content should be read till the parent // boundary is reached if ($part->getParent() !== null) { $parent = $part->getParent(); $boundary = $parent->getHeaderParameter('Content-Type', 'boundary'); } $skipFirst = false; } return $this->readMimeMessageBoundaryParts($handle, $message, $parent, $part, $boundary, $skipFirst); }