@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @param $calendar_response |
| 21 | 21 | */ |
| 22 | - public function applyConstraint(CalendarResponse &$calendar_response); |
|
| 22 | + public function applyConstraint(CalendarResponse & $calendar_response); |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @param $start_date |
@@ -111,7 +111,7 @@ |
||
| 111 | 111 | /** |
| 112 | 112 | * {@inheritdoc} |
| 113 | 113 | */ |
| 114 | - public function applyConstraint(CalendarResponse &$calendar_response) { |
|
| 114 | + public function applyConstraint(CalendarResponse & $calendar_response) { |
|
| 115 | 115 | $this->calendar_response = $calendar_response; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | * @return int |
| 63 | 63 | */ |
| 64 | 64 | public function getValue() { |
| 65 | - return (int) $this->value; |
|
| 65 | + return (int)$this->value; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | * {@inheritdoc} |
| 45 | 45 | */ |
| 46 | 46 | public function getDefaultValue() { |
| 47 | - return (int) $this->default_value; |
|
| 47 | + return (int)$this->default_value; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * {@inheritdoc} |
| 37 | 37 | */ |
| 38 | - public function applyConstraint(CalendarResponse &$calendar_response) { |
|
| 38 | + public function applyConstraint(CalendarResponse & $calendar_response) { |
|
| 39 | 39 | parent::applyConstraint($calendar_response); |
| 40 | 40 | |
| 41 | 41 | if ($this->start_date === NULL) { |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | $this->end_date = new \DateTime('2999-12-31'); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( (($calendar_response->getStartDate()->getTimestamp() >= $this->start_date->getTimestamp() && |
|
| 48 | + if ((($calendar_response->getStartDate()->getTimestamp() >= $this->start_date->getTimestamp() && |
|
| 49 | 49 | $calendar_response->getStartDate()->getTimestamp() <= $this->end_date->getTimestamp()) || |
| 50 | 50 | ($calendar_response->getStartDate()->getTimestamp() <= $this->start_date->getTimestamp() && |
| 51 | 51 | $calendar_response->getEndDate()->getTimestamp() >= $this->end_date->getTimestamp())) && |
| 52 | - $this->checkin_day != $calendar_response->getStartDate()->format('N') ) { |
|
| 52 | + $this->checkin_day != $calendar_response->getStartDate()->format('N')) { |
|
| 53 | 53 | |
| 54 | 54 | $units = $this->getUnits(); |
| 55 | 55 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * {@inheritdoc} |
| 54 | 54 | */ |
| 55 | - public function applyConstraint(CalendarResponse &$calendar_response) { |
|
| 55 | + public function applyConstraint(CalendarResponse & $calendar_response) { |
|
| 56 | 56 | parent::applyConstraint($calendar_response); |
| 57 | 57 | |
| 58 | 58 | if ($this->start_date === NULL) { |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | $this->end_date = new \DateTime('2999-12-31'); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ( (($calendar_response->getStartDate()->getTimestamp() >= $this->start_date->getTimestamp() && |
|
| 65 | + if ((($calendar_response->getStartDate()->getTimestamp() >= $this->start_date->getTimestamp() && |
|
| 66 | 66 | $calendar_response->getStartDate()->getTimestamp() <= $this->end_date->getTimestamp()) || |
| 67 | 67 | ($calendar_response->getEndDate()->getTimestamp() >= $this->start_date->getTimestamp() && |
| 68 | 68 | $calendar_response->getEndDate()->getTimestamp() <= $this->end_date->getTimestamp()) || |
| 69 | 69 | ($calendar_response->getStartDate()->getTimestamp() <= $this->start_date->getTimestamp() && |
| 70 | 70 | $calendar_response->getEndDate()->getTimestamp() >= $this->end_date->getTimestamp())) && |
| 71 | - ($this->checkin_day === NULL || $this->checkin_day == $calendar_response->getStartDate()->format('N')) ) { |
|
| 71 | + ($this->checkin_day === NULL || $this->checkin_day == $calendar_response->getStartDate()->format('N'))) { |
|
| 72 | 72 | |
| 73 | 73 | $units = $this->getUnits(); |
| 74 | 74 | |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | $text = ''; |
| 108 | 108 | |
| 109 | 109 | // Min/max stay length constraint variables. |
| 110 | - $minimum_stay = empty($this->min_days) ? '' : (($this->min_days == 1) ? $this->min_days . ' day' : $this->min_days . ' days'); |
|
| 111 | - $maximum_stay = empty($this->max_days) ? '' : (($this->max_days == 1) ? $this->max_days . ' day' : $this->max_days . ' days'); |
|
| 110 | + $minimum_stay = empty($this->min_days) ? '' : (($this->min_days == 1) ? $this->min_days.' day' : $this->min_days.' days'); |
|
| 111 | + $maximum_stay = empty($this->max_days) ? '' : (($this->max_days == 1) ? $this->max_days.' day' : $this->max_days.' days'); |
|
| 112 | 112 | |
| 113 | 113 | // Day of the week constraint variable. |
| 114 | 114 | $day_of_the_week = $this->getWeekDay($this->checkin_day); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function getEventData(\DateTime $start_date, \DateTime $end_date, $unit_ids) { |
| 29 | 29 | |
| 30 | - $queries = $this->buildQueries($start_date, $end_date, $unit_ids); |
|
| 30 | + $queries = $this->buildQueries($start_date, $end_date, $unit_ids); |
|
| 31 | 31 | |
| 32 | 32 | $results = array(); |
| 33 | 33 | // Run each query and store results |
@@ -38,31 +38,31 @@ discard block |
||
| 38 | 38 | $db_events = array(); |
| 39 | 39 | |
| 40 | 40 | // Cycle through day results and setup an event array |
| 41 | - while( $data = $results[Event::BAT_DAY]->fetchAssoc()) { |
|
| 41 | + while ($data = $results[Event::BAT_DAY]->fetchAssoc()) { |
|
| 42 | 42 | // Figure out how many days the current month has |
| 43 | - $temp_date = new \DateTime($data['year'] . "-" . $data['month']); |
|
| 43 | + $temp_date = new \DateTime($data['year']."-".$data['month']); |
|
| 44 | 44 | $days_in_month = (int)$temp_date->format('t'); |
| 45 | - for ($i = 1; $i<=$days_in_month; $i++) { |
|
| 46 | - $db_events[$data['unit_id']][Event::BAT_DAY][$data['year']][$data['month']]['d' . $i] = $data['d'.$i]; |
|
| 45 | + for ($i = 1; $i <= $days_in_month; $i++) { |
|
| 46 | + $db_events[$data['unit_id']][Event::BAT_DAY][$data['year']][$data['month']]['d'.$i] = $data['d'.$i]; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // With the day events taken care off let's cycle through hours |
| 51 | - while( $data = $results[Event::BAT_HOUR]->fetchAssoc()) { |
|
| 52 | - for ($i = 0; $i<=23; $i++) { |
|
| 53 | - $db_events[$data['unit_id']][Event::BAT_HOUR][$data['year']][$data['month']]['d' . $data['day']]['h'. $i] = $data['h'.$i]; |
|
| 51 | + while ($data = $results[Event::BAT_HOUR]->fetchAssoc()) { |
|
| 52 | + for ($i = 0; $i <= 23; $i++) { |
|
| 53 | + $db_events[$data['unit_id']][Event::BAT_HOUR][$data['year']][$data['month']]['d'.$data['day']]['h'.$i] = $data['h'.$i]; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // With the hour events taken care off let's cycle through minutes |
| 58 | - while( $data = $results[Event::BAT_MINUTE]->fetchAssoc()) { |
|
| 59 | - for ($i = 0; $i<=59; $i++) { |
|
| 58 | + while ($data = $results[Event::BAT_MINUTE]->fetchAssoc()) { |
|
| 59 | + for ($i = 0; $i <= 59; $i++) { |
|
| 60 | 60 | if ($i <= 9) { |
| 61 | 61 | $index = 'm0'.$i; |
| 62 | 62 | } else { |
| 63 | 63 | $index = 'm'.$i; |
| 64 | 64 | } |
| 65 | - $db_events[$data['unit_id']][Event::BAT_MINUTE][$data['year']][$data['month']]['d' . $data['day']]['h' . $data['hour']][$index] = $data[$index]; |
|
| 65 | + $db_events[$data['unit_id']][Event::BAT_MINUTE][$data['year']][$data['month']]['d'.$data['day']]['h'.$data['hour']][$index] = $data[$index]; |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | protected function normalizeMinMaxDaysConstraints() { |
| 97 | 97 | $new_constraints = array(); |
| 98 | 98 | |
| 99 | - $constraints = array_map(function ($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\MinMaxDaysConstraint']); |
|
| 99 | + $constraints = array_map(function($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\MinMaxDaysConstraint']); |
|
| 100 | 100 | |
| 101 | 101 | foreach (array_reverse($constraints) as $constraint) { |
| 102 | 102 | $start_date = $constraint->getStartDate(); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | protected function normalizeCheckInDayConstraints() { |
| 173 | 173 | $new_constraints = array(); |
| 174 | 174 | |
| 175 | - $constraints = array_map(function ($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\CheckInDayConstraint']); |
|
| 175 | + $constraints = array_map(function($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\CheckInDayConstraint']); |
|
| 176 | 176 | |
| 177 | 177 | foreach (array_reverse($constraints) as $constraint) { |
| 178 | 178 | $start_date = $constraint->getStartDate(); |
@@ -77,23 +77,23 @@ discard block |
||
| 77 | 77 | $this->event_type = $event_type; |
| 78 | 78 | |
| 79 | 79 | if ($event_data == SqlDBStore::BAT_STATE) { |
| 80 | - $this->day_table = $prefix . 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_STATE; |
|
| 81 | - $this->hour_table = $prefix . 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_STATE; |
|
| 82 | - $this->minute_table = $prefix . 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_STATE; |
|
| 80 | + $this->day_table = $prefix.'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_STATE; |
|
| 81 | + $this->hour_table = $prefix.'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_STATE; |
|
| 82 | + $this->minute_table = $prefix.'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_STATE; |
|
| 83 | 83 | |
| 84 | - $this->day_table_no_prefix = 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_STATE; |
|
| 85 | - $this->hour_table_no_prefix = 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_STATE; |
|
| 86 | - $this->minute_table_no_prefix = 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_STATE; |
|
| 84 | + $this->day_table_no_prefix = 'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_STATE; |
|
| 85 | + $this->hour_table_no_prefix = 'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_STATE; |
|
| 86 | + $this->minute_table_no_prefix = 'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_STATE; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | if ($event_data == SqlDBStore::BAT_EVENT) { |
| 90 | - $this->day_table = $prefix . 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_EVENT; |
|
| 91 | - $this->hour_table = $prefix . 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_EVENT; |
|
| 92 | - $this->minute_table = $prefix . 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_EVENT; |
|
| 90 | + $this->day_table = $prefix.'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_EVENT; |
|
| 91 | + $this->hour_table = $prefix.'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_EVENT; |
|
| 92 | + $this->minute_table = $prefix.'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_EVENT; |
|
| 93 | 93 | |
| 94 | - $this->day_table_no_prefix = 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_EVENT; |
|
| 95 | - $this->hour_table_no_prefix = 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_EVENT; |
|
| 96 | - $this->minute_table_no_prefix = 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_EVENT; |
|
| 94 | + $this->day_table_no_prefix = 'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_EVENT; |
|
| 95 | + $this->hour_table_no_prefix = 'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_EVENT; |
|
| 96 | + $this->minute_table_no_prefix = 'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_EVENT; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | } |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | public function buildQueries(\DateTime $start_date, \DateTime $end_date, $unit_ids) { |
| 109 | 109 | $queries = array(); |
| 110 | 110 | |
| 111 | - $queries[Event::BAT_DAY] = 'SELECT * FROM ' . $this->day_table . ' WHERE '; |
|
| 112 | - $queries[Event::BAT_HOUR] = 'SELECT * FROM ' . $this->hour_table . ' WHERE '; |
|
| 113 | - $queries[Event::BAT_MINUTE] = 'SELECT * FROM ' . $this->minute_table . ' WHERE '; |
|
| 111 | + $queries[Event::BAT_DAY] = 'SELECT * FROM '.$this->day_table.' WHERE '; |
|
| 112 | + $queries[Event::BAT_HOUR] = 'SELECT * FROM '.$this->hour_table.' WHERE '; |
|
| 113 | + $queries[Event::BAT_MINUTE] = 'SELECT * FROM '.$this->minute_table.' WHERE '; |
|
| 114 | 114 | |
| 115 | 115 | // Create a mock event which we will use to determine how to query the database |
| 116 | 116 | $mock_event = new Event($start_date, $end_date, new Unit(0, 0, NULL), -10); |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | // We are dealing with multiple years so add an OR |
| 129 | 129 | $query_parameters .= ' OR '; |
| 130 | 130 | } |
| 131 | - $query_parameters .= 'year IN (' . $year . ') '; |
|
| 132 | - $query_parameters .= 'AND month IN (' . implode(",", array_keys($months)) . ') '; |
|
| 131 | + $query_parameters .= 'year IN ('.$year.') '; |
|
| 132 | + $query_parameters .= 'AND month IN ('.implode(",", array_keys($months)).') '; |
|
| 133 | 133 | if (count($unit_ids) > 0) { |
| 134 | 134 | // Unit ids are defined so add this as a filter |
| 135 | - $query_parameters .= 'AND unit_id in (' . implode("," , $unit_ids) . ') '; |
|
| 135 | + $query_parameters .= 'AND unit_id in ('.implode(",", $unit_ids).') '; |
|
| 136 | 136 | } |
| 137 | 137 | $year_count++; |
| 138 | 138 | } |