protected function calculateResidualPeriod(PeriodData $periodData, \DateInterval $leftover)
 {
     $currentPeriod = $periodData->getPeriod();
     $periodSeconds = ConvertTime::convertIntervalToSeconds($currentPeriod);
     $leftoverSeconds = ConvertTime::convertIntervalToSeconds($leftover);
     $diff = $periodSeconds - $leftoverSeconds;
     if ($diff < 0) {
         throw new OccurrencesException("Time is enough, residual period is not required.");
     }
     return new \DateInterval("PT" . $diff . "S");
 }
 protected function resolvePeriodLabel(PeriodData $occurrencePeriod, $periodLabels)
 {
     $periodInHours = ConvertTime::convertIntervalToHours($occurrencePeriod->getPeriod());
     return $periodLabels[$periodInHours];
 }