implement immutable datetime

This commit is contained in:
Dennis Eichhorn 2020-09-10 20:18:46 +02:00
parent 3b3ad48c90
commit 8e4384a3b0
4 changed files with 8 additions and 8 deletions

View File

@ -76,7 +76,7 @@ class Report implements \JsonSerializable
* @var \DateTime
* @since 1.0.0
*/
protected \DateTime $createdAt;
protected \DateTimeImmutable $createdAt;
/**
* Report created by.
@ -110,7 +110,7 @@ class Report implements \JsonSerializable
public function __construct()
{
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTime('now');
$this->createdAt = new \DateTimeImmutable('now');
$this->template = new NullTemplate();
$this->source = new NullCollection();
}
@ -238,7 +238,7 @@ class Report implements \JsonSerializable
*
* @since 1.0.0
*/
public function getCreatedAt() : \DateTime
public function getCreatedAt() : \DateTimeInterface
{
return $this->createdAt;
}

View File

@ -42,7 +42,7 @@ final class ReportMapper extends DataMapperAbstract
'helper_report_media' => ['name' => 'helper_report_media', 'type' => 'int', 'internal' => 'source'],
'helper_report_template' => ['name' => 'helper_report_template', 'type' => 'int', 'internal' => 'template'],
'helper_report_creator' => ['name' => 'helper_report_creator', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'helper_report_created' => ['name' => 'helper_report_created', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'helper_report_created' => ['name' => 'helper_report_created', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
];
/**

View File

@ -102,7 +102,7 @@ class Template implements \JsonSerializable
* @var \DateTime
* @since 1.0.0
*/
protected \DateTime $createdAt;
protected \DateTimeImmutable $createdAt;
/**
* Template created by.
@ -151,7 +151,7 @@ class Template implements \JsonSerializable
*/
public function __construct()
{
$this->createdAt = new \DateTime('now');
$this->createdAt = new \DateTimeImmutable('now');
$this->unit = new NullUnit();
$this->source = new NullCollection();
$this->createdBy = new NullAccount();
@ -350,7 +350,7 @@ class Template implements \JsonSerializable
*
* @since 1.0.0
*/
public function getCreatedAt() : \DateTime
public function getCreatedAt() : \DateTimeInterface
{
return $this->createdAt;
}

View File

@ -48,7 +48,7 @@ final class TemplateMapper extends DataMapperAbstract
'helper_template_media' => ['name' => 'helper_template_media', 'type' => 'int', 'internal' => 'source'],
'helper_template_creator' => ['name' => 'helper_template_creator', 'type' => 'int', 'internal' => 'createdBy'],
'helper_template_unit' => ['name' => 'helper_template_unit', 'type' => 'int', 'internal' => 'unit'],
'helper_template_created' => ['name' => 'helper_template_created', 'type' => 'DateTime', 'internal' => 'createdAt'],
'helper_template_created' => ['name' => 'helper_template_created', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'],
];
/**