add more controllers and fix tests

This commit is contained in:
root
2026-03-09 11:54:13 -04:00
parent 0c3e9b16f7
commit 1cb3573d4b
74 changed files with 2761 additions and 2728 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Services\Fees;
class FeeGradeService
{
public function normalizeGrade(?string $grade): string
{
return strtoupper(trim((string) $grade));
}
public function compareGrades(string $gradeA, string $gradeB): int
{
$valA = $this->getGradeLevel($gradeA);
$valB = $this->getGradeLevel($gradeB);
if ($valA !== $valB) {
return $valA <=> $valB;
}
preg_match('/\d+([A-Z]*)$/i', strtoupper($gradeA), $suffixA);
preg_match('/\d+([A-Z]*)$/i', strtoupper($gradeB), $suffixB);
return strcmp($suffixA[1] ?? '', $suffixB[1] ?? '');
}
public function getGradeLevel(string $grade): int
{
$grade = $this->normalizeGrade($grade);
if ($grade === 'K') {
return 0;
}
if ($grade === 'Y') {
return 99;
}
if (preg_match('/^(\d+)([A-Z]*)$/i', $grade, $matches)) {
return (int) $matches[1];
}
return 999;
}
}