PhoneData.php 691 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Data\Pagarme\Recipient\Parts\Request;
  3. use App\Data\Pagarme\PagarmeData;
  4. final readonly class PhoneData extends PagarmeData
  5. {
  6. public function __construct(
  7. public string $ddd,
  8. public string $number,
  9. public string $type,
  10. ) {
  11. self::requireFilled($this->ddd, 'phone.ddd');
  12. self::requireFilled($this->number, 'phone.number');
  13. self::requireIn($this->type, ['home', 'mobile'], 'phone.type');
  14. }
  15. public function toArray(): array
  16. {
  17. return $this->filterFilledRecursive([
  18. 'ddd' => $this->ddd,
  19. 'number' => $this->number,
  20. 'type' => $this->type,
  21. ]);
  22. }
  23. }