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 <[email protected]> |
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 null|string |
32
|
|
|
*/ |
33
|
|
|
private $charset; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Constructor. |
37
|
|
|
* |
38
|
|
|
* @param Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder |
39
|
|
|
* @param Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder |
40
|
|
|
* @param string|null $charset |
41
|
|
|
*/ |
42
|
55 |
|
public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) |
43
|
|
|
{ |
44
|
55 |
|
$this->safeEncoder = $safeEncoder; |
45
|
55 |
|
$this->nativeEncoder = $nativeEncoder; |
46
|
55 |
|
$this->charset = $charset; |
47
|
55 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Make a deep copy of object. |
51
|
|
|
*/ |
52
|
3 |
|
public function __clone() |
53
|
|
|
{ |
54
|
3 |
|
$this->safeEncoder = clone $this->safeEncoder; |
55
|
3 |
|
$this->nativeEncoder = clone $this->nativeEncoder; |
56
|
3 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
27 |
|
public function charsetChanged($charset) |
62
|
|
|
{ |
63
|
27 |
|
$this->charset = $charset; |
64
|
27 |
|
$this->safeEncoder->charsetChanged($charset); |
65
|
27 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritdoc} |
69
|
|
|
*/ |
70
|
|
|
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) |
71
|
|
|
{ |
72
|
|
|
$this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
55 |
|
public function getName() |
79
|
|
|
{ |
80
|
55 |
|
return 'quoted-printable'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
22 |
|
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) |
87
|
|
|
{ |
88
|
22 |
|
return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return Swift_Mime_ContentEncoder |
93
|
|
|
*/ |
94
|
22 |
|
private function getEncoder() |
95
|
|
|
{ |
96
|
22 |
|
return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.