OSDN Git Service

Добавлена возможность создавать новую запись предмета оборудования на основании уже...
[invent/invent.git] / vendor / swiftmailer / swiftmailer / lib / classes / Swift / Mime / ContentEncoder / QpContentEncoderProxy.php
1 <?php
2
3 /*
4  * This file is part of SwiftMailer.
5  * (c) 2004-2009 Chris Corbyn
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * Proxy for quoted-printable content encoders.
13  *
14  * Switches on the best QP encoder implementation for current charset.
15  *
16  * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
17  */
18 class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder
19 {
20     /**
21      * @var Swift_Mime_ContentEncoder_QpContentEncoder
22      */
23     private $safeEncoder;
24
25     /**
26      * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder
27      */
28     private $nativeEncoder;
29
30     /**
31      * @var string|null
32      */
33     private $charset;
34
35     /**
36      * Constructor.
37      *
38      * @param string|null $charset
39      */
40     public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset)
41     {
42         $this->safeEncoder = $safeEncoder;
43         $this->nativeEncoder = $nativeEncoder;
44         $this->charset = $charset;
45     }
46
47     /**
48      * Make a deep copy of object.
49      */
50     public function __clone()
51     {
52         $this->safeEncoder = clone $this->safeEncoder;
53         $this->nativeEncoder = clone $this->nativeEncoder;
54     }
55
56     /**
57      * {@inheritdoc}
58      */
59     public function charsetChanged($charset)
60     {
61         $this->charset = $charset;
62         $this->safeEncoder->charsetChanged($charset);
63     }
64
65     /**
66      * {@inheritdoc}
67      */
68     public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
69     {
70         $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength);
71     }
72
73     /**
74      * {@inheritdoc}
75      */
76     public function getName()
77     {
78         return 'quoted-printable';
79     }
80
81     /**
82      * {@inheritdoc}
83      */
84     public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
85     {
86         return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength);
87     }
88
89     /**
90      * @return Swift_Mime_ContentEncoder
91      */
92     private function getEncoder()
93     {
94         return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder;
95     }
96 }