<?php

namespace App\Data\Pagarme\Customer\Parts\Request;

use App\Data\Pagarme\PagarmeData;

final readonly class PhoneData extends PagarmeData
{
    public function __construct(
        public string $countryCode,
        public string $areaCode,
        public string $number,
    ) {
        self::requireFilled($this->countryCode, 'phone.country_code');
        self::requireFilled($this->areaCode, 'phone.area_code');
        self::requireFilled($this->number, 'phone.number');
    }

    public function toArray(): array
    {
        return $this->filterFilledRecursive([
            'country_code' => $this->countryCode,
            'area_code'    => $this->areaCode,
            'number'       => $this->number,
        ]);
    }
}
