Roomify\Bat\Event\EventItemizer::createHourlyGranular PHP Method

createHourlyGranular() public method

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.
public createHourlyGranular ( DatePeriod $period, DateTime $period_start ) : array
$period DatePeriod
$period_start DateTime
return array
    public function createHourlyGranular(\DatePeriod $period, \DateTime $period_start)
    {
        $itemized = array();
        $counter = (int) $period_start->format('i');
        $start_minute = $counter;
        foreach ($period as $minute) {
            // Doing minutes so set the values in the minute array
            $itemized[EventItemizer::BAT_MINUTE][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')]['m' . $minute->format('i')] = $this->event->getValue();
            // Let the hours know that it cannot determine availability
            $itemized[EventItemizer::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = -1;
            $counter++;
            if ($counter == 60 && $start_minute !== 0) {
                // Not a real hour - leave as is and move on
                $counter = 0;
                $start_minute = 0;
            } elseif ($counter == 60 && $start_minute == 0) {
                // Did a real whole hour so initialize the hour
                $itemized[EventItemizer::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = $this->event->getValue();
                $counter = 0;
                $start_minute = 0;
            }
        }
        return $itemized;
    }