fix: traiter le deuxième lot de tickets

Refs #1 #2 #3 #13 #17
This commit is contained in:
Alexandre NOEL 2026-09-07 23:55:59 +02:00
commit 220c0ece82
18 changed files with 95 additions and 22 deletions

View file

@ -4,6 +4,29 @@ declare(strict_types=1);
final class Ids
{
public static function validRna(string $value): bool
{
$value = strtoupper(preg_replace('/\s+/', '', trim($value)) ?? '');
return $value === '' || preg_match('/^W[0-9]{9}$/', $value) === 1;
}
public static function validSiret(string $value): bool
{
$digits = preg_replace('/\D+/', '', trim($value)) ?? '';
if ($digits === '') {
return true;
}
if (strlen($digits) !== 14) {
return false;
}
$sum = 0;
foreach (str_split($digits) as $index => $digit) {
$number = (int) $digit * ($index % 2 === 0 ? 2 : 1);
$sum += $number > 9 ? $number - 9 : $number;
}
return $sum % 10 === 0;
}
public static function slugifyUpper(string $s): string
{
$s = trim($s);