1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace ICanBoogie\Mailer;
13
14 class
15 {
16 protected $value;
17
18 static public function from($value)
19 {
20 return new static($value);
21 }
22
23 public function __construct($value)
24 {
25 $this->value = $value;
26 }
27
28 public function __toString()
29 {
30 $value = $this->value;
31 $charset = mb_detect_encoding($value);
32
33 if ($charset != 'ASCII')
34 {
35 $value = mb_convert_encoding($value, 'UTF-8');
36 $value = mb_encode_mimeheader($value);
37 }
38
39 return $value;
40 }
41 }