61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
|
<?php
|
||
|
namespace ProVM\Emails\Model;
|
||
|
|
||
|
use DateTimeInterface;
|
||
|
use ProVM\Common\Define\Model;
|
||
|
|
||
|
class Job implements Model
|
||
|
{
|
||
|
protected int $id;
|
||
|
protected Message $message;
|
||
|
protected DateTimeInterface $dateTime;
|
||
|
protected bool $executed;
|
||
|
|
||
|
public function getId(): int
|
||
|
{
|
||
|
return $this->id;
|
||
|
}
|
||
|
public function getMessage(): Message
|
||
|
{
|
||
|
return $this->message;
|
||
|
}
|
||
|
public function getDateTime(): DateTimeInterface
|
||
|
{
|
||
|
return $this->dateTime;
|
||
|
}
|
||
|
public function isExecuted(): bool
|
||
|
{
|
||
|
return $this->executed ?? false;
|
||
|
}
|
||
|
|
||
|
public function setId(int $id): Job
|
||
|
{
|
||
|
$this->id = $id;
|
||
|
return $this;
|
||
|
}
|
||
|
public function setMessage(Message $message): Job
|
||
|
{
|
||
|
$this->message = $message;
|
||
|
return $this;
|
||
|
}
|
||
|
public function setDateTime(DateTimeInterface $dateTime): Job
|
||
|
{
|
||
|
$this->dateTime = $dateTime;
|
||
|
return $this;
|
||
|
}
|
||
|
public function wasExecuted(): Job
|
||
|
{
|
||
|
$this->executed = true;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function toArray(): array
|
||
|
{
|
||
|
return [
|
||
|
'id' => $this->getId(),
|
||
|
'message' => $this->getMessage()->toArray(),
|
||
|
'date_time' => $this->getDateTime()->format('Y-m-d H:i:s'),
|
||
|
'executed' => $this->isExecuted()
|
||
|
];
|
||
|
}
|
||
|
}
|