Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • File
  • InlineFile
  • InlineString
  • String
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * Jyxo PHP Library
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file license.txt.
10:  * It is also available through the world-wide-web at this URL:
11:  * https://github.com/jyxo/php/blob/master/license.txt
12:  */
13: 
14: namespace Jyxo\Mail\Email\Attachment;
15: 
16: /**
17:  * Inline mail attachment created from a string.
18:  *
19:  * @category Jyxo
20:  * @package Jyxo\Mail
21:  * @subpackage Email
22:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
23:  * @license https://github.com/jyxo/php/blob/master/license.txt
24:  * @author Jaroslav HanslĂ­k
25:  */
26: class InlineString extends \Jyxo\Mail\Email\Attachment
27: {
28:     /**
29:      * Type.
30:      *
31:      * @var string
32:      */
33:     protected $disposition = \Jyxo\Mail\Email\Attachment::DISPOSITION_INLINE;
34: 
35:     /**
36:      * Creates an attachment.
37:      *
38:      * @param string $content File contents
39:      * @param string $name Attachment name
40:      * @param string $cid Id
41:      * @param string $mimeType Attachment mime-type
42:      * @param string $encoding Source encoding
43:      */
44:     public function __construct($content, $name, $cid, $mimeType = 'application/octet-stream', $encoding = '')
45:     {
46:         $this->setContent($content);
47:         $this->setName($name);
48:         $this->setCid($cid);
49:         $this->setMimeType($mimeType);
50:         $this->setEncoding($encoding);
51:     }
52: 
53:     /**
54:      * Sets Id.
55:      *
56:      * @param string $cid
57:      * @return \Jyxo\Mail\Email\Attachment\InlineString
58:      */
59:     public function setCid($cid)
60:     {
61:         $this->cid = (string) $cid;
62: 
63:         return $this;
64:     }
65: 
66:     /**
67:      * Sets contents encoding.
68:      * If none is set, assume no encoding is used.
69:      *
70:      * @param string $encoding Encoding name
71:      * @return \Jyxo\Mail\Email\Attachment\InlineString
72:      * @throws \InvalidArgumentException If an incompatible encoding was provided
73:      */
74:     public function setEncoding($encoding)
75:     {
76:         if ((!empty($encoding)) && (!\Jyxo\Mail\Encoding::isCompatible($encoding))) {
77:             throw new \InvalidArgumentException(sprintf('Incompatible encoding %s', $encoding));
78:         }
79: 
80:         $this->encoding = (string) $encoding;
81: 
82:         return $this;
83:     }
84: }
85: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0