From 50963885f0bc985e2d46274e8691e3bff892b0e0 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 8 Oct 2025 09:06:05 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- src/exceptions.php | 105 --------------------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 src/exceptions.php diff --git a/src/exceptions.php b/src/exceptions.php deleted file mode 100644 index afad896..0000000 --- a/src/exceptions.php +++ /dev/null @@ -1,105 +0,0 @@ -_ce(); - $msg .= " est invalide"; - if ($reason) $msg .= ": $reason"; - return new UserException($msg); - } - - /** - * spécialisation de {@link self::invalid_value()} qui permet d'indiquer les - * types attendus - */ - static function invalid_type($value, $expectedTypes=null): UserException { - $pronom = self::word()->pronom(); - $expectedTypes = cl::withn($expectedTypes); - if (!$expectedTypes) { - $reason = null; - } elseif (count($expectedTypes) == 1) { - $reason = "$pronom doit être du type suivant: "; - } else { - $reason = "$pronom doit être d'un des types suivants: "; - } - $reason .= implode(", ", $expectedTypes); - return self::invalid_value($value, $reason); - } - - static function invalid_format($value, $expectedFormats=null): UserException { - $pronom = self::word()->pronom(); - $expectedFormats = cl::withn($expectedFormats); - if (!$expectedFormats) { - $reason = null; - } elseif (count($expectedFormats) == 1) { - $reason = "$pronom doit être au format suivant: "; - } else { - $reason = "$pronom doit être dans l'un des formats suivants: "; - } - $reason .= implode(", ", $expectedFormats); - return self::invalid_value($value, $reason); - } - - static function out_of_range($value, ?int $min=null, ?int $max=null): UserException { - $pronom = self::word()->pronom(); - if ($min !== null && $max !== null) { - $reason = "$pronom doit être compris entre $min et $max"; - } else if ($min !== null) { - $reason = "$pronom doit être supérieur à $min"; - } elseif ($max !== null) { - $reason = "$pronom doit être inférieur à $max"; - } else { - $reason = null; - } - return self::invalid_value($value, $reason); - } - - static function null_value(?string $reason=null): UserException { - $msg = self::word()->_ce(); - $msg .= " ne doit pas être nulle"; - if ($reason) $msg .= ": $reason"; - return new UserException($msg); - } - - /** - * indiquer qu'une valeur est manquante - */ - static function missing_value(?int $amout=null, ?string $reason=null): UserException { - $msg = "il manque "; - if ($amout !== null) { - $msg .= self::word()->q($amout); - } else { - $msg .= self::word()->_le(); - } - if ($reason) $msg .= ": $reason"; - return new UserException($msg); - } - - /** - * indiquer qu'une valeur est en trop - */ - static function unexpected_value(?string $reason=null): UserException { - $msg = "il y a trop "; - $msg .= self::word()->_de(2); - if ($reason) $msg .= ": $reason"; - return new UserException($msg); - } -}