Last active
July 13, 2016 02:27
-
-
Save pierswarmers/60f52ae03bce5bbbf43c to your computer and use it in GitHub Desktop.
ManDate Example
This file contains hidden or 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
| <?php | |
| use ManDate\Mandate; | |
| use ManDate\Rule\WeekdayRule; | |
| use ManDate\Rule\DaytimeRule; | |
| use ManDate\Rule\MorningRule; | |
| $mandate = new Mandate(); | |
| $mandate | |
| ->andWhere(new WeekdayRule()) | |
| ->andWhere(new DaytimeRule()) | |
| ->andWhereNot(new MorningRule()) | |
| ; | |
| $date = new \DateTime('2015-03-02 11:30', new \DateTimeZone('Australia/Sydney')); | |
| if ($mandate->validate($date)) { | |
| echo 'It\'s a weekday afternoon!'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment