<?php

declare(strict_types=1);

namespace App\Administration\Application\Query\GetClasses;

use App\Administration\Domain\Model\SchoolClass\SchoolClass;
use DateTimeImmutable;

/**
 * DTO pour représenter une classe dans les réponses de query.
 */
final readonly class ClassDto
{
    public function __construct(
        public string $id,
        public string $name,
        public ?string $level,
        public ?int $capacity,
        public string $status,
        public ?string $description,
        public DateTimeImmutable $createdAt,
        public DateTimeImmutable $updatedAt,
    ) {
    }

    public static function fromDomain(SchoolClass $class): self
    {
        return new self(
            id: (string) $class->id,
            name: (string) $class->name,
            level: $class->level?->value,
            capacity: $class->capacity,
            status: $class->status->value,
            description: $class->description,
            createdAt: $class->createdAt,
            updatedAt: $class->updatedAt,
        );
    }
}
