/**
  * @param string $attribute
  * @param string $tableName
  * @param string $columnName
  * @param null|string $queryStringExtraPart
  * @return string
  * @throws NotSupportedException if the type is invalid or null
  */
 public function resolveOrderByStringForCalculationOrModifier($attribute, $tableName, $columnName, $queryStringExtraPart = null)
 {
     assert('is_string($attribute)');
     assert('is_string($columnName)');
     assert('is_string($queryStringExtraPart) || $queryStringExtraPart == null');
     $type = $this->getDisplayAttributeForMakingViaSelectType($attribute);
     if ($type == ModelRelationsAndAttributesToSummableReportAdapter::DISPLAY_CALCULATION_COUNT) {
         return RedBeanModelSelectQueryAdapter::makeCountString($tableName, $columnName);
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::DISPLAY_CALCULATION_SUMMMATION) {
         return RedBeanModelSelectQueryAdapter::makeSummationString($tableName, $columnName, $queryStringExtraPart);
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::DISPLAY_CALCULATION_AVERAGE) {
         return RedBeanModelSelectQueryAdapter::makeAverageString($tableName, $columnName, $queryStringExtraPart);
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::DISPLAY_CALCULATION_MINIMUM) {
         return RedBeanModelSelectQueryAdapter::makeMinimumString($tableName, $columnName, $queryStringExtraPart);
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::DISPLAY_CALCULATION_MAXIMUM) {
         return RedBeanModelSelectQueryAdapter::makeMaximumString($tableName, $columnName, $queryStringExtraPart);
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::GROUP_BY_CALCULATION_DAY) {
         return RedBeanModelSelectQueryAdapter::makeDayModifierString($tableName, $columnName, $this->shouldDoTimeZoneAdjustmentOnModifierClause($attribute));
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::GROUP_BY_CALCULATION_WEEK) {
         return RedBeanModelSelectQueryAdapter::makeWeekModifierString($tableName, $columnName, $this->shouldDoTimeZoneAdjustmentOnModifierClause($attribute));
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::GROUP_BY_CALCULATION_MONTH) {
         return RedBeanModelSelectQueryAdapter::makeMonthModifierString($tableName, $columnName, $this->shouldDoTimeZoneAdjustmentOnModifierClause($attribute));
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::GROUP_BY_CALCULATION_QUARTER) {
         return RedBeanModelSelectQueryAdapter::makeQuarterModifierString($tableName, $columnName, $this->shouldDoTimeZoneAdjustmentOnModifierClause($attribute));
     } elseif ($type == ModelRelationsAndAttributesToSummableReportAdapter::GROUP_BY_CALCULATION_YEAR) {
         return RedBeanModelSelectQueryAdapter::makeYearModifierString($tableName, $columnName, $this->shouldDoTimeZoneAdjustmentOnModifierClause($attribute));
     } else {
         throw new NotSupportedException();
     }
 }