Last active
August 23, 2023 00:21
-
-
Save mcsee/0a519a375e302a5d25ec09185bf95312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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