public function filter($column, $callable = null)
{
// Get the function arguments.
$args = func_get_args();
$column = array_shift($args);
// Check if we actually have a column or a callable.
if (is_numeric($column)) {
$callable = array_shift($args);
} else {
$callable = $column;
$column = null;
}
// Check the function arguments.
if (!is_callable($callable)) {
throw new InvalidArgumentException('The $callable parameter must be callable.');
}
if (isset($column) && !is_numeric($column)) {
throw new InvalidArgumentException('No proper column index provided. Expected a numeric, while given ' . var_export($column, true));
}
// Add the filter to our stack. Apply it to the whole row when our column
// appears to be the callable, being the only present argument.
$this->_filters[] = array('callable' => $callable, 'column' => isset($column) ? (int) $column : null, 'args' => $args);
return $this;
}