From bd9261daae85157567b77965ec2db5669bfb233b Mon Sep 17 00:00:00 2001 From: Piotr Potrebka <piotr.potrebka@wpdesk.net> Date: Wed, 25 Jan 2023 13:36:11 +0100 Subject: [PATCH] feat: email abstract --- src/Abstracts/EmailAbstract.php | 24 +++++++++++++++++++++--- src/Abstracts/EmailInterface.php | 7 +++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Abstracts/EmailAbstract.php b/src/Abstracts/EmailAbstract.php index fbd687f..3e7adb1 100644 --- a/src/Abstracts/EmailAbstract.php +++ b/src/Abstracts/EmailAbstract.php @@ -44,7 +44,7 @@ abstract class EmailAbstract implements EmailInterface { /** * @var string */ - protected $type = 'text/html'; + protected $type = 'html'; /** * @var array @@ -66,7 +66,9 @@ abstract class EmailAbstract implements EmailInterface { } /** - * @return bool + * @param $enable + * + * @return EmailAbstract */ public function set_is_enable( $enable ): self { $this->is_enable = $enable; @@ -218,7 +220,7 @@ abstract class EmailAbstract implements EmailInterface { * * @return self */ - public function set_type( string $type = 'text/html' ): self { + public function set_type( string $type = 'html' ): self { $this->type = $type; return $this; @@ -233,6 +235,22 @@ abstract class EmailAbstract implements EmailInterface { return $this->type; } + /** + * Get content type. + * + * @return string + */ + public function get_content_type(): string { + switch ( $this->get_type() ) { + case 'html': + return 'text/html'; + case 'multipart': + return 'multipart/alternative'; + default: + return 'text/plain'; + } + } + /** * Get email content. * diff --git a/src/Abstracts/EmailInterface.php b/src/Abstracts/EmailInterface.php index de5a423..c82a432 100644 --- a/src/Abstracts/EmailInterface.php +++ b/src/Abstracts/EmailInterface.php @@ -67,6 +67,13 @@ interface EmailInterface { */ public function get_type(): string; + /** + * Get content type. + * + * @return string + */ + public function get_content_type(): string; + /** * Get email content. * -- GitLab