Conditions | 5 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
33 | protected static function nextBillingDate(\DateTime $startDate, $period, $interval) |
||
34 | { |
||
35 | $startDate = Date::instance($startDate)->setHour(8)->setMinute(0); |
||
36 | |||
37 | switch ($period) { |
||
38 | case BillingPeriod::DAILY: |
||
39 | return $startDate->addDays($interval); |
||
40 | |||
41 | case BillingPeriod::WEEKLY: |
||
42 | return $startDate->addWeeks($interval); |
||
43 | |||
44 | case BillingPeriod::MONTHLY: |
||
45 | return $startDate->addMonthsNoOverflow($interval); |
||
46 | |||
47 | case BillingPeriod::YEARLY: |
||
48 | return $startDate->addYears($interval); |
||
49 | } |
||
50 | throw new \InvalidArgumentException("Invalid period [{$period}] provided."); |
||
51 | } |
||
53 |