<?php

namespace App\DTO;

readonly class LeaveApplicationDTO
{
    public function __construct(
        public int $userId,
        public string $type,
        public string $startDate,
        public string $endDate,
        public string $reason,
        public ?string $attachmentPath = null
    ) {}

    public static function fromArray(array $data): self
    {
        return new self(
            userId: $data['user_id'],
            type: $data['type'],
            startDate: $data['start_date'],
            endDate: $data['end_date'],
            reason: $data['reason'],
            attachmentPath: $data['attachment_path'] ?? null
        );
    }
}
