| Conditions | 4 |
| Paths | 1 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public static function validateDateRange(DateTimeInterface $start, DateTimeInterface $end) |
||
| 17 | { |
||
| 18 | $start = new Chronos($start); |
||
|
|
|||
| 19 | $end = new Chronos($end); |
||
| 20 | |||
| 21 | if ($start->isFuture()) { |
||
| 22 | throw new DateException("Start date \"{$start}\" must be in the past"); |
||
| 23 | } |
||
| 24 | |||
| 25 | if ($end->isFuture()) { |
||
| 26 | throw new DateException("End date \"{$end}\" must be in the past"); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($start > $end) { |
||
| 30 | throw new DateException("Start date \"{$start}\" must be smaller than end date \"{$end}\""); |
||
| 31 | } |
||
| 32 | |||
| 33 | return true; |
||
| 34 | } |
||
| 36 |