Piwik\Plugins\Referrers\Controller::addEvolutionPropertiesToView PHP Method

addEvolutionPropertiesToView() private method

Utility method that calculates evolution values for a set of current & past values and sets properties on a View w/ HTML that displays the evolution percents.
private addEvolutionPropertiesToView ( string $date, array $currentValues, string $lastPeriodDate, array $previousValues ) : array
$date string The date of the current values.
$currentValues array Array mapping view property names w/ present values.
$lastPeriodDate string The date of the period in the past.
$previousValues array Array mapping view property names w/ past values. Keys in this array should be the same as keys in $currentValues.
return array Added current values
    private function addEvolutionPropertiesToView($date, $currentValues, $lastPeriodDate, $previousValues)
    {
        foreach ($previousValues as $name => $pastValue) {
            $currentValue = $currentValues[$name];
            $evolutionName = $name . 'Evolution';
            $currentValueFormatted = NumberFormatter::getInstance()->format($currentValue);
            $pastValueFormatted = NumberFormatter::getInstance()->format($pastValue);
            $currentValues[$evolutionName] = array('currentValue' => $currentValue, 'pastValue' => $pastValue, 'tooltip' => Piwik::translate('General_EvolutionSummaryGeneric', array(Piwik::translate('General_NVisits', $currentValueFormatted), $date, Piwik::translate('General_NVisits', $pastValueFormatted), $lastPeriodDate, CalculateEvolutionFilter::calculate($currentValue, $pastValue, $precision = 1))));
        }
        return $currentValues;
    }