fix: harden sessions and domain validation
This commit is contained in:
@@ -3,6 +3,9 @@ declare(strict_types=1);
|
||||
|
||||
function calculate_sla_usage(float $allocatedHours, array $hours): array
|
||||
{
|
||||
if ($allocatedHours < 0) {
|
||||
throw new InvalidArgumentException('Allocated hours must not be negative.');
|
||||
}
|
||||
$used = round(array_sum(array_map(static fn ($value): float => max(0.0, (float)$value), $hours)), 2);
|
||||
$remaining = round(max(0.0, $allocatedHours - $used), 2);
|
||||
$percentage = $allocatedHours > 0 ? round(($used / $allocatedHours) * 100, 2) : ($used > 0 ? 100.0 : 0.0);
|
||||
|
||||
Reference in New Issue
Block a user