<?php

namespace App\Modules\HR\Shifts\Support;

use App\Modules\HR\Shifts\Models\Shift;
use Carbon\CarbonImmutable;

final class ShiftScheduleMinutes
{
    public static function scheduledWorkMinutes(Shift $shift): int
    {
        $d = CarbonImmutable::parse('2010-01-15');
        $start = ShiftScheduleEndpoints::shiftStartOnDate($shift, $d);
        $end = ShiftScheduleEndpoints::shiftEndOnDate($shift, $d);
        $span = max(0, $start->diffInMinutes($end));

        return max(0, $span - (int) $shift->break_minutes);
    }
}
