<?php

declare(strict_types=1);

namespace App\Administration\Domain\Event;

use App\Administration\Domain\Model\SchoolCalendar\CalendarEntryId;
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 lorsqu'une journée pédagogique est ajoutée au calendrier.
 *
 * Déclenche la notification aux enseignants (AC5).
 */
final readonly class JourneePedagogiqueAjoutee implements DomainEvent
{
    public function __construct(
        public CalendarEntryId $entryId,
        public TenantId $tenantId,
        public AcademicYearId $academicYearId,
        public DateTimeImmutable $date,
        public string $label,
        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),
        );
    }
}
