id = (int)$subscriptionQueryObject->id; $self->createdAt = Temporal::toDateTime($subscriptionQueryObject->createdAt); $self->renewsAt = isset($subscriptionQueryObject->renewsAt) ? Temporal::toDateTime( $subscriptionQueryObject->renewsAt ) : null; $self->donorId = (int)$subscriptionQueryObject->donorId; $self->period = new SubscriptionPeriod($subscriptionQueryObject->period); $self->frequency = (int)$subscriptionQueryObject->frequency; $self->installments = (int)$subscriptionQueryObject->installments; $self->transactionId = $subscriptionQueryObject->transactionId; $self->mode = new SubscriptionMode($subscriptionQueryObject->mode); $self->amount = Money::fromDecimal($subscriptionQueryObject->amount, $subscriptionQueryObject->currency ?? give_get_currency()); $self->feeAmountRecovered = Money::fromDecimal($subscriptionQueryObject->feeAmount, $subscriptionQueryObject->currency ?? give_get_currency()); $self->status = new SubscriptionStatus($subscriptionQueryObject->status); $self->gatewayId = $subscriptionQueryObject->gatewayId; $self->gatewaySubscriptionId = $subscriptionQueryObject->gatewaySubscriptionId; $self->donationFormId = (int)$subscriptionQueryObject->donationFormId; return $self; } /** * Convert DTO to Subscription */ public function toSubscription(): Subscription { $attributes = get_object_vars($this); return new Subscription($attributes); } }