<?php

declare(strict_types=1);

namespace App\Administration\Domain\Event;

use App\Administration\Domain\Model\HomeworkRules\EnforcementMode;
use App\Administration\Domain\Model\HomeworkRules\HomeworkRulesId;
use App\Shared\Domain\DomainEvent;
use App\Shared\Domain\Tenant\TenantId;
use DateTimeImmutable;
use Override;
use Ramsey\Uuid\UuidInterface;

/**
 * Événement émis lors de la modification des règles de devoirs d'un établissement.
 *
 * Porte l'état avant/après pour permettre l'historique des changements (AC6).
 */
final readonly class ReglesDevoirsModifiees implements DomainEvent
{
    /**
     * @param array<int, array{type: string, params: array<string, mixed>}> $previousRules
     * @param array<int, array{type: string, params: array<string, mixed>}> $newRules
     */
    public function __construct(
        public HomeworkRulesId $homeworkRulesId,
        public TenantId $tenantId,
        public array $previousRules,
        public array $newRules,
        public EnforcementMode $enforcementMode,
        public bool $enabled,
        private DateTimeImmutable $occurredOn,
    ) {
    }

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

    #[Override]
    public function aggregateId(): UuidInterface
    {
        return $this->homeworkRulesId->value;
    }
}
