private function itemizeMinutes($db_events, $itemized, $unit, $keyed_units) {
    $result = array();

    if (isset($itemized[Event::BAT_MINUTE])) {
      foreach ($itemized[Event::BAT_MINUTE] as $year => $months) {
        foreach ($months as $month => $days) {
          foreach ($days as $day => $hours) {
            foreach ($hours as $hour => $minutes) {
              foreach ($minutes as $minute => $value) {
                if (isset($db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute])) {
                  $result[$year][$month][$day][$hour][$minute] = ((int) $db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int) $db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute]);
                }
                else {
                  // If nothing from db - then revert to the defaults
                  $result[$year][$month][$day][$hour][$minute] = (int) $keyed_units[$unit]->getDefaultValue();
                }
              }
            }
          }
        }
      }
    }

    // Now fill in minute data coming from the database which the mock event did *not* cater for
    if (isset($db_events[$unit][Event::BAT_MINUTE])) {
      foreach ($db_events[$unit][Event::BAT_MINUTE] as $year => $months) {
        foreach ($months as $month => $days) {
          foreach ($days as $day => $hours) {
            foreach ($hours as $hour => $minutes) {
              foreach ($minutes as $minute => $value) {
                $result[$year][$month][$day][$hour][$minute] = ((int) $value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int) $value);
              }
              ksort($result[$year][$month][$day][$hour], SORT_NATURAL);
            }
          }
        }
      }
    }

    return $result;
  }
private function itemizeMinutes($db_events, $itemized, $unit, $keyed_units) {
    $result = array();

    if (isset($itemized[Event::BAT_MINUTE])) {
      foreach ($itemized[Event::BAT_MINUTE] as $year => $months) {
        foreach ($months as $month => $days) {
          foreach ($days as $day => $hours) {
            foreach ($hours as $hour => $minutes) {
              foreach ($minutes as $minute => $value) {
                if (isset($db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute])) {
                  $result[$year][$month][$day][$hour][$minute] = ((int) $db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int) $db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute]);
                }
                else {
                  // If nothing from db - then revert to the defaults
                  $result[$year][$month][$day][$hour][$minute] = (int) $keyed_units[$unit]->getDefaultValue();
                }
              }
            }
          }
        }
      }
    }

    // Now fill in minute data coming from the database which the mock event did *not* cater for
    if (isset($db_events[$unit][Event::BAT_MINUTE])) {
      foreach ($db_events[$unit][Event::BAT_MINUTE] as $year => $months) {
        foreach ($months as $month => $days) {
          foreach ($days as $day => $hours) {
            foreach ($hours as $hour => $minutes) {
              foreach ($minutes as $minute => $value) {
                $result[$year][$month][$day][$hour][$minute] = ((int) $value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int) $value);
              }
              ksort($result[$year][$month][$day][$hour], SORT_NATURAL);
            }
          }
        }
      }
    }

    return $result;
  }
private function itemizeMinutes ( $ db_events , $ itemized , $ unit , $ keyed_units ) { $ result = array ( ) ; if ( isset ( $ itemized [ Event :: BAT_MINUTE ] ) ) { foreach ( $ itemized [ Event :: BAT_MINUTE ] as $ year => $ months ) { foreach ( $ months as $ month => $ days ) { foreach ( $ days as $ day => $ hours ) { foreach ( $ hours as $ hour => $ minutes ) { foreach ( $ minutes as $ minute => $ value ) { if ( isset ( $ db_events [ $ unit ] [ Event :: BAT_MINUTE ] [ $ year ] [ $ month ] [ $ day ] [ $ hour ] [ $ minute ] ) ) { $ result [ $ year ] [ $ month ] [ $ day ] [ $ hour ] [ $ minute ] = ( ( int ) $ db_events [ $ unit ] [ Event :: BAT_MINUTE ] [ $ year ] [ $ month ] [ $ day ] [ $ hour ] [ $ minute ] == 0 ? $ keyed_units [ $ unit ] -> getDefaultValue ( ) : ( int ) $ db_events [ $ unit ] [ Event :: BAT_MINUTE ] [ $ year ] [ $ month ] [ $ day ] [ $ hour ] [ $ minute ] ) ; } else { // If nothing from db - then revert to the defaults $ result [ $ year ] [ $ month ] [ $ day ] [ $ hour ] [ $ minute ] = ( int ) $ keyed_units [ $ unit ] -> getDefaultValue ( ) ; } } } } } } } // Now fill in minute data coming from the database which the mock event did *not* cater for if ( isset ( $ db_events [ $ unit ] [ Event :: BAT_MINUTE ] ) ) { foreach ( $ db_events [ $ unit ] [ Event :: BAT_MINUTE ] as $ year => $ months ) { foreach ( $ months as $ month => $ days ) { foreach ( $ days as $ day => $ hours ) { foreach ( $ hours as $ hour => $ minutes ) { foreach ( $ minutes as $ minute => $ value ) { $ result [ $ year ] [ $ month ] [ $ day ] [ $ hour ] [ $ minute ] = ( ( int ) $ value == 0 ? $ keyed_units [ $ unit ] -> getDefaultValue ( ) : ( int ) $ value ) ; } ksort ( $ result [ $ year ] [ $ month ] [ $ day ] [ $ hour ] , SORT_NATURAL ) ; } } } } } return $ result ; }
Helper function that cycles through db results and setups the BAT_MINUTE itemized array

@param $db_events
@param $itemized
@param $unit
@param $keyed_units

@return array
Helper function that cycles through db results and setups the BAT_MINUTE itemized array