v-matsuk/time-overlap-calculator
Time Overlap Calculator is a Laravel/PHP package for comparing time intervals and calculating overlaps. Detect scheduling conflicts, find shared durations, and simplify booking, availability, or resource allocation logic with a small, reusable API.
composer require v-matsuk/time-overlap-calculator
bootstrap/providers.php. composer require is the entire setup.vendor/v-matsuk/time-overlap-calculator/src/. The public surface is tiny — expect one calculator class, possibly a small value object for a time range. Confirm the real namespace and method names from its composer.json and class docblocks; you can read the whole thing in five minutes.A minimal call, shaped like most such libraries:
// Confirm exact class + method names by reading src/
$overlap = (new TimeOverlapCalculator())
->setStart('2024-06-01 09:00:00')
->setEnd('2024-06-01 12:00:00')
->setCompareStart('2024-06-01 11:00:00')
->setCompareEnd('2024-06-01 13:00:00');
// returns overlap duration / bool depending on the method you call
TimeRangeOverlapService in the container and inject it; this gives you the only real "extension point" the package lacks.DateTimeImmutable (or whatever the package expects — string vs. timestamp matters) in exactly one place, always in UTC, before handing off.WHERE start < :newEnd AND end > :newStart — then use the library only on the small candidate set for the precise result.TimeRange value object with startsAt(), endsAt(), and overlaps(TimeRange $other): bool; keep the third-party call in one method so it's swappable.app/Support.[09:00, 10:00) overlapping [10:00, 11:00)? Most overlap libraries say no, but confirm against this one with an explicit test — this is where production incidents come from.start < end) before calling; behaviour on bad input is likely undefined rather than an exception.dd() the four normalized timestamps you pass in — that catch 95% of "library bugs."$aStart < $bEnd && $bStart < $aEnd with Carbon. Reach for this package only if you genuinely need the duration/percentage helpers; otherwise use spatie/period, which is actively maintained and Laravel-friendly.How can I help you explore Laravel packages today?