League Period: A Swiss Army Knife for Time Intervals in PHP

php dev.to

Originally published at recca0120.github.io Have you ever written this kind of code — checking whether two time intervals overlap? if ($startA $endB && $startB $endA) { // overlap } Looks simple, but add boundary conditions (include endpoints or not?), more intervals (what about three?), and gap detection (which time slots aren't covered?), and the code explodes. League Period wraps time intervals into immutable value objects with built-in overlap, containment, gap, and intersec

Read Full Tutorial open_in_new
arrow_back Back to Tutorials