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:
56
lib/Client/Mime/LazyMessage.php
Normal file
56
lib/Client/Mime/LazyMessage.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gricob\IMAP\Mime;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Gricob\IMAP\Client;
|
||||
use Gricob\IMAP\Mime\Part\Part;
|
||||
|
||||
class LazyMessage extends Message
|
||||
{
|
||||
public function __construct(
|
||||
private Client $client,
|
||||
int $id,
|
||||
?array $headers = null,
|
||||
?DateTimeImmutable $internalDate = null,
|
||||
) {
|
||||
$this->id = $id;
|
||||
|
||||
if (null !== $headers) {
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
if (null !== $internalDate) {
|
||||
$this->internalDate = $internalDate;
|
||||
}
|
||||
}
|
||||
|
||||
public function headers(): array
|
||||
{
|
||||
if (!isset($this->headers)) {
|
||||
$this->headers = $this->client->fetchHeaders($this->id);
|
||||
}
|
||||
|
||||
return parent::headers();
|
||||
}
|
||||
|
||||
public function body(): Part
|
||||
{
|
||||
if (!isset($this->body)) {
|
||||
$this->body = $this->client->fetchBody($this->id);
|
||||
}
|
||||
|
||||
return parent::body();
|
||||
}
|
||||
|
||||
public function internalDate(): DateTimeImmutable
|
||||
{
|
||||
if (!isset($this->internalDate)) {
|
||||
$this->internalDate = $this->client->fetchInternalDate($this->id);
|
||||
}
|
||||
|
||||
return parent::internalDate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user