<?php

declare(strict_types=1);

namespace App\Administration\Domain\Event;

use App\Administration\Domain\Model\SchoolCalendar\SchoolZone;
use App\Administration\Domain\Model\SchoolClass\AcademicYearId;
use App\Shared\Domain\DomainEvent;
use App\Shared\Domain\Tenant\TenantId;
use DateTimeImmutable;
use Override;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

use function sprintf;

/**
 * Événement émis lorsque le calendrier scolaire est configuré
 * (zone sélectionnée, vacances importées).
 */
final readonly class CalendrierConfigure implements DomainEvent
{
    public function __construct(
        public TenantId $tenantId,
        public AcademicYearId $academicYearId,
        public SchoolZone $zone,
        public int $nombreEntrees,
        private DateTimeImmutable $occurredOn,
    ) {
    }

    #[Override]
    public function occurredOn(): DateTimeImmutable
    {
        return $this->occurredOn;
    }

    #[Override]
    public function aggregateId(): UuidInterface
    {
        return Uuid::uuid5(
            Uuid::NAMESPACE_DNS,
            sprintf('school-calendar:%s:%s', $this->tenantId, $this->academicYearId),
        );
    }
}
