29 lines
787 B
PHP
29 lines
787 B
PHP
<?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,
|
|
static fn ($entry): bool => is_array($entry) && (($entry['counts_toward_sla'] ?? true) === true)
|
|
)));
|
|
}
|
|
}
|