@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string $startTime \Datetime start time string compatible with php Datetime class. example: '08:00' |
31 | 31 | * @param string $endTime \Datetime end time string compatible with php Datetime class. example: '17:00' |
32 | 32 | */ |
33 | - public function setTimeFrame( $startTime = null, $endTime = null ) |
|
33 | + public function setTimeFrame($startTime = null, $endTime = null) |
|
34 | 34 | { |
35 | 35 | if ($startTime != null && !empty($startTime)) { |
36 | 36 | $this->startTime = new \DateTime($startTime); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @param string $dateTimeStr \Datetime object valid date string |
50 | 50 | */ |
51 | - public function add( $dateTimeStr ) |
|
51 | + public function add($dateTimeStr) |
|
52 | 52 | { |
53 | 53 | $this->oneTimeEvents[] = new \DateTime($dateTimeStr); |
54 | 54 | return $this; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @param string $dateTimeStr \Datetime object valid date string |
61 | 61 | */ |
62 | - public function addRecurring( $dateTimeStr ) |
|
62 | + public function addRecurring($dateTimeStr) |
|
63 | 63 | { |
64 | 64 | $this->schedules[] = $dateTimeStr; |
65 | 65 | return $this; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $fromDateStr \Datetime object valid date string |
73 | 73 | * @return \Datetime or null |
74 | 74 | */ |
75 | - public function getNextSchedule( $fromDateStr = 'now' ) |
|
75 | + public function getNextSchedule($fromDateStr = 'now') |
|
76 | 76 | { |
77 | 77 | $dates = $this->getNextSchedules($fromDateStr, 1); |
78 | 78 | return count($dates) ? $dates[0] : null; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param int $limit number of dates to return |
87 | 87 | * @return array |
88 | 88 | */ |
89 | - public function getNextSchedules( $fromDateStr = 'now', $limit = 5 ) |
|
89 | + public function getNextSchedules($fromDateStr = 'now', $limit = 5) |
|
90 | 90 | { |
91 | 91 | $dates = []; |
92 | 92 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | foreach ($this->schedules as $schedule) { |
100 | 100 | $d = new \DateTime($fromDateStr); |
101 | 101 | |
102 | - for ($i=0, $maxRecursion = 100 * $limit; $i < $limit && $maxRecursion > 0; ++$i, --$maxRecursion) { |
|
102 | + for ($i = 0, $maxRecursion = 100 * $limit; $i < $limit && $maxRecursion > 0; ++$i, --$maxRecursion) { |
|
103 | 103 | |
104 | 104 | if (strpos($schedule, '+') !== false) { |
105 | 105 | if ($this->startTime instanceof \DateTime && $d < $this->startTime->modify($d->format('Y-m-d'))) { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | /** |
130 | 130 | * @param array $dates |
131 | 131 | */ |
132 | - private function orderDates( &$dates ) |
|
132 | + private function orderDates(&$dates) |
|
133 | 133 | { |
134 | 134 | uasort($dates, function($a, $b) { |
135 | 135 | return strtotime($a->format('Y-m-d H:i:s')) > strtotime($b->format('Y-m-d H:i:s')) ? 1 : -1; |
@@ -104,18 +104,15 @@ |
||
104 | 104 | if (strpos($schedule, '+') !== false) { |
105 | 105 | if ($this->startTime instanceof \DateTime && $d < $this->startTime->modify($d->format('Y-m-d'))) { |
106 | 106 | $d->modify($this->startTime->format('H:i:s')); |
107 | - } |
|
108 | - elseif ($this->endTime instanceof \DateTime && $d > $this->endTime->modify($d->format('Y-m-d'))) { |
|
107 | + } elseif ($this->endTime instanceof \DateTime && $d > $this->endTime->modify($d->format('Y-m-d'))) { |
|
109 | 108 | $d->modify('next day')->modify($this->startTime->format('H:i:s')); |
110 | 109 | } |
111 | 110 | |
112 | 111 | $dates[] = clone $d; |
113 | 112 | $d->modify($schedule); |
114 | - } |
|
115 | - elseif ($this->isInTimeFrame($d->modify($schedule), $fromDateStr)) { |
|
113 | + } elseif ($this->isInTimeFrame($d->modify($schedule), $fromDateStr)) { |
|
116 | 114 | $dates[] = clone $d; |
117 | - } |
|
118 | - else { |
|
115 | + } else { |
|
119 | 116 | --$i; |
120 | 117 | } |
121 | 118 | } |