add static builder
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
function endOfSubscriptionIsNear1(
|
||||
DateTime $today,
|
||||
DateTime $endOfSubscription
|
||||
) {
|
||||
return $endOfSubscription < $today->modify('+15 days');
|
||||
}
|
||||
|
||||
function endOfSubscriptionIsNear2(
|
||||
DateTime $endOfSubscription
|
||||
) {
|
||||
return $endOfSubscription < (new DateTime)->modify('+15 days');
|
||||
}
|
||||
|
||||
$closedEndOfSubscription = (new DateTime)->modify('+14 days');
|
||||
$farEndOfSubscription = (new DateTime)->modify('+16 days');
|
||||
|
||||
vprintf("Using new object should be 1: %d\n", endOfSubscriptionIsNear1(new DateTime, $closedEndOfSubscription));
|
||||
vprintf("Using new object should be 0: %d\n", endOfSubscriptionIsNear1(new DateTime, $farEndOfSubscription));
|
||||
|
||||
$today = new DateTime;
|
||||
$endOfSubscription = (new DateTime)->modify('+16 days');
|
||||
|
||||
vprintf("First call: %d\n", endOfSubscriptionIsNear1($today, $endOfSubscription));
|
||||
vprintf("Second call: %d\n", endOfSubscriptionIsNear1($today, $endOfSubscription));
|
||||
Reference in New Issue
Block a user