| Conditions | 6 |
| Paths | 16 |
| Total Lines | 15 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 34 | public function getDatesListByPeriod($startDate, $endDate, $format = null, $step = self::DAY) |
||
| 35 | { |
||
| 36 | $startTimestamp = (is_int($startDate)) ? $startDate : strtotime($startDate); |
||
| 37 | $endTimestamp = (is_int($endDate)) ? $endDate : strtotime($endDate); |
||
| 38 | if ($startTimestamp >= $endTimestamp) { |
||
| 39 | throw new \Exception('Dates interval is not valid'); |
||
| 40 | } |
||
| 41 | $dates = []; |
||
| 42 | $current = $startTimestamp; |
||
| 43 | while($current <= $endTimestamp) { |
||
| 44 | $dates[] = ($format) ? date($format, $current) : $current; |
||
| 45 | $current += $step; |
||
| 46 | } |
||
| 47 | return $dates; |
||
| 48 | } |
||
| 49 | |||
| 72 | } |