Files

29 lines
806 B
PHP
Raw Permalink Normal View History

2026-09-01 18:54:47 +02:00
<?php
declare(strict_types=1);
namespace App\Domain\Jobcard;
final class TimeAggregator
{
public function total(array $entries): float
{
$total = 0.0;
foreach ($entries as $entry) {
if (is_array($entry) && isset($entry['hours']) && is_numeric($entry['hours'])) {
$total += max(0.0, (float) $entry['hours']);
} elseif (is_numeric($entry)) {
$total += max(0.0, (float) $entry);
}
}
return round($total, 2);
}
public function slaTotal(array $entries): float
{
return $this->total(array_values(array_filter(
$entries,
2026-09-01 18:58:18 +02:00
static fn ($entry): bool => is_array($entry) && in_array($entry['counts_toward_sla'] ?? true, [true, 1, '1'], true)
2026-09-01 18:54:47 +02:00
)));
}
}