| Total Complexity | 7 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class SimpleContent implements Content\Contracts\SimpleContent |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var Message|null |
||
| 17 | */ |
||
| 18 | private $html; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var Message|null |
||
| 22 | */ |
||
| 23 | private $text; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * SimpleContent constructor. |
||
| 27 | * |
||
| 28 | * @param Message|null $html |
||
| 29 | * @param Message|null $text |
||
| 30 | */ |
||
| 31 | 4 | public function __construct(?Message $html, ?Message $text) |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $html |
||
| 39 | * @param string $charset |
||
| 40 | * |
||
| 41 | * @return SimpleContent |
||
| 42 | */ |
||
| 43 | 2 | public static function html(string $html, string $charset = Message::DEFAULT_CHARSET): self |
|
| 44 | { |
||
| 45 | 2 | return new self(new Message($html, $charset), null); |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param string $html |
||
| 50 | * @param string $charset |
||
| 51 | * |
||
| 52 | * @return SimpleContent |
||
| 53 | */ |
||
| 54 | 1 | public function addHtml(string $html, string $charset = Message::DEFAULT_CHARSET): self |
|
| 55 | { |
||
| 56 | 1 | return new self(new Message($html, $charset), clone $this->text); |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param string $text |
||
| 61 | * @param string $charset |
||
| 62 | * |
||
| 63 | * @return SimpleContent |
||
| 64 | */ |
||
| 65 | 2 | public static function text(string $text, string $charset = Message::DEFAULT_CHARSET): self |
|
| 66 | { |
||
| 67 | 2 | return new self(null, new Message($text, $charset)); |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param string $text |
||
| 72 | * @param string $charset |
||
| 73 | * |
||
| 74 | * @return SimpleContent |
||
| 75 | */ |
||
| 76 | 1 | public function addText(string $text, string $charset = Message::DEFAULT_CHARSET): self |
|
| 77 | { |
||
| 78 | 1 | return new self(clone $this->html, new Message($text, $charset)); |
|
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return Message|null |
||
| 83 | */ |
||
| 84 | 4 | public function getHtml(): ?Message |
|
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return Message|null |
||
| 91 | */ |
||
| 92 | 4 | public function getText(): ?Message |
|
| 97 |