feat: bootstrap JOBcard CRM foundation
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?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)
|
||||
)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user