generated from Nodarx/template
feat: initial version
Signed-off-by: Sebastian Krupinski <root@LAPTOP-7DVOR6NC>
This commit was merged in pull request #1.
This commit is contained in:
55
lib/Client/Mime/Message.php
Normal file
55
lib/Client/Mime/Message.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gricob\IMAP\Mime;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Gricob\IMAP\Mime\Part\Part;
|
||||
|
||||
class Message
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $headers
|
||||
*/
|
||||
public function __construct(
|
||||
protected int $id,
|
||||
protected array $headers,
|
||||
protected Part $body,
|
||||
protected DateTimeImmutable $internalDate,
|
||||
) {
|
||||
}
|
||||
|
||||
public function id(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function headers(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function body(): Part
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function internalDate(): DateTimeImmutable
|
||||
{
|
||||
return $this->internalDate;
|
||||
}
|
||||
|
||||
public function textBody(): ?string
|
||||
{
|
||||
return $this->body()->findPartByMimeType('text/plain')?->decodedBody();
|
||||
}
|
||||
|
||||
public function htmlBody(): ?string
|
||||
{
|
||||
return $this->body()->findPartByMimeType('text/html')?->decodedBody();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user