lastTransaction; } public static function fromArray(array $payload): self { return new self( id: $payload['id'] ?? null, status: $payload['status'] ?? null, amount: isset($payload['amount']) ? (int) $payload['amount'] : null, currency: $payload['currency'] ?? null, paidAt: $payload['paid_at'] ?? null, createdAt: $payload['created_at'] ?? null, lastTransaction: ! empty($payload['last_transaction']) ? PagarmeOrderTransactionResponseData::fromArray($payload['last_transaction']) : null, ); } public function toArray(): array { return array_filter([ 'id' => $this->id, 'status' => $this->status, 'amount' => $this->amount, 'currency' => $this->currency, 'paid_at' => $this->paidAt, 'created_at' => $this->createdAt, 'last_transaction' => $this->lastTransaction?->toArray(), ], static fn ($v) => $v !== null); } }