private function sumColumnValueToTotal($columns, $metricId, $metricName)
{
$value = false;
if (array_key_exists($metricId, $columns)) {
$value = $columns[$metricId];
}
if ($value === false) {
// we do not add $metricId to $possibleMetricNames for a small performance improvement since in most cases
// $metricId should be present in $columns so we avoid this foreach loop
$possibleMetricNames = array($metricName, 'Goal_' . $metricName, 'Actions_' . $metricName);
foreach ($possibleMetricNames as $possibleMetricName) {
if (array_key_exists($possibleMetricName, $columns)) {
$value = $columns[$possibleMetricName];
break;
}
}
if ($value === false) {
return;
}
}
if (array_key_exists($metricName, $this->totals)) {
$this->totals[$metricName] += $value;
} else {
$this->totals[$metricName] = $value;
}
}