implement immutable datetime

This commit is contained in:
Dennis Eichhorn 2020-09-10 20:18:47 +02:00
parent 279d6cc6f9
commit 58858e2f7d
4 changed files with 8 additions and 8 deletions

View File

@ -62,7 +62,7 @@ class Task implements \JsonSerializable
* @var \DateTime
* @since 1.0.0
*/
protected \DateTime $createdAt;
protected \DateTimeImmutable $createdAt;
/**
* Description.
@ -184,7 +184,7 @@ class Task implements \JsonSerializable
public function __construct()
{
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTime('now');
$this->createdAt = new \DateTimeImmutable('now');
$this->schedule = new Schedule();
$this->start = new \DateTime('now');
$this->due = new \DateTime('now');
@ -410,7 +410,7 @@ class Task implements \JsonSerializable
*
* @since 1.0.0
*/
public function getCreatedAt() : \DateTime
public function getCreatedAt() : \DateTimeInterface
{
return $this->createdAt;
}

View File

@ -76,7 +76,7 @@ class TaskElement implements \JsonSerializable
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $createdAt;
private \DateTimeImmutable $createdAt;
/**
* Status.
@ -135,7 +135,7 @@ class TaskElement implements \JsonSerializable
{
$this->due = new \DateTime('now');
$this->due->modify('+1 day');
$this->createdAt = new \DateTime('now');
$this->createdAt = new \DateTimeImmutable('now');
$this->createdBy = new NullAccount();
}
@ -156,7 +156,7 @@ class TaskElement implements \JsonSerializable
*
* @since 1.0.0
*/
public function getCreatedAt() : \DateTime
public function getCreatedAt() : \DateTimeInterface
{
return $this->createdAt;
}

View File

@ -43,7 +43,7 @@ final class TaskElementMapper extends DataMapperAbstract
'task_element_due' => ['name' => 'task_element_due', 'type' => 'DateTime', 'internal' => 'due'],
'task_element_task' => ['name' => 'task_element_task', 'type' => 'int', 'internal' => 'task'],
'task_element_created_by' => ['name' => 'task_element_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'task_element_created_at' => ['name' => 'task_element_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'task_element_created_at' => ['name' => 'task_element_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
];
/**

View File

@ -53,7 +53,7 @@ final class TaskMapper extends DataMapperAbstract
'task_schedule' => ['name' => 'task_schedule', 'type' => 'int', 'internal' => 'schedule'],
'task_start' => ['name' => 'task_start', 'type' => 'DateTime', 'internal' => 'start'],
'task_created_by' => ['name' => 'task_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'task_created_at' => ['name' => 'task_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'task_created_at' => ['name' => 'task_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
];
/**