fix logic and tests, update docker CI file

This commit is contained in:
root
2026-03-09 15:58:44 -04:00
parent 1cb3573d4b
commit 79e44fe037
188 changed files with 1776 additions and 524 deletions
+10 -6
View File
@@ -6,20 +6,24 @@ class FeeGradeService
{
public function normalizeGrade(?string $grade): string
{
return strtoupper(trim((string) $grade));
$normalized = strtoupper(trim((string) $grade));
return str_replace([' ', '-'], '', $normalized);
}
public function compareGrades(string $gradeA, string $gradeB): int
{
$valA = $this->getGradeLevel($gradeA);
$valB = $this->getGradeLevel($gradeB);
$normA = $this->normalizeGrade($gradeA);
$normB = $this->normalizeGrade($gradeB);
$valA = $this->getGradeLevel($normA);
$valB = $this->getGradeLevel($normB);
if ($valA !== $valB) {
return $valA <=> $valB;
}
preg_match('/\d+([A-Z]*)$/i', strtoupper($gradeA), $suffixA);
preg_match('/\d+([A-Z]*)$/i', strtoupper($gradeB), $suffixB);
preg_match('/\d+([A-Z]*)$/i', $normA, $suffixA);
preg_match('/\d+([A-Z]*)$/i', $normB, $suffixB);
return strcmp($suffixA[1] ?? '', $suffixB[1] ?? '');
}
@@ -35,7 +39,7 @@ class FeeGradeService
return 99;
}
if (preg_match('/^(\d+)([A-Z]*)$/i', $grade, $matches)) {
if (preg_match('/^(\d+)/', $grade, $matches)) {
return (int) $matches[1];
}