Example #1
0
 /**
  * Goes recursively through all parts of multi part and tries to retrieve content in required format
  *
  * @param PartInterface $multipart
  * @param string        $format
  *
  * @return Content|null  Returns null if given part is not multipart or when content of required format not found
  */
 protected function getMultipartContentRecursively(PartInterface $multipart, $format)
 {
     if ($multipart->isMultipart()) {
         foreach ($multipart as $part) {
             if ($part->isMultipart()) {
                 return $this->getMultipartContentRecursively($part, $format);
             }
             $contentTypeHeader = $this->getPartContentType($part);
             if ($contentTypeHeader->getType() === $format) {
                 return $this->extractContent($part);
             }
         }
     }
 }