original_string: private function calculateEvolutionPercentages($currentData, $pastData, $apiMetrics)
      {
          if (get_class($currentData) != get_class($pastData)) { // sanity check for regressions
              throw new Exception("Expected \$pastData to be of type " . get_class($currentData) . " - got "
                  . get_class($pastData) . ".");
          }
  
          if ($currentData instanceof DataTable\Map) {
              $pastArray = $pastData->getDataTables();
              foreach ($currentData->getDataTables() as $subTable) {
                  $this->calculateEvolutionPercentages($subTable, current($pastArray), $apiMetrics);
                  next($pastArray);
              }
          } else {
              $extraProcessedMetrics = $currentData->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME);
              foreach ($apiMetrics as $metricSettings) {
                  $evolutionMetricClass = $this->isEcommerceEvolutionMetric($metricSettings)
                                        ? "Piwik\\Plugins\\MultiSites\\Columns\\Metrics\\EcommerceOnlyEvolutionMetric"
                                        : "Piwik\\Plugins\\CoreHome\\Columns\\Metrics\\EvolutionMetric";
  
                  $extraProcessedMetrics[] = new $evolutionMetricClass(
                      $metricSettings[self::METRIC_RECORD_NAME_KEY],
                      $pastData,
                      $metricSettings[self::METRIC_EVOLUTION_COL_NAME_KEY],
                      $quotientPrecision = 1
                  );
              }
              $currentData->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics);
          }
      }
code: private function calculateEvolutionPercentages($currentData, $pastData, $apiMetrics)
      {
          if (get_class($currentData) != get_class($pastData)) { // sanity check for regressions
              throw new Exception("Expected \$pastData to be of type " . get_class($currentData) . " - got "
                  . get_class($pastData) . ".");
          }
  
          if ($currentData instanceof DataTable\Map) {
              $pastArray = $pastData->getDataTables();
              foreach ($currentData->getDataTables() as $subTable) {
                  $this->calculateEvolutionPercentages($subTable, current($pastArray), $apiMetrics);
                  next($pastArray);
              }
          } else {
              $extraProcessedMetrics = $currentData->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME);
              foreach ($apiMetrics as $metricSettings) {
                  $evolutionMetricClass = $this->isEcommerceEvolutionMetric($metricSettings)
                                        ? "Piwik\\Plugins\\MultiSites\\Columns\\Metrics\\EcommerceOnlyEvolutionMetric"
                                        : "Piwik\\Plugins\\CoreHome\\Columns\\Metrics\\EvolutionMetric";
  
                  $extraProcessedMetrics[] = new $evolutionMetricClass(
                      $metricSettings[self::METRIC_RECORD_NAME_KEY],
                      $pastData,
                      $metricSettings[self::METRIC_EVOLUTION_COL_NAME_KEY],
                      $quotientPrecision = 1
                  );
              }
              $currentData->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics);
          }
      }
code_tokens: private function calculateEvolutionPercentages ( $ currentData , $ pastData , $ apiMetrics ) { if ( get_class ( $ currentData ) != get_class ( $ pastData ) ) { // sanity check for regressions throw new Exception ( "Expected \$pastData to be of type " . get_class ( $ currentData ) . " - got " . get_class ( $ pastData ) . "." ) ; } if ( $ currentData instanceof DataTable \ Map ) { $ pastArray = $ pastData -> getDataTables ( ) ; foreach ( $ currentData -> getDataTables ( ) as $ subTable ) { $ this -> calculateEvolutionPercentages ( $ subTable , current ( $ pastArray ) , $ apiMetrics ) ; next ( $ pastArray ) ; } } else { $ extraProcessedMetrics = $ currentData -> getMetadata ( DataTable :: EXTRA_PROCESSED_METRICS_METADATA_NAME ) ; foreach ( $ apiMetrics as $ metricSettings ) { $ evolutionMetricClass = $ this -> isEcommerceEvolutionMetric ( $ metricSettings ) ? "Piwik\\Plugins\\MultiSites\\Columns\\Metrics\\EcommerceOnlyEvolutionMetric" : "Piwik\\Plugins\\CoreHome\\Columns\\Metrics\\EvolutionMetric" ; $ extraProcessedMetrics [ ] = new $ evolutionMetricClass ( $ metricSettings [ self :: METRIC_RECORD_NAME_KEY ] , $ pastData , $ metricSettings [ self :: METRIC_EVOLUTION_COL_NAME_KEY ] , $ quotientPrecision = 1 ) ; } $ currentData -> setMetadata ( DataTable :: EXTRA_PROCESSED_METRICS_METADATA_NAME , $ extraProcessedMetrics ) ; } }
docstring: Performs a binary filter of two
  DataTables in order to correctly calculate evolution metrics.
  
  @param DataTable|DataTable\Map $currentData
  @param DataTable|DataTable\Map $pastData
  @param array $apiMetrics The array of string fields to calculate evolution
  metrics for.
  @throws Exception
docstring_tokens: Performs a binary filter of two DataTables in order to correctly calculate evolution metrics .