implement immutable datetime

This commit is contained in:
Dennis Eichhorn 2020-09-10 20:18:47 +02:00
parent 71d165b1e5
commit 0c7cd4b132
2 changed files with 4 additions and 4 deletions

View File

@ -78,7 +78,7 @@ class Promotion
* @var \DateTime * @var \DateTime
* @since 1.0.0 * @since 1.0.0
*/ */
private \DateTime $createdAt; private \DateTimeImmutable $createdAt;
/** /**
* Created by. * Created by.
@ -102,7 +102,7 @@ class Promotion
$this->start = new \DateTime('now'); $this->start = new \DateTime('now');
$this->end = new \DateTime('now'); $this->end = new \DateTime('now');
$this->end->modify('+1 month'); $this->end->modify('+1 month');
$this->createdAt = new \DateTime('now'); $this->createdAt = new \DateTimeImmutable('now');
$this->createdBy = new NullAccount(); $this->createdBy = new NullAccount();
$this->calendar = new Calendar(); $this->calendar = new Calendar();
@ -482,7 +482,7 @@ class Promotion
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getCreatedAt() : \DateTime public function getCreatedAt() : \DateTimeInterface
{ {
return $this->createdAt; return $this->createdAt;
} }

View File

@ -49,7 +49,7 @@ final class PromotionMapper extends DataMapperAbstract
'marketing_promotion_progress' => ['name' => 'marketing_promotion_progress', 'type' => 'int', 'internal' => 'progress'], 'marketing_promotion_progress' => ['name' => 'marketing_promotion_progress', 'type' => 'int', 'internal' => 'progress'],
'marketing_promotion_progress_type' => ['name' => 'marketing_promotion_progress_type', 'type' => 'int', 'internal' => 'progressType'], 'marketing_promotion_progress_type' => ['name' => 'marketing_promotion_progress_type', 'type' => 'int', 'internal' => 'progressType'],
'marketing_promotion_created_by' => ['name' => 'marketing_promotion_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], 'marketing_promotion_created_by' => ['name' => 'marketing_promotion_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'marketing_promotion_created_at' => ['name' => 'marketing_promotion_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], 'marketing_promotion_created_at' => ['name' => 'marketing_promotion_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
]; ];
/** /**