@@ -8,7 +8,6 @@ |
||
8 | 8 | namespace Roomify\Bat\Event; |
9 | 9 | |
10 | 10 | use Roomify\Bat\Event\EventInterface; |
11 | -use Roomify\Bat\Unit\Unit; |
|
12 | 11 | |
13 | 12 | /** |
14 | 13 | * The EventItemizer class does the hard work of splitting an event into discrete time |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $dayrange = new \DatePeriod($this->event->getStartDate(), $dayinterval, $this->event->endMonthDate($this->event->getStartDate())); |
161 | 161 | } |
162 | 162 | foreach ($dayrange as $day) { |
163 | - $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d' . $day->format('j')] = $this->event->getValue(); |
|
163 | + $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d'.$day->format('j')] = $this->event->getValue(); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | elseif ($this->event->isLastMonth($date)) { |
169 | 169 | $dayrange = new \DatePeriod(new \DateTime($date->format("Y-n-1")), $dayinterval, $this->event->getEndDate()); |
170 | 170 | foreach ($dayrange as $day) { |
171 | - $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d' . $day->format('j')] = $this->event->getValue(); |
|
171 | + $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d'.$day->format('j')] = $this->event->getValue(); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | else { |
177 | 177 | $dayrange = new \DatePeriod(new \DateTime($date->format("Y-n-1")), $dayinterval, new \DateTime($date->format("Y-n-t 23:59:59"))); |
178 | 178 | foreach ($dayrange as $day) { |
179 | - $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d' . $day->format('j')] = $this->event->getValue(); |
|
179 | + $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d'.$day->format('j')] = $this->event->getValue(); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -217,35 +217,35 @@ discard block |
||
217 | 217 | if ($this->event->isSameDay()) { |
218 | 218 | if (!($this->event->getStartDate()->format('H:i') == '00:00' && $this->event->getEndDate()->format('H:i') == '23:59')) { |
219 | 219 | $itemized_same_day = $this->createHourlyGranular($start_date, $end_date->add(new \DateInterval('PT1M')), $interval, $start_date); |
220 | - $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
|
221 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
|
222 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
|
220 | + $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d'.$sd] = -1; |
|
221 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd]; |
|
222 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd]; |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | else { |
226 | 226 | // Deal with the start day unless it starts on midnight precisely at which point the whole day is booked |
227 | 227 | if (!($this->event->getStartDate()->format('H:i') == '00:00')) { |
228 | 228 | $itemized_start = $this->createHourlyGranular($start_date, new \DateTime($start_date->format("Y-n-j 23:59:59")), $interval, $start_date); |
229 | - $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
|
230 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
|
231 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
|
229 | + $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d'.$sd] = -1; |
|
230 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd]; |
|
231 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd]; |
|
232 | 232 | } |
233 | 233 | else { |
234 | 234 | // Just set an empty hour and minute |
235 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = array(); |
|
236 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = array(); |
|
235 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = array(); |
|
236 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = array(); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | // Deal with the end date unless it ends just before midnight at which point we don't need to go further |
240 | 240 | if ($this->event->getEndDate()->format('H:i') == '23:59') { |
241 | - $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = array(); |
|
242 | - $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = array(); |
|
241 | + $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed] = array(); |
|
242 | + $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed] = array(); |
|
243 | 243 | } |
244 | 244 | else { |
245 | 245 | $itemized_end = $this->createHourlyGranular(new \DateTime($end_date->format("Y-n-j 00:00:00")), $end_date->add(new \DateInterval('PT1M')), $interval, new \DateTime($end_date->format("Y-n-j 00:00:00"))); |
246 | - $itemized[EventItemizer::BAT_DAY][$ey][$em]['d' . $ed] = -1; |
|
247 | - $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed]; |
|
248 | - $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed]; |
|
246 | + $itemized[EventItemizer::BAT_DAY][$ey][$em]['d'.$ed] = -1; |
|
247 | + $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed]; |
|
248 | + $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed] = $itemized_end[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed]; |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | // Doing minutes so set the values in the minute array |
287 | - $itemized[EventItemizer::BAT_MINUTE][$year][$month]['d' . $day]['h' . $hour]['m' . $min] = $event_value; |
|
287 | + $itemized[EventItemizer::BAT_MINUTE][$year][$month]['d'.$day]['h'.$hour]['m'.$min] = $event_value; |
|
288 | 288 | // Let the hours know that it cannot determine availability |
289 | - $itemized[EventItemizer::BAT_HOUR][$year][$month]['d' . $day]['h' . $hour] = -1; |
|
289 | + $itemized[EventItemizer::BAT_HOUR][$year][$month]['d'.$day]['h'.$hour] = -1; |
|
290 | 290 | $min++; |
291 | 291 | |
292 | 292 | if ($min == 60 && $start_minute !== 0) { |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | elseif ($min == 60 && $start_minute == 0) { |
299 | 299 | // Did a real whole hour so initialize the hour |
300 | - $itemized[EventItemizer::BAT_HOUR][$year][$month]['d' . $day]['h' . $hour] = $event_value; |
|
300 | + $itemized[EventItemizer::BAT_HOUR][$year][$month]['d'.$day]['h'.$hour] = $event_value; |
|
301 | 301 | |
302 | 302 | $min = 0; |
303 | 303 | $hour++; |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | |
325 | 325 | $hour = $date->format('G'); |
326 | 326 | for ($i = 0; $i < 60; $i++) { |
327 | - $minute = ($i < 10) ? '0' . $i : $i; |
|
327 | + $minute = ($i < 10) ? '0'.$i : $i; |
|
328 | 328 | |
329 | - $itemized[EventItemizer::BAT_MINUTE][$date->format('Y')][$date->format('n')]['d' . $date->format('j')]['h' . $hour]['m' . $minute] = $this->event->getValue(); |
|
329 | + $itemized[EventItemizer::BAT_MINUTE][$date->format('Y')][$date->format('n')]['d'.$date->format('j')]['h'.$hour]['m'.$minute] = $this->event->getValue(); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | } |
@@ -129,8 +129,7 @@ discard block |
||
129 | 129 | // We add a minute to compensate |
130 | 130 | elseif (($this->event->getStartDate()->format('Y-m-d H:i') == $this->event->getEndDate()->format('Y-m-d H:i')) && $this->granularity == EventItemizer::BAT_DAILY) { |
131 | 131 | $adjusted_end_day = new \DateTime($this->event->getEndDate()->add(new \DateInterval('PT1M'))->format('Y-m-d H:i')); |
132 | - } |
|
133 | - else { |
|
132 | + } else { |
|
134 | 133 | $adjusted_end_day = new \DateTime($this->event->getEndDate()->format('Y-m-d H:i')); |
135 | 134 | } |
136 | 135 | |
@@ -221,16 +220,14 @@ discard block |
||
221 | 220 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
222 | 221 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
223 | 222 | } |
224 | - } |
|
225 | - else { |
|
223 | + } else { |
|
226 | 224 | // Deal with the start day unless it starts on midnight precisely at which point the whole day is booked |
227 | 225 | if (!($this->event->getStartDate()->format('H:i') == '00:00')) { |
228 | 226 | $itemized_start = $this->createHourlyGranular($start_date, new \DateTime($start_date->format("Y-n-j 23:59:59")), $interval, $start_date); |
229 | 227 | $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
230 | 228 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
231 | 229 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
232 | - } |
|
233 | - else { |
|
230 | + } else { |
|
234 | 231 | // Just set an empty hour and minute |
235 | 232 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = array(); |
236 | 233 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = array(); |
@@ -240,8 +237,7 @@ discard block |
||
240 | 237 | if ($this->event->getEndDate()->format('H:i') == '23:59') { |
241 | 238 | $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = array(); |
242 | 239 | $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = array(); |
243 | - } |
|
244 | - else { |
|
240 | + } else { |
|
245 | 241 | $itemized_end = $this->createHourlyGranular(new \DateTime($end_date->format("Y-n-j 00:00:00")), $end_date->add(new \DateInterval('PT1M')), $interval, new \DateTime($end_date->format("Y-n-j 00:00:00"))); |
246 | 242 | $itemized[EventItemizer::BAT_DAY][$ey][$em]['d' . $ed] = -1; |
247 | 243 | $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed]; |
@@ -294,8 +290,7 @@ discard block |
||
294 | 290 | $min = 0; |
295 | 291 | $hour++; |
296 | 292 | $start_minute = 0; |
297 | - } |
|
298 | - elseif ($min == 60 && $start_minute == 0) { |
|
293 | + } elseif ($min == 60 && $start_minute == 0) { |
|
299 | 294 | // Did a real whole hour so initialize the hour |
300 | 295 | $itemized[EventItemizer::BAT_HOUR][$year][$month]['d' . $day]['h' . $hour] = $event_value; |
301 | 296 |