@@ -127,8 +127,7 @@ discard block |
||
| 127 | 127 | // Unit is in a state that is within the set of valid states so add to result set |
| 128 | 128 | $units[$unit] = $unit; |
| 129 | 129 | $response->addMatch($keyed_units[$unit], CalendarResponse::VALID_STATE); |
| 130 | - } |
|
| 131 | - else { |
|
| 130 | + } else { |
|
| 132 | 131 | $response->addMiss($keyed_units[$unit], CalendarResponse::INVALID_STATE); |
| 133 | 132 | } |
| 134 | 133 | |
@@ -178,8 +177,7 @@ discard block |
||
| 178 | 177 | foreach ($days as $day => $value) { |
| 179 | 178 | $events[$unit][Event::BAT_DAY][$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]); |
| 180 | 179 | } |
| 181 | - } |
|
| 182 | - else { |
|
| 180 | + } else { |
|
| 183 | 181 | foreach ($days as $day => $value) { |
| 184 | 182 | $events[$unit][Event::BAT_DAY][$year][$month][$day] = $keyed_units[$unit]->getDefaultValue(); |
| 185 | 183 | } |
@@ -196,8 +194,7 @@ discard block |
||
| 196 | 194 | foreach ($hours as $hour => $value) { |
| 197 | 195 | if (isset($db_events[$unit][Event::BAT_HOUR][$year][$month][$day][$hour])) { |
| 198 | 196 | $events[$unit][Event::BAT_HOUR][$year][$month]['d' . $day][$hour] = ((int)$db_events[$unit][Event::BAT_DAY][$year][$month][$day][$hour] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour]); |
| 199 | - } |
|
| 200 | - else { |
|
| 197 | + } else { |
|
| 201 | 198 | // If nothing from db - then revert to the defaults |
| 202 | 199 | $events[$unit][Event::BAT_HOUR][$year][$month][$day][$hour] = (int)$keyed_units[$unit]->getDefaultValue(); |
| 203 | 200 | } |
@@ -227,8 +224,7 @@ discard block |
||
| 227 | 224 | foreach ($minutes as $minute => $value) { |
| 228 | 225 | if (isset($db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute])) { |
| 229 | 226 | $events[$unit][Event::BAT_MINUTE][$year][$month]['d' .$day]['h'.$hour][$minute] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute]); |
| 230 | - } |
|
| 231 | - else { |
|
| 227 | + } else { |
|
| 232 | 228 | // If nothing from db - then revert to the defaults |
| 233 | 229 | $events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute] = (int)$keyed_units[$unit]->getDefaultValue(); |
| 234 | 230 | } |
@@ -311,8 +307,7 @@ discard block |
||
| 311 | 307 | if ($current_value === $minute_value) { |
| 312 | 308 | // We are still in minutes and going through so add a minute |
| 313 | 309 | $end_event->add(new \DateInterval('PT1M')); |
| 314 | - } |
|
| 315 | - elseif (($current_value != $minute_value) && ($current_value !== NULL)) { |
|
| 310 | + } elseif (($current_value != $minute_value) && ($current_value !== NULL)) { |
|
| 316 | 311 | // Value just switched - let us wrap up with current event and start a new one |
| 317 | 312 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
| 318 | 313 | $start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
@@ -326,12 +321,10 @@ discard block |
||
| 326 | 321 | } |
| 327 | 322 | $current_value = $minute_value; |
| 328 | 323 | } |
| 329 | - } |
|
| 330 | - elseif ($current_value === $hour_value) { |
|
| 324 | + } elseif ($current_value === $hour_value) { |
|
| 331 | 325 | // We are in hours and can add something |
| 332 | 326 | $end_event->add(new \DateInterval('PT1H')); |
| 333 | - } |
|
| 334 | - elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
|
| 327 | + } elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
|
| 335 | 328 | // Value just switched - let us wrap up with current event and start a new one |
| 336 | 329 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
| 337 | 330 | // Start event becomes the end event with a minute added |
@@ -348,12 +341,10 @@ discard block |
||
| 348 | 341 | $current_value = $hour_value; |
| 349 | 342 | } |
| 350 | 343 | } |
| 351 | - } |
|
| 352 | - elseif ($current_value === $value) { |
|
| 344 | + } elseif ($current_value === $value) { |
|
| 353 | 345 | // We are adding a whole day so the end event gets moved to the end of the day we are adding |
| 354 | 346 | $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 355 | - } |
|
| 356 | - elseif (($current_value !== $value) && ($current_value !== NULL)) { |
|
| 347 | + } elseif (($current_value !== $value) && ($current_value !== NULL)) { |
|
| 357 | 348 | // Value just switched - let us wrap up with current event and start a new one |
| 358 | 349 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
| 359 | 350 | // Start event becomes the end event with a minute added |
@@ -388,8 +379,7 @@ discard block |
||
| 388 | 379 | if ($event->endsLater($end_date)) { |
| 389 | 380 | $event->setEndDate($end_date); |
| 390 | 381 | } |
| 391 | - } |
|
| 392 | - else { |
|
| 382 | + } else { |
|
| 393 | 383 | // Event completely not in range so unset it |
| 394 | 384 | unset($normalized_events[$unit][$key]); |
| 395 | 385 | } |
@@ -420,8 +410,7 @@ discard block |
||
| 420 | 410 | $e++; |
| 421 | 411 | $flipped[$e][$value][$datum] = $datum; |
| 422 | 412 | $old_value = $value; |
| 423 | - } |
|
| 424 | - else { |
|
| 413 | + } else { |
|
| 425 | 414 | $flipped[$e][$value][$datum] = $datum; |
| 426 | 415 | } |
| 427 | 416 | } |
@@ -166,8 +166,7 @@ |
||
| 166 | 166 | fwrite($minutefile, json_encode($minutefile_content)); |
| 167 | 167 | fclose($minutefile); |
| 168 | 168 | } |
| 169 | - } |
|
| 170 | - catch (\Exception $e) { |
|
| 169 | + } catch (\Exception $e) { |
|
| 171 | 170 | $saved = FALSE; |
| 172 | 171 | } |
| 173 | 172 | |