implement immutable datetime

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

View File

@ -41,7 +41,7 @@ class Client
private string $info = ''; private string $info = '';
private \DateTime $createdAt; private \DateTimeImmutable $createdAt;
private Profile $profile; private Profile $profile;
@ -68,7 +68,7 @@ class Client
*/ */
public function __construct() public function __construct()
{ {
$this->createdAt = new \DateTime('now'); $this->createdAt = new \DateTimeImmutable('now');
$this->profile = new Profile(); $this->profile = new Profile();
} }
@ -303,7 +303,7 @@ class Client
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getCreatedAt() : \DateTime public function getCreatedAt() : \DateTimeInterface
{ {
return $this->createdAt; return $this->createdAt;
} }

View File

@ -42,7 +42,7 @@ final class ClientMapper extends DataMapperAbstract
'clientmgmt_client_status' => ['name' => 'clientmgmt_client_status', 'type' => 'int', 'internal' => 'status'], 'clientmgmt_client_status' => ['name' => 'clientmgmt_client_status', 'type' => 'int', 'internal' => 'status'],
'clientmgmt_client_type' => ['name' => 'clientmgmt_client_type', 'type' => 'int', 'internal' => 'type'], 'clientmgmt_client_type' => ['name' => 'clientmgmt_client_type', 'type' => 'int', 'internal' => 'type'],
'clientmgmt_client_info' => ['name' => 'clientmgmt_client_info', 'type' => 'string', 'internal' => 'info'], 'clientmgmt_client_info' => ['name' => 'clientmgmt_client_info', 'type' => 'string', 'internal' => 'info'],
'clientmgmt_client_created_at' => ['name' => 'clientmgmt_client_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], 'clientmgmt_client_created_at' => ['name' => 'clientmgmt_client_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
'clientmgmt_client_profile' => ['name' => 'clientmgmt_client_profile', 'type' => 'int', 'internal' => 'profile'], 'clientmgmt_client_profile' => ['name' => 'clientmgmt_client_profile', 'type' => 'int', 'internal' => 'profile'],
]; ];