Skip to content

Instantly share code, notes, and snippets.


mcsee/Date.php Secret

Last active Sep 6, 2020
What would you like to do?
final class Date{
function __construct($aMonthDay, $aMonth) {
if (!$aMonth->includes($aMonthDay)) {
throw new InvalidDateException($aMonthDay, $aMonth);
$day30 = new Day(30);
$year2020 = new Year(2020);
$feb2020 = new YearMonth(2, $year2020);
$invalidDate = new Date($day30, $feb2020);
//will raise an exception.
//No, It will not coerce to March,1st or do "under the rug magic" to coverup the programmer contract violation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment