From 618e53d44fa522333bd3c32232e97b064f77ffc0 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 10 Sep 2020 20:18:46 +0200 Subject: [PATCH] implement immutable datetime --- Models/EditorDoc.php | 6 +++--- Models/EditorDocMapper.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Models/EditorDoc.php b/Models/EditorDoc.php index 7d90364..e1aff0b 100755 --- a/Models/EditorDoc.php +++ b/Models/EditorDoc.php @@ -75,7 +75,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface * @var \DateTime * @since 1.0.0 */ - private \DateTime $createdAt; + private \DateTimeImmutable $createdAt; /** * Creator. @@ -101,7 +101,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface public function __construct() { $this->createdBy = new NullAccount(); - $this->createdAt = new \DateTime('now'); + $this->createdAt = new \DateTimeImmutable('now'); } /** @@ -163,7 +163,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface * * @since 1.0.0 */ - public function getCreatedAt() : \DateTime + public function getCreatedAt() : \DateTimeInterface { return $this->createdAt; } diff --git a/Models/EditorDocMapper.php b/Models/EditorDocMapper.php index ecbe5a2..bb2e188 100755 --- a/Models/EditorDocMapper.php +++ b/Models/EditorDocMapper.php @@ -41,7 +41,7 @@ final class EditorDocMapper extends DataMapperAbstract 'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'], 'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'], 'editor_doc_path' => ['name' => 'editor_doc_path', 'type' => 'string', 'internal' => 'path'], - 'editor_doc_created_at' => ['name' => 'editor_doc_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], + 'editor_doc_created_at' => ['name' => 'editor_doc_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], ]; /**