<?php

declare(strict_types=1);

namespace App\Dto\WorkHours;

final class WorkMetrics
{
    public function __construct(
        public int $dayMinutes = 0,
        public int $nightMinutes = 0,
        public int $totalMinutes = 0,
    ) {}

    public function addCreditedMinutes(int $creditedMinutes): void
    {
        // Ignore les valeurs nulles ou négatives pour ne pas biaiser les totaux.
        if ($creditedMinutes <= 0) {
            return;
        }

        // Le crédit absence alimente les heures de jour et le total.
        $this->dayMinutes += $creditedMinutes;
        $this->totalMinutes += $creditedMinutes;
    }
}
