private function processDiffs(array $tables, Config $config)
{
$stat = $config['diff_col'];
if ($config['compare']) {
return $tables;
}
if (!in_array('diff', $config['cols'])) {
return $tables;
}
if (!in_array($stat, $config['cols'])) {
throw new \InvalidArgumentException(sprintf('The "%s" column must be visible when using the diff column', $stat));
}
return F\map($tables, function ($table) use($stat) {
$means = F\map($table, function ($row) use($stat) {
return $row[$stat];
});
$min = min($means);
return F\map($table, function ($row) use($min, $stat) {
if ($row[$stat] === 0) {
$row['diff'] = 0;
return $row;
}
$row['diff'] = ($row[$stat] / $min - 1) * 100;
return $row;
});
});
}