id = (int)$object->id; $self->userId = (int)$object->userId; $self->prefix = $object->{DonorMetaKeys::PREFIX()->getKeyAsCamelCase()}; $self->email = $object->email; $self->phone = $object->phone; $self->name = $object->name; $self->firstName = $object->firstName; $self->lastName = $object->lastName; $self->createdAt = Temporal::toDateTime($object->createdAt); $self->additionalEmails = $object->additionalEmails; $self->addresses = $object->addresses ?? []; $self->avatarId = (int)$object->{DonorMetaKeys::AVATAR_ID()->getKeyAsCamelCase()}; $self->company = $object->{DonorMetaKeys::COMPANY()->getKeyAsCamelCase()}; $self->totalAmountDonated = Money::fromDecimal($object->totalAmountDonated, give_get_currency()); $self->totalNumberOfDonations = (int)$object->totalNumberOfDonations; return $self; } /** * Convert DTO to Donation * * @return Donor */ public function toDonor() { $attributes = get_object_vars($this); return new Donor($attributes); } }