<?php

namespace App\Modules\HR\Overtime\DTOs;

final readonly class OvertimeRequestSubmitData
{
    public function __construct(
        public int $employeeId,
        public string $attendanceDate,
        public int $overtimeMinutes,
        public ?string $reason,
    ) {}

    /**
     * @param  array<string, mixed>  $data
     */
    public static function fromValidated(array $data): self
    {
        return new self(
            employeeId: (int) $data['employee_id'],
            attendanceDate: (string) $data['attendance_date'],
            overtimeMinutes: (int) $data['overtime_minutes'],
            reason: isset($data['reason']) ? (string) $data['reason'] : null,
        );
    }
}
