@@ -128,8 +128,7 @@ discard block |
||
| 128 | 128 | // Unit is in a state that is within the set of valid states so add to result set |
| 129 | 129 | $units[$unit] = $unit; |
| 130 | 130 | $response->addMatch($keyed_units[$unit], CalendarResponse::VALID_STATE); |
| 131 | - } |
|
| 132 | - else { |
|
| 131 | + } else { |
|
| 133 | 132 | $response->addMiss($keyed_units[$unit], CalendarResponse::INVALID_STATE); |
| 134 | 133 | } |
| 135 | 134 | |
@@ -223,8 +222,7 @@ discard block |
||
| 223 | 222 | foreach ($days as $day => $value) { |
| 224 | 223 | $result[$year][$month][$day] = ((int)$db_events[$unit][Event::BAT_DAY][$year][$month][$day] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][Event::BAT_DAY][$year][$month][$day]); |
| 225 | 224 | } |
| 226 | - } |
|
| 227 | - else { |
|
| 225 | + } else { |
|
| 228 | 226 | foreach ($days as $day => $value) { |
| 229 | 227 | $result[$year][$month][$day] = $keyed_units[$unit]->getDefaultValue(); |
| 230 | 228 | } |
@@ -254,8 +252,7 @@ discard block |
||
| 254 | 252 | foreach ($hours as $hour => $value) { |
| 255 | 253 | if (isset($db_events[$unit][Event::BAT_HOUR][$year][$month][$day][$hour])) { |
| 256 | 254 | $result[$year][$month][$day][$hour] = ((int) $db_events[$unit][Event::BAT_HOUR][$year][$month][$day][$hour] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int) $db_events[$unit][Event::BAT_HOUR][$year][$month][$day][$hour]); |
| 257 | - } |
|
| 258 | - else { |
|
| 255 | + } else { |
|
| 259 | 256 | // If nothing from db - then revert to the defaults |
| 260 | 257 | $result[$year][$month][$day][$hour] = (int) $keyed_units[$unit]->getDefaultValue(); |
| 261 | 258 | } |
@@ -301,8 +298,7 @@ discard block |
||
| 301 | 298 | foreach ($minutes as $minute => $value) { |
| 302 | 299 | if (isset($db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute])) { |
| 303 | 300 | $result[$year][$month][$day][$hour][$minute] = ((int) $db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int) $db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute]); |
| 304 | - } |
|
| 305 | - else { |
|
| 301 | + } else { |
|
| 306 | 302 | // If nothing from db - then revert to the defaults |
| 307 | 303 | $result[$year][$month][$day][$hour][$minute] = (int) $keyed_units[$unit]->getDefaultValue(); |
| 308 | 304 | } |
@@ -377,8 +373,7 @@ discard block |
||
| 377 | 373 | if ($current_value === $minute_value) { |
| 378 | 374 | // We are still in minutes and going through so add a minute |
| 379 | 375 | $end_event->add(new \DateInterval('PT1M')); |
| 380 | - } |
|
| 381 | - elseif (($current_value != $minute_value) && ($current_value !== NULL)) { |
|
| 376 | + } elseif (($current_value != $minute_value) && ($current_value !== NULL)) { |
|
| 382 | 377 | // Value just switched - let us wrap up with current event and start a new one |
| 383 | 378 | $normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 384 | 379 | $start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
@@ -392,12 +387,10 @@ discard block |
||
| 392 | 387 | } |
| 393 | 388 | $current_value = $minute_value; |
| 394 | 389 | } |
| 395 | - } |
|
| 396 | - elseif ($current_value === $hour_value) { |
|
| 390 | + } elseif ($current_value === $hour_value) { |
|
| 397 | 391 | // We are in hours and can add something |
| 398 | 392 | $end_event->add(new \DateInterval('PT1H')); |
| 399 | - } |
|
| 400 | - elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
|
| 393 | + } elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
|
| 401 | 394 | // Value just switched - let us wrap up with current event and start a new one |
| 402 | 395 | $normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 403 | 396 | // Start event becomes the end event with a minute added |
@@ -414,12 +407,10 @@ discard block |
||
| 414 | 407 | $current_value = $hour_value; |
| 415 | 408 | } |
| 416 | 409 | } |
| 417 | - } |
|
| 418 | - elseif ($current_value === $value) { |
|
| 410 | + } elseif ($current_value === $value) { |
|
| 419 | 411 | // We are adding a whole day so the end event gets moved to the end of the day we are adding |
| 420 | 412 | $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 421 | - } |
|
| 422 | - elseif (($current_value !== $value) && ($current_value !== NULL)) { |
|
| 413 | + } elseif (($current_value !== $value) && ($current_value !== NULL)) { |
|
| 423 | 414 | // Value just switched - let us wrap up with current event and start a new one |
| 424 | 415 | $normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 425 | 416 | // Start event becomes the end event with a minute added |
@@ -454,8 +445,7 @@ discard block |
||
| 454 | 445 | if ($event->endsLater($end_date)) { |
| 455 | 446 | $event->setEndDate($end_date); |
| 456 | 447 | } |
| 457 | - } |
|
| 458 | - else { |
|
| 448 | + } else { |
|
| 459 | 449 | // Event completely not in range so unset it |
| 460 | 450 | unset($normalized_events[$unit_id][$key]); |
| 461 | 451 | } |
@@ -486,8 +476,7 @@ discard block |
||
| 486 | 476 | $e++; |
| 487 | 477 | $flipped[$e][$value][$datum] = $datum; |
| 488 | 478 | $old_value = $value; |
| 489 | - } |
|
| 490 | - else { |
|
| 479 | + } else { |
|
| 491 | 480 | $flipped[$e][$value][$datum] = $datum; |
| 492 | 481 | } |
| 493 | 482 | } |