<?php

namespace App\Support\Works;

/**
 * Eventos «Observado» en bitácora de asignaciones para una OT concreta.
 *
 * @param  list<array{day: string, count: int}>  $countsByDayChronological
 * @param  list<array{recorded_at: string, technician: string, coordinator: string}>  $recentEventsDesc
 */
final readonly class WorkObservedIncidentsForWork
{
    public function __construct(
        public int $totalEvents,
        public int $distinctDays,
        public array $countsByDayChronological,
        public array $recentEventsDesc,
    ) {}

    public function hasData(): bool
    {
        return $this->totalEvents > 0;
    }

    public function maxDayCount(): int
    {
        $max = 0;
        foreach ($this->countsByDayChronological as $row) {
            $max = max($max, $row['count']);
        }

        return $max;
    }
}
