| Conditions | 6 |
| Paths | 10 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 6.0052 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 147 | public function __construct(string $value, bool $phrase = false) |
|
| 28 | { |
||
| 29 | 147 | if ($phrase === true) { |
|
| 30 | 51 | $encoded = new OptimalTransferEncodedPhraseStream($value, 68, self::FOLDING); |
|
| 31 | |||
| 32 | 51 | $this->encoding = $encoded->getMetadata(['transfer-encoding'])['transfer-encoding']; |
|
| 33 | } else { |
||
| 34 | 119 | $encoded = new OptimalTransferEncodedTextStream($value, 68, self::FOLDING); |
|
| 35 | |||
| 36 | 119 | $this->encoding = $encoded->getMetadata(['transfer-encoding'])['transfer-encoding']; |
|
| 37 | } |
||
| 38 | |||
| 39 | 147 | switch ($this->encoding) { |
|
| 40 | 147 | case '7bit': |
|
| 41 | 10 | case '8bit': |
|
| 42 | 140 | $this->encoded = (string) $encoded; |
|
| 43 | 140 | break; |
|
| 44 | 10 | case 'base64': |
|
| 45 | 8 | $this->encoded = \sprintf('=?%s?B?%s?=', 'UTF-8', (string) $encoded); |
|
| 46 | 8 | break; |
|
| 47 | 2 | case 'quoted-printable': |
|
| 48 | 2 | $this->encoded = \sprintf('=?%s?Q?%s?=', 'UTF-8', (string) $encoded); |
|
| 49 | 2 | break; |
|
| 50 | default: |
||
| 51 | throw new \UnexpectedValueException('Unknown encoding ' . $this->encoding); |
||
| 52 | } |
||
| 53 | 147 | } |
|
| 54 | |||
| 80 |