id = new ObjectId(); $this->createdOn = new DateTimeImmutable(); $this->updatedOn = new DateTimeImmutable(); } public function __serialize(): array { return [ '_id' => $this->id, 'CreatedOn' => new UTCDateTime($this->createdOn), 'UpdatedOn' => new UTCDateTime($this->updatedOn), 'UserUuid' => $this->userUuid, 'EmailAddress' => $this->emailAddress, 'FirstName' => $this->firstName, 'LastName' => $this->lastName, 'Roles' => $this->roles, 'IsUserLocked' => $this->isUserLocked, 'IsUserEnabled' => $this->isUserEnabled ]; } public function __unserialize(array $data): void { $this->id = $data['_id']; $this->createdOn = DateTimeImmutable::createFromMutable($data['CreatedOn']->toDateTime()); $this->updatedOn = DateTimeImmutable::createFromMutable($data['UpdatedOn']->toDateTime()); $this->userUuid = $data['UserUuid']; $this->emailAddress = $data['EmailAddress']; $this->firstName = $data['FirstName']; $this->lastName = $data['LastName']; $this->roles = $data['Roles']; $this->isUserLocked = $data['IsUserLocked']; $this->isUserEnabled = $data['IsUserLocked']; } }