AnticipationLimitData.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Data\Pagarme\Anticipation;
  3. use App\Data\Pagarme\PagarmeResponseData;
  4. final readonly class AnticipationLimitData extends PagarmeResponseData
  5. {
  6. public function __construct(
  7. public int $amount,
  8. public int $anticipationFee,
  9. public int $fee,
  10. public int $fraudCoverageFee,
  11. ) {}
  12. public static function fromArray(array $payload): static
  13. {
  14. return new self(
  15. amount: static::arrInt($payload, 'amount') ?? 0,
  16. anticipationFee: static::arrInt($payload, 'anticipation_fee') ?? 0,
  17. fee: static::arrInt($payload, 'fee') ?? 0,
  18. fraudCoverageFee: static::arrInt($payload, 'fraud_coverage_fee') ?? 0,
  19. );
  20. }
  21. public function toArray(): array
  22. {
  23. return [
  24. 'amount' => $this->amount,
  25. 'anticipation_fee' => $this->anticipationFee,
  26. 'fee' => $this->fee,
  27. 'fraud_coverage_fee' => $this->fraudCoverageFee,
  28. ];
  29. }
  30. }