<?php

declare(strict_types=1);

namespace App\Scolarite\Infrastructure\Messaging;

use App\Scolarite\Domain\Event\DevoirCree;
use Psr\Log\LoggerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

/**
 * Réagit à la création d'un devoir.
 *
 * @todo #0 Implémenter la notification push/email aux élèves et parents (dépend de Epic 9)
 */
#[AsMessageHandler(bus: 'event.bus')]
final readonly class OnDevoirCreeHandler
{
    public function __construct(
        private LoggerInterface $logger,
    ) {
    }

    public function __invoke(DevoirCree $event): void
    {
        $this->logger->info('Nouveau devoir créé — notification prévue', [
            'homework_id' => (string) $event->homeworkId,
            'class_id' => $event->classId,
            'subject_id' => $event->subjectId,
            'teacher_id' => $event->teacherId,
            'title' => $event->title,
            'due_date' => $event->dueDate->format('Y-m-d'),
        ]);
    }
}
