Full implemantation
This commit is contained in:
61
api/src/Model/Job.php
Normal file
61
api/src/Model/Job.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?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()
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user