/**
* Will create a new ColumnConfiguration with all defaults but allows overriding of all properties through the method.
*
* @param string $name The name of the configuration, required for the configuration
* @param string|callable $callable The function to execute, defaults to null which means the default will be set.
* @param Searchable $searchable If the column should be searchable or not
* @param Orderable $orderable If the column should be orderable or not
* @return $this
*/
public function column($name, $callable = null, Searchable $searchable = null, Orderable $orderable = null)
{
/**
* @var ColumnConfigurationBuilder
*/
$config = ColumnConfigurationBuilder::create();
if (is_string($name)) {
$config->name($name);
} else {
throw new \InvalidArgumentException('$name must be a string');
}
if (!is_null($callable)) {
if (is_callable($callable)) {
$config->withCallable($callable);
} elseif (is_string($callable)) {
$config->withCallable(function () use($callable) {
return $callable;
});
}
}
if (is_null($searchable)) {
$config->searchable(Searchable::NORMAL());
}
if (is_null($orderable)) {
$config->orderable(Orderable::BOTH());
}
$this->columnConfiguration[] = $config->build();
return $this;
}