Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Mail\Content\Attachment Class Reference
Inheritance diagram for Hoa\Mail\Content\Attachment:

Public Member Functions

 __construct (Stream $stream, $name=null, $mimeType=null)
 
 getStream ()
 
- Public Member Functions inherited from Hoa\Mail\Content\Content
 __construct ()
 
 offsetExists ($header)
 
 offsetGet ($header)
 
 offsetSet ($header, $value)
 
 offsetUnset ($header)
 
 getHeaders ()
 
 getFormattedContent ($headers=true)
 
 getId ()
 
 getIdUrl ()
 
 __toString ()
 

Protected Member Functions

 setStream (Stream $stream)
 
 _getContent ()
 
- Protected Member Functions inherited from Hoa\Mail\Content\Content
 _getContent ()
 

Protected Attributes

 $_stream = null
 
- Protected Attributes inherited from Hoa\Mail\Content\Content
 $_headers = []
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\Mail\Content\Content
static formatHeaders (Array $headers)
 
static getAddress ($contact)
 
static getDomain ($contact)
 

Detailed Description

Class .

This class represents an attachment.

Definition at line 50 of file Attachment.php.

Constructor & Destructor Documentation

Hoa\Mail\Content\Attachment::__construct ( Stream  $stream,
  $name = null,
  $mimeType = null 
)

Construct an attachment with a stream and a name.

Parameters
\Hoa\Stream$streamStream that contains the attachment.
string$nameName of the attachment (if null, will use the stream basename).
string$mimeTypeForce a MIME type.
Returns
void

Definition at line 70 of file Attachment.php.

71  {
72  parent::__construct();
73 
74  if (null === $name) {
75  if ($stream instanceof Stream\IStream\Pathable) {
76  $name = $stream->getBasename();
77  } else {
78  $name = basename($stream->getStreamName());
79  }
80  }
81 
82  if (null === $mimeType) {
83  $mimeType = null;
84 
85  try {
86  $mime = new Mime($stream);
87  $mimeType = $mime->getMime();
88  } catch (Mime\Exception $e) {
89  }
90 
91  if (null === $mimeType) {
92  $mimeType = 'application/octet-stream';
93  }
94  }
95 
96  $size = null;
97 
98  if ($stream instanceof Stream\IStream\Statable &&
99  false !== $_size = $stream->getSize()) {
100  $size = '; size=' . $_size;
101  }
102 
103  $this['content-type'] = $mimeType;
104  $this['content-disposition'] =
105  'attachment; filename="' .
106  str_replace('"', '-', $name) .
107  '"' .
108  $size;
109 
110  $this->setStream($stream);
111 
112  return;
113  }
setStream(Stream $stream)
Definition: Attachment.php:121

Here is the call graph for this function:

Member Function Documentation

Hoa\Mail\Content\Attachment::_getContent ( )
protected

Get final “plain” content.

Returns
string

Definition at line 144 of file Attachment.php.

145  {
146  return Encoder\Base64::encode($this->getStream()->readAll());
147  }
static encode($string, $isHeaderValue=false)
Definition: Base64.php:59

Here is the call graph for this function:

Hoa\Mail\Content\Attachment::getStream ( )

Get the stream.

Returns

Definition at line 134 of file Attachment.php.

135  {
136  return $this->_stream;
137  }

Here is the caller graph for this function:

Hoa\Mail\Content\Attachment::setStream ( Stream  $stream)
protected

Set the stream.

Parameters
\Hoa\Stream$streamStream.
Returns

Definition at line 121 of file Attachment.php.

122  {
123  $old = $this->_stream;
124  $this->_stream = $stream;
125 
126  return $old;
127  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Mail\Content\Attachment::$_stream = null
protected

Definition at line 57 of file Attachment.php.


The documentation for this class was generated from the following file: