4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Proxy for quoted-printable content encoders.
14 * Switches on the best QP encoder implementation for current charset.
16 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
18 class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder
21 * @var Swift_Mime_ContentEncoder_QpContentEncoder
26 * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder
28 private $nativeEncoder;
38 * @param string|null $charset
40 public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset)
42 $this->safeEncoder = $safeEncoder;
43 $this->nativeEncoder = $nativeEncoder;
44 $this->charset = $charset;
48 * Make a deep copy of object.
50 public function __clone()
52 $this->safeEncoder = clone $this->safeEncoder;
53 $this->nativeEncoder = clone $this->nativeEncoder;
59 public function charsetChanged($charset)
61 $this->charset = $charset;
62 $this->safeEncoder->charsetChanged($charset);
68 public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
70 $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength);
76 public function getName()
78 return 'quoted-printable';
84 public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
86 return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength);
90 * @return Swift_Mime_ContentEncoder
92 private function getEncoder()
94 return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder;