feat: Gestion des matières scolaires

Les établissements ont besoin de définir leur référentiel de matières
pour pouvoir ensuite les associer aux enseignants et aux classes.
Cette fonctionnalité permet aux administrateurs de créer, modifier et
archiver les matières avec leurs propriétés (nom, code court, couleur).

L'architecture suit le pattern DDD avec des Value Objects utilisant
les property hooks PHP 8.5 pour garantir l'immutabilité et la validation.
L'isolation multi-tenant est assurée par vérification dans les handlers.
This commit is contained in:
2026-02-05 20:42:31 +01:00
parent 8e09e0abf1
commit 0d5a097c4c
50 changed files with 5882 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Administration\Domain\Exception;
use RuntimeException;
use function sprintf;
final class SubjectCodeInvalideException extends RuntimeException
{
public static function pourFormat(string $value, int $min, int $max): self
{
return new self(sprintf(
'Le code de matière "%s" doit contenir entre %d et %d caractères alphanumériques majuscules (ex: "MATH", "FR", "EPS").',
$value,
$min,
$max,
));
}
}

View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace App\Administration\Domain\Exception;
use RuntimeException;
use function sprintf;
final class SubjectColorInvalideException extends RuntimeException
{
public static function pourFormat(string $value): self
{
return new self(sprintf(
'La couleur "%s" doit être au format hexadécimal #RRGGBB (ex: "#3B82F6").',
$value,
));
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Administration\Domain\Exception;
use App\Administration\Domain\Model\Subject\SubjectCode;
use RuntimeException;
use function sprintf;
final class SubjectDejaExistanteException extends RuntimeException
{
public static function avecCode(SubjectCode $code): self
{
return new self(sprintf(
'Une matière avec le code "%s" existe déjà dans cet établissement.',
(string) $code,
));
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Administration\Domain\Exception;
use RuntimeException;
use function sprintf;
final class SubjectNameInvalideException extends RuntimeException
{
public static function pourLongueur(string $value, int $min, int $max): self
{
return new self(sprintf(
'Le nom de matière "%s" doit contenir entre %d et %d caractères.',
$value,
$min,
$max,
));
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Administration\Domain\Exception;
use App\Administration\Domain\Model\Subject\SubjectId;
use RuntimeException;
use function sprintf;
final class SubjectNonSupprimableException extends RuntimeException
{
public static function avecNotes(SubjectId $id): self
{
return new self(sprintf(
'La matière "%s" ne peut pas être supprimée car des notes y sont associées.',
(string) $id,
));
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace App\Administration\Domain\Exception;
use App\Administration\Domain\Model\Subject\SubjectId;
use RuntimeException;
use function sprintf;
final class SubjectNotFoundException extends RuntimeException
{
public static function withId(SubjectId $id): self
{
return new self(sprintf('Matière "%s" non trouvée.', (string) $id));
}
}