@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | /** |
| 103 | 103 | * Set the start date. |
| 104 | 104 | * |
| 105 | - * @param DateTime $start_date |
|
| 105 | + * @param \DateTime $start_date |
|
| 106 | 106 | */ |
| 107 | 107 | public function setStartDate(\DateTime $start_date) { |
| 108 | 108 | $this->start_date = clone($start_date); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | /** |
| 129 | 129 | * Set the end date. |
| 130 | 130 | * |
| 131 | - * @param DateTime $end_date |
|
| 131 | + * @param \DateTime $end_date |
|
| 132 | 132 | */ |
| 133 | 133 | public function setEndDate(\DateTime $end_date) { |
| 134 | 134 | $this->end_date = clone($end_date); |
@@ -240,6 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | /** |
| 242 | 242 | * {@inheritdoc} |
| 243 | + * @param \DateTime $date |
|
| 243 | 244 | */ |
| 244 | 245 | public function isLastMonth($date) { |
| 245 | 246 | if ($date->format("n") == $this->endMonth() && $date->format("Y") == $this->endYear()) { |
@@ -535,7 +536,7 @@ discard block |
||
| 535 | 536 | /** |
| 536 | 537 | * Saves an event to whatever Drupal tables are defined in the store array |
| 537 | 538 | * |
| 538 | - * @param \ROomify\Bat\\Store\Store $store |
|
| 539 | + * @param Store $store |
|
| 539 | 540 | * @param string $granularity |
| 540 | 541 | * |
| 541 | 542 | * @throws \Exception |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $current_states = array_keys($unit_states); |
| 124 | 124 | // Compare the current states with the set of valid states |
| 125 | 125 | $remaining_states = array_diff($current_states, $valid_states); |
| 126 | - if (count($remaining_states) == 0 ) { |
|
| 126 | + if (count($remaining_states) == 0) { |
|
| 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); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | foreach ($months as $month => $days) { |
| 213 | 213 | foreach ($days as $day => $hours) { |
| 214 | 214 | foreach ($hours as $hour => $value) { |
| 215 | - $events[$unit][Event::BAT_HOUR][$year][$month]['d'.$day][$hour] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
| 215 | + $events[$unit][Event::BAT_HOUR][$year][$month]['d' . $day][$hour] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | foreach ($hours as $hour => $minutes) { |
| 227 | 227 | foreach ($minutes as $minute => $value) { |
| 228 | 228 | if (isset($db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute])) { |
| 229 | - $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]); |
|
| 229 | + $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 | 230 | } |
| 231 | 231 | else { |
| 232 | 232 | // If nothing from db - then revert to the defaults |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | foreach ($days as $day => $hours) { |
| 245 | 245 | foreach ($hours as $hour => $minutes) { |
| 246 | 246 | foreach ($minutes as $minute => $value) { |
| 247 | - $events[$unit][Event::BAT_MINUTE][$year][$month]['d'.$day]['h'.$hour][$minute] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
| 247 | + $events[$unit][Event::BAT_MINUTE][$year][$month]['d' . $day]['h' . $hour][$minute] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | // Value just switched - let us wrap up with current event and start a new one |
| 317 | 317 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
| 318 | 318 | $start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 319 | - $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
|
| 319 | + $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute, 1)); |
|
| 320 | 320 | $current_value = $minute_value; |
| 321 | 321 | } |
| 322 | 322 | if ($current_value === NULL) { |
| 323 | 323 | // We are down to minutes and haven't created and event yet - do one now |
| 324 | - $start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
|
| 324 | + $start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute, 1)); |
|
| 325 | 325 | $end_event = clone($start_event); |
| 326 | 326 | } |
| 327 | 327 | $current_value = $minute_value; |
@@ -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 | |