<?php

declare(strict_types=1);

namespace App\Scolarite\Application\Query\GetScheduleSlots;

use App\Scolarite\Domain\Model\Schedule\ScheduleSlot;
use DateTimeImmutable;

final readonly class ScheduleSlotDto
{
    public function __construct(
        public string $id,
        public string $classId,
        public string $subjectId,
        public string $teacherId,
        public int $dayOfWeek,
        public string $startTime,
        public string $endTime,
        public ?string $room,
        public bool $isRecurring,
        public DateTimeImmutable $createdAt,
        public DateTimeImmutable $updatedAt,
    ) {
    }

    public static function fromDomain(ScheduleSlot $slot): self
    {
        return new self(
            id: (string) $slot->id,
            classId: (string) $slot->classId,
            subjectId: (string) $slot->subjectId,
            teacherId: (string) $slot->teacherId,
            dayOfWeek: $slot->dayOfWeek->value,
            startTime: $slot->timeSlot->startTime,
            endTime: $slot->timeSlot->endTime,
            room: $slot->room,
            isRecurring: $slot->isRecurring,
            createdAt: $slot->createdAt,
            updatedAt: $slot->updatedAt,
        );
    }
}
