<?php

namespace App\DTO;

readonly class ShiftDTO
{
    public function __construct(
        public string $name,
        public string $startTime,
        public string $endTime,
        public int $gracePeriodMinutes = 0
    ) {}

    public static function fromArray(array $data): self
    {
        return new self(
            name: $data['name'],
            startTime: $data['start_time'],
            endTime: $data['end_time'],
            gracePeriodMinutes: (int)($data['grace_period_minutes'] ?? 0)
        );
    }
}
