implement immutable datetime

This commit is contained in:
Dennis Eichhorn 2020-09-10 20:18:46 +02:00
parent d77c9477c4
commit 618e53d44f
2 changed files with 4 additions and 4 deletions

View File

@ -75,7 +75,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
* @var \DateTime * @var \DateTime
* @since 1.0.0 * @since 1.0.0
*/ */
private \DateTime $createdAt; private \DateTimeImmutable $createdAt;
/** /**
* Creator. * Creator.
@ -101,7 +101,7 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
public function __construct() public function __construct()
{ {
$this->createdBy = new NullAccount(); $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 * @since 1.0.0
*/ */
public function getCreatedAt() : \DateTime public function getCreatedAt() : \DateTimeInterface
{ {
return $this->createdAt; return $this->createdAt;
} }

View File

@ -41,7 +41,7 @@ final class EditorDocMapper extends DataMapperAbstract
'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'], 'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'],
'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'], 'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'],
'editor_doc_path' => ['name' => 'editor_doc_path', 'type' => 'string', 'internal' => 'path'], '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],
]; ];
/** /**