| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Data\Pagarme\Response\PagarmeOrderResponseData;
- final readonly class PagarmeOrderItemResponseData
- {
- public function __construct(
- public ?string $id,
- public ?string $code,
- public ?int $amount,
- public ?int $quantity,
- public ?string $description,
- public ?string $status,
- ) {}
- public static function fromArray(array $payload): self
- {
- return new self(
- id: $payload['id'] ?? null,
- code: $payload['code'] ?? null,
- amount: isset($payload['amount']) ? (int) $payload['amount'] : null,
- quantity: isset($payload['quantity']) ? (int) $payload['quantity'] : null,
- description: $payload['description'] ?? null,
- status: $payload['status'] ?? null,
- );
- }
- public function toArray(): array
- {
- return [
- 'id' => $this->id,
- 'code' => $this->code,
- 'amount' => $this->amount,
- 'quantity' => $this->quantity,
- 'description' => $this->description,
- 'status' => $this->status,
- ];
- }
- }
|