Files
lichterei-web/kirby/src/Email/Body.php
Bastian Allgeier 3b0b6546ca Upgrade to 4.0.0
2023-11-28 09:34:07 +01:00

72 lines
1.3 KiB
PHP

<?php
namespace Kirby\Email;
use Kirby\Toolkit\Properties;
/**
* Representation of a an Email body
* with a text and optional html version
*
* @package Kirby Email
* @author Bastian Allgeier <bastian@getkirby.com>,
* Nico Hoffmann <nico@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class Body
{
protected string|null $html;
protected string|null $text;
/**
* Email body constructor
*/
public function __construct(array $props = [])
{
$this->html = $props['html'] ?? null;
$this->text = $props['text'] ?? null;
}
/**
* Creates a new instance while
* merging initial and new properties
* @deprecated 4.0.0
*/
public function clone(array $props = []): static
{
return new static(array_merge_recursive([
'html' => $this->html,
'text' => $this->text
], $props));
}
/**
* Returns the HTML content of the email body
*/
public function html(): string
{
return $this->html ?? '';
}
/**
* Returns the plain text content of the email body
*/
public function text(): string
{
return $this->text ?? '';
}
/**
* @since 4.0.0
*/
public function toArray(): array
{
return [
'html' => $this->html(),
'text' => $this->text()
];
}
}