PHP Класс Roomify\Bat\Event\EventItemizer
This data structure allows to quickly retrieve the state of a unit for a provided time
period. The value is either the default value of the unit or the value that the event
introduced. If the value in either BAT_DAY or BAT_HOUR is -1 it means that that specific
day or that specific hour are non-determinant. This means that in order to determine the
value of the event for that point in time we need to look at a lower level of granularity.
Example - consider breaking up the following event
start-date: 2016-01-01 1210
end-date: 2016-01-03 1210
value: 10
[BAT_DAY][2016][01][d1][-1] - The first day starts at 1210 so the DAY array is not enough
[BAT_DAY][2016][01][d2][10] - The second day is a full day at the same value of 10
[BAT_DAY][2016][01][d3][-1] - The last day is no a full day so the day array in non-determinant
[BAT_HOUR][2016][01][d1][h12][-1] - The first hour of the event starts at 10 minutes so the hour is non-determinant
[BAT_HOUR][2016][01][d1][h13][10]
[BAT_HOUR][2016][01][d1][h14][10]
[BAT_HOUR][2016][01][d1][h15][10]
[BAT_HOUR][2016][01][d1][h16][10]
[BAT_HOUR][2016][01][d1][h17][10]
[BAT_HOUR][2016][01][d1][h18][10]
[BAT_HOUR][2016][01][d1][h19][10]
[BAT_HOUR][2016][01][d1][h20][10]
[BAT_HOUR][2016][01][d1][h21][10]
[BAT_HOUR][2016][01][d1][h22][10]
[BAT_HOUR][2016][01][d1][h23][10]
- we don't need to state anything about hours on the 2nd of Jan since the day array is determinant
[BAT_HOUR][2016][01][d3][h01][10]
[BAT_HOUR][2016][01][d3][h02][10]
[BAT_HOUR][2016][01][d3][h03][10]
[BAT_HOUR][2016][01][d3][h04][10]
[BAT_HOUR][2016][01][d3][h05][10]
[BAT_HOUR][2016][01][d3][h06][10]
[BAT_HOUR][2016][01][d3][h07][10]
[BAT_HOUR][2016][01][d3][h08][10]
[BAT_HOUR][2016][01][d3][h09][10]
[BAT_HOUR][2016][01][d3][h10][10]
[BAT_HOUR][2016][01][d3][h11][10]
[BAT_HOUR][2016][01][d3][h12][-1] - The last hour of the event ends at the 10th minute so will need to minute array
[BAT_MINUTE][2016][01][d1][h12][m00][10] - Minutes, which is the maximum granularity, are always determinant
[BAT_MINUTE][2016][01][d1][h12][m01][10]
[BAT_MINUTE][2016][01][d1][h12][m02][10]
[BAT_MINUTE][2016][01][d1][h12][m03][10]
[BAT_MINUTE][2016][01][d1][h12][m04][10]
[BAT_MINUTE][2016][01][d1][h12][m05][10]
[BAT_MINUTE][2016][01][d1][h12][m06][10]
[BAT_MINUTE][2016][01][d1][h12][m07][10]
[BAT_MINUTE][2016][01][d1][h12][m08][10]
[BAT_MINUTE][2016][01][d1][h12][m09][10]
[BAT_MINUTE][2016][01][d1][h12][m10][10]
[BAT_MINUTE][2016][01][d3][h12][m00][10]
[BAT_MINUTE][2016][01][d3][h12][m01][10]
[BAT_MINUTE][2016][01][d3][h12][m02][10]
[BAT_MINUTE][2016][01][d3][h12][m03][10]
[BAT_MINUTE][2016][01][d3][h12][m04][10]
[BAT_MINUTE][2016][01][d3][h12][m05][10]
[BAT_MINUTE][2016][01][d3][h12][m06][10]
[BAT_MINUTE][2016][01][d3][h12][m07][10]
[BAT_MINUTE][2016][01][d3][h12][m08][10]
[BAT_MINUTE][2016][01][d3][h12][m09][10]
[BAT_MINUTE][2016][01][d3][h12][m10][10]
Class EventItemizer
Показать файл
Открыть проект
Примеры использования класса
Защищенные свойства (Protected)
Открытые методы
Метод |
Описание |
|
__construct ( Roomify\Bat\Event\EventInterface $event, $granularity = EventItemizer::BAT_HOURLY ) |
|
|
createHourlyGranular ( DatePeriod $period, DateTime $period_start ) : array |
Given a DatePeriod it transforms it in hours and minutes. Used to break the first and
last days of an event into more granular events. |
|
itemizeEvent ( ) : array |
Transforms the event in a breakdown of days, hours and minutes with associated states. |
|
Приватные методы
Метод |
Описание |
|
createDayGranural ( array $itemized = [] ) : array |
Based on the start and end dates of the event it creates the appropriate granular events
and adds them to an array suitable for manipulating easily or storing in the database. |
|
Описание методов
__construct()
публичный Метод
public __construct ( Roomify\Bat\Event\EventInterface $event, $granularity = EventItemizer::BAT_HOURLY ) |
$event |
Roomify\Bat\Event\EventInterface |
|
createHourlyGranular()
публичный Метод
Given a DatePeriod it transforms it in hours and minutes. Used to break the first and
last days of an event into more granular events.
itemizeEvent()
публичный Метод
Transforms the event in a breakdown of days, hours and minutes with associated states.
Описание свойств
$event защищенное свойство
protected EventInterface,Roomify\Bat\Event $event |
Результат |
Roomify\Bat\Event\EventInterface |
|
$granularity защищенное свойство
protected string $granularity |
Результат |
string |
|