PagarmeOrderCheckoutResponseData.php 699 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Data\Pagarme\Response\PagarmeOrderResponseData;
  3. final readonly class PagarmeOrderCheckoutResponseData
  4. {
  5. public function __construct(
  6. public ?string $id,
  7. public ?string $status,
  8. public ?string $url,
  9. ) {}
  10. public static function fromArray(array $payload): self
  11. {
  12. return new self(
  13. id: $payload['id'] ?? null,
  14. status: $payload['status'] ?? null,
  15. url: $payload['url'] ?? null,
  16. );
  17. }
  18. public function toArray(): array
  19. {
  20. return [
  21. 'id' => $this->id,
  22. 'status' => $this->status,
  23. 'url' => $this->url,
  24. ];
  25. }
  26. }