implement immutable datetime

This commit is contained in:
Dennis Eichhorn 2020-09-10 20:18:47 +02:00
parent ee40af6480
commit 5912df63b9
9 changed files with 15 additions and 15 deletions

View File

@ -57,7 +57,7 @@ class KanbanBoard implements \JsonSerializable
private Account $createdBy; private Account $createdBy;
private \DateTime $createdAt; private \DateTimeImmutable $createdAt;
private array $columns = []; private array $columns = [];
@ -68,7 +68,7 @@ class KanbanBoard implements \JsonSerializable
*/ */
public function __construct() public function __construct()
{ {
$this->createdAt = new \DateTime('now'); $this->createdAt = new \DateTimeImmutable('now');
$this->createdBy = new NullAccount(); $this->createdBy = new NullAccount();
} }
@ -221,7 +221,7 @@ class KanbanBoard implements \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getCreatedAt() : \DateTime public function getCreatedAt() : \DateTimeInterface
{ {
return $this->createdAt; return $this->createdAt;
} }

View File

@ -40,7 +40,7 @@ final class KanbanBoardMapper extends DataMapperAbstract
'kanban_board_status' => ['name' => 'kanban_board_status', 'type' => 'int', 'internal' => 'status'], 'kanban_board_status' => ['name' => 'kanban_board_status', 'type' => 'int', 'internal' => 'status'],
'kanban_board_order' => ['name' => 'kanban_board_order', 'type' => 'int', 'internal' => 'order'], 'kanban_board_order' => ['name' => 'kanban_board_order', 'type' => 'int', 'internal' => 'order'],
'kanban_board_created_by' => ['name' => 'kanban_board_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], 'kanban_board_created_by' => ['name' => 'kanban_board_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'kanban_board_created_at' => ['name' => 'kanban_board_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], 'kanban_board_created_at' => ['name' => 'kanban_board_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
]; ];
/** /**

View File

@ -64,7 +64,7 @@ class KanbanCard implements \JsonSerializable
private Account $createdBy; private Account $createdBy;
private \DateTime $createdAt; private \DateTimeImmutable $createdAt;
private array $comments = []; private array $comments = [];
@ -79,7 +79,7 @@ class KanbanCard implements \JsonSerializable
*/ */
public function __construct() public function __construct()
{ {
$this->createdAt = new \DateTime('now'); $this->createdAt = new \DateTimeImmutable('now');
$this->createdBy = new NullAccount(); $this->createdBy = new NullAccount();
} }
@ -310,7 +310,7 @@ class KanbanCard implements \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getCreatedAt() : \DateTime public function getCreatedAt() : \DateTimeInterface
{ {
return $this->createdAt; return $this->createdAt;
} }

View File

@ -47,7 +47,7 @@ class KanbanCardComment implements \JsonSerializable
private Account $createdBy; private Account $createdBy;
private \DateTime $createdAt; private \DateTimeImmutable $createdAt;
private array $media = []; private array $media = [];
@ -58,7 +58,7 @@ class KanbanCardComment implements \JsonSerializable
*/ */
public function __construct() public function __construct()
{ {
$this->createdAt = new \DateTime('now'); $this->createdAt = new \DateTimeImmutable('now');
$this->createdBy = new NullAccount(); $this->createdBy = new NullAccount();
} }
@ -159,7 +159,7 @@ class KanbanCardComment implements \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getCreatedAt() : \DateTime public function getCreatedAt() : \DateTimeInterface
{ {
return $this->createdAt; return $this->createdAt;
} }

View File

@ -38,7 +38,7 @@ final class KanbanCardCommentMapper extends DataMapperAbstract
'kanban_card_comment_id' => ['name' => 'kanban_card_comment_id', 'type' => 'int', 'internal' => 'id'], 'kanban_card_comment_id' => ['name' => 'kanban_card_comment_id', 'type' => 'int', 'internal' => 'id'],
'kanban_card_comment_description' => ['name' => 'kanban_card_comment_description', 'type' => 'string', 'internal' => 'description'], 'kanban_card_comment_description' => ['name' => 'kanban_card_comment_description', 'type' => 'string', 'internal' => 'description'],
'kanban_card_comment_card' => ['name' => 'kanban_card_comment_card', 'type' => 'int', 'internal' => 'card'], 'kanban_card_comment_card' => ['name' => 'kanban_card_comment_card', 'type' => 'int', 'internal' => 'card'],
'kanban_card_comment_created_at' => ['name' => 'kanban_card_comment_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], 'kanban_card_comment_created_at' => ['name' => 'kanban_card_comment_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
'kanban_card_comment_created_by' => ['name' => 'kanban_card_comment_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], 'kanban_card_comment_created_by' => ['name' => 'kanban_card_comment_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
]; ];

View File

@ -43,7 +43,7 @@ final class KanbanCardMapper extends DataMapperAbstract
'kanban_card_order' => ['name' => 'kanban_card_order', 'type' => 'int', 'internal' => 'order'], 'kanban_card_order' => ['name' => 'kanban_card_order', 'type' => 'int', 'internal' => 'order'],
'kanban_card_ref' => ['name' => 'kanban_card_ref', 'type' => 'int', 'internal' => 'ref'], 'kanban_card_ref' => ['name' => 'kanban_card_ref', 'type' => 'int', 'internal' => 'ref'],
'kanban_card_column' => ['name' => 'kanban_card_column', 'type' => 'int', 'internal' => 'column'], 'kanban_card_column' => ['name' => 'kanban_card_column', 'type' => 'int', 'internal' => 'column'],
'kanban_card_created_at' => ['name' => 'kanban_card_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], 'kanban_card_created_at' => ['name' => 'kanban_card_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
'kanban_card_created_by' => ['name' => 'kanban_card_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], 'kanban_card_created_by' => ['name' => 'kanban_card_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
]; ];

View File

@ -32,7 +32,7 @@ class KanbanBoardTest extends \PHPUnit\Framework\TestCase
self::assertEquals('', $board->getName()); self::assertEquals('', $board->getName());
self::assertEquals('', $board->getDescription()); self::assertEquals('', $board->getDescription());
self::assertEquals(0, $board->getCreatedBy()->getId()); self::assertEquals(0, $board->getCreatedBy()->getId());
self::assertInstanceOf('\DateTime', $board->getCreatedAt()); self::assertInstanceOf('\DateTimeImmutable', $board->getCreatedAt());
self::assertEquals([], $board->getColumns()); self::assertEquals([], $board->getColumns());
} }

View File

@ -30,7 +30,7 @@ class KanbanCardCommentTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $comment->getCard()); self::assertEquals(0, $comment->getCard());
self::assertEquals('', $comment->getDescription()); self::assertEquals('', $comment->getDescription());
self::assertEquals(0, $comment->getCreatedBy()->getId()); self::assertEquals(0, $comment->getCreatedBy()->getId());
self::assertInstanceOf('\DateTime', $comment->getCreatedAt()); self::assertInstanceOf('\DateTimeImmutable', $comment->getCreatedAt());
self::assertEquals([], $comment->getMedia()); self::assertEquals([], $comment->getMedia());
} }

View File

@ -36,7 +36,7 @@ class KanbanCardTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $card->getColumn()); self::assertEquals(0, $card->getColumn());
self::assertEquals(0, $card->getOrder()); self::assertEquals(0, $card->getOrder());
self::assertEquals(0, $card->getCreatedBy()->getId()); self::assertEquals(0, $card->getCreatedBy()->getId());
self::assertInstanceOf('\DateTime', $card->getCreatedAt()); self::assertInstanceOf('\DateTimeImmutable', $card->getCreatedAt());
self::assertEquals([], $card->getComments()); self::assertEquals([], $card->getComments());
self::assertEquals([], $card->getLabels()); self::assertEquals([], $card->getLabels());
self::assertEquals([], $card->getMedia()); self::assertEquals([], $card->getMedia());