@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * Returns the start date. |
| 92 | 92 | * |
| 93 | - * @return DateTime |
|
| 93 | + * @return \DateTime |
|
| 94 | 94 | */ |
| 95 | 95 | public function getStartDate() { |
| 96 | 96 | return clone($this->start_date); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * Set the start date. |
| 109 | 109 | * |
| 110 | - * @param DateTime $start_date |
|
| 110 | + * @param \DateTime $start_date |
|
| 111 | 111 | */ |
| 112 | 112 | public function setStartDate(\DateTime $start_date) { |
| 113 | 113 | $this->start_date = clone($start_date); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | /** |
| 117 | 117 | * Returns the end date. |
| 118 | 118 | * |
| 119 | - * @return DateTime |
|
| 119 | + * @return \DateTime |
|
| 120 | 120 | */ |
| 121 | 121 | public function getEndDate() { |
| 122 | 122 | return clone($this->end_date); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | /** |
| 134 | 134 | * Set the end date. |
| 135 | 135 | * |
| 136 | - * @param DateTime $end_date |
|
| 136 | + * @param \DateTime $end_date |
|
| 137 | 137 | */ |
| 138 | 138 | public function setEndDate(\DateTime $end_date) { |
| 139 | 139 | $this->end_date = clone($end_date); |
@@ -451,6 +451,7 @@ discard block |
||
| 451 | 451 | /** |
| 452 | 452 | * Transforms the event in a breakdown of days, hours and minutes with associated states. |
| 453 | 453 | * |
| 454 | + * @param EventItemizer $itemizer |
|
| 454 | 455 | * @return array |
| 455 | 456 | */ |
| 456 | 457 | public function itemize($itemizer, $granularity = AbstractEvent::BAT_HOURLY) { |
@@ -461,7 +462,7 @@ discard block |
||
| 461 | 462 | /** |
| 462 | 463 | * Saves an event using the Store object |
| 463 | 464 | * |
| 464 | - * @param \Roomify\Bat\\Store\Store $store |
|
| 465 | + * @param Store $store |
|
| 465 | 466 | * @param string $granularity |
| 466 | 467 | * |
| 467 | 468 | * @return boolean |
@@ -25,6 +25,7 @@ discard block |
||
| 25 | 25 | * Set the unit id. |
| 26 | 26 | * |
| 27 | 27 | * @param int $unit_id |
| 28 | + * @return void |
|
| 28 | 29 | */ |
| 29 | 30 | public function setUnitId($unit_id); |
| 30 | 31 | |
@@ -46,6 +47,7 @@ discard block |
||
| 46 | 47 | * Sets the StartDate |
| 47 | 48 | * |
| 48 | 49 | * @param \DateTime |
| 50 | + * @return void |
|
| 49 | 51 | */ |
| 50 | 52 | public function setStartDate(\DateTime $start_date); |
| 51 | 53 | |
@@ -53,6 +55,7 @@ discard block |
||
| 53 | 55 | * Sets the EndDate |
| 54 | 56 | * |
| 55 | 57 | * @param \DateTime |
| 58 | + * @return void |
|
| 56 | 59 | */ |
| 57 | 60 | public function setEndDate(\DateTime $end_date); |
| 58 | 61 | |
@@ -67,6 +70,7 @@ discard block |
||
| 67 | 70 | * Sets the event value. |
| 68 | 71 | * |
| 69 | 72 | * @param int $value |
| 73 | + * @return void |
|
| 70 | 74 | */ |
| 71 | 75 | public function setValue($value); |
| 72 | 76 | |
@@ -215,7 +219,7 @@ discard block |
||
| 215 | 219 | |
| 216 | 220 | /** |
| 217 | 221 | * Returns TRUE if the date supplied is the first month of the event |
| 218 | - * @param $date |
|
| 222 | + * @param \DateTime $date |
|
| 219 | 223 | * |
| 220 | 224 | * @return bool |
| 221 | 225 | */ |
@@ -231,7 +235,7 @@ discard block |
||
| 231 | 235 | |
| 232 | 236 | /** |
| 233 | 237 | * Returns TRUE if the date supplied is the last month of the event |
| 234 | - * @param $date |
|
| 238 | + * @param \DateTime $date |
|
| 235 | 239 | * |
| 236 | 240 | * @return bool |
| 237 | 241 | */ |
@@ -283,7 +287,6 @@ discard block |
||
| 283 | 287 | /** |
| 284 | 288 | * Returns the json version of this event. |
| 285 | 289 | * |
| 286 | - * @param \Roomify\Bat\Event\EventInterface $event |
|
| 287 | 290 | * |
| 288 | 291 | * @return mixed |
| 289 | 292 | */ |
@@ -16,27 +16,27 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class EventInterval { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Return the number of times a duration fits into the start and end date taking into account |
|
| 21 | - * BAT's consideration that the end time for a BAT event includes that last minute. |
|
| 22 | - * |
|
| 23 | - * @param \DateTime $start_date |
|
| 24 | - * @param \DateTime $end_date |
|
| 25 | - * @param \DateInterval $duration |
|
| 26 | - * |
|
| 27 | - * @return float |
|
| 28 | - */ |
|
| 29 | - public static function divide(\DateTime $start_date, \DateTime $end_date, \DateInterval $duration) { |
|
| 30 | - // Clone so that we don't change the original object. We are not using ImmutableDateTime to support PHP5.4 |
|
| 31 | - $temp_end_date = clone($end_date); |
|
| 32 | - |
|
| 33 | - // Add a minute to deal with the fact that BAT considers the last minute included |
|
| 34 | - $temp_end_date->add(new \DateInterval('PT1M')); |
|
| 35 | - |
|
| 36 | - // Convert everything to seconds and calculate exactly how many times the duration fits in our event length |
|
| 37 | - $duration_seconds = $duration->d * 86400 + $duration->h * 3600 + $duration->i * 60 + $duration->s; |
|
| 38 | - |
|
| 39 | - return ($temp_end_date->getTimestamp() - $start_date->getTimestamp()) / $duration_seconds; |
|
| 40 | - } |
|
| 19 | + /** |
|
| 20 | + * Return the number of times a duration fits into the start and end date taking into account |
|
| 21 | + * BAT's consideration that the end time for a BAT event includes that last minute. |
|
| 22 | + * |
|
| 23 | + * @param \DateTime $start_date |
|
| 24 | + * @param \DateTime $end_date |
|
| 25 | + * @param \DateInterval $duration |
|
| 26 | + * |
|
| 27 | + * @return float |
|
| 28 | + */ |
|
| 29 | + public static function divide(\DateTime $start_date, \DateTime $end_date, \DateInterval $duration) { |
|
| 30 | + // Clone so that we don't change the original object. We are not using ImmutableDateTime to support PHP5.4 |
|
| 31 | + $temp_end_date = clone($end_date); |
|
| 32 | + |
|
| 33 | + // Add a minute to deal with the fact that BAT considers the last minute included |
|
| 34 | + $temp_end_date->add(new \DateInterval('PT1M')); |
|
| 35 | + |
|
| 36 | + // Convert everything to seconds and calculate exactly how many times the duration fits in our event length |
|
| 37 | + $duration_seconds = $duration->d * 86400 + $duration->h * 3600 + $duration->i * 60 + $duration->s; |
|
| 38 | + |
|
| 39 | + return ($temp_end_date->getTimestamp() - $start_date->getTimestamp()) / $duration_seconds; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | } |