Exemplo n.º 1
0
 protected function parseStructure(\stdClass $structure)
 {
     if (isset($this->typesMap[$structure->type])) {
         $this->type = $this->typesMap[$structure->type];
     } else {
         $this->type = self::TYPE_UNKNOWN;
     }
     $this->encoding = $this->encodingsMap[$structure->encoding];
     $this->subtype = $structure->subtype;
     if (isset($structure->bytes)) {
         $this->bytes = $structure->bytes;
     }
     foreach (array('disposition', 'bytes', 'description') as $optional) {
         if (isset($structure->{$optional})) {
             $this->{$optional} = $structure->{$optional};
         }
     }
     $this->parameters = new Parameters();
     if (is_array($structure->parameters)) {
         $this->parameters->add($structure->parameters);
     }
     if (isset($structure->dparameters)) {
         $this->parameters->add($structure->dparameters);
     }
     if (isset($structure->parts)) {
         foreach ($structure->parts as $key => $partStructure) {
             if (null === $this->partNumber) {
                 $partNumber = $key + 1;
             } else {
                 $partNumber = (string) ($this->partNumber . '.' . ($key + 1));
             }
             if ($this->isAttachment($partStructure)) {
                 $this->parts[] = new Attachment($this->stream, $this->messageNumber, $partNumber, $partStructure);
             } else {
                 $this->parts[] = new Part($this->stream, $this->messageNumber, $partNumber, $partStructure);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Get header
  *
  * @param string $key
  *
  * @return string
  */
 public function get($key)
 {
     return parent::get(strtolower($key));
 }