columns = $columns; $this->columnToAdd = $columnToAdd; $this->functionToApply = $functionToApply; $this->functionParameters = $functionParameters; } /** * Executes a callback on every row of the supplied table and adds the result of * the callback as a new column to each row. * * @param DataTable $table The table to filter. */ public function filter($table) { foreach ($table->getRows() as $row) { $columnValues = array(); foreach ($this->columns as $column) { $columnValues[] = $row->getColumn($column); } $parameters = array_merge($columnValues, $this->functionParameters); $value = call_user_func_array($this->functionToApply, $parameters); $row->setColumn($this->columnToAdd, $value); $this->filterSubTable($row); } } }