<?php

namespace App\Modules\HR\PermissionRequests\DTOs;

final readonly class PermissionRequestSubmitData
{
    public function __construct(
        public int $employeeId,
        public string $type,
        public string $requestDate,
        public ?string $startAt,
        public ?string $endAt,
        public ?string $reason,
    ) {}

    /**
     * @param  array<string, mixed>  $data
     */
    public static function fromValidated(array $data): self
    {
        return new self(
            employeeId: (int) $data['employee_id'],
            type: (string) $data['type'],
            requestDate: (string) $data['request_date'],
            startAt: isset($data['start_at']) ? (string) $data['start_at'] : null,
            endAt: isset($data['end_at']) ? (string) $data['end_at'] : null,
            reason: isset($data['reason']) ? (string) $data['reason'] : null,
        );
    }
}
