public function filter(OptionsInterface $options, $value)
{
if (is_callable($value)) {
$value = call_user_func($value, $options);
}
if (is_array($value)) {
$commands = $this->getDefault($options);
foreach ($value as $commandID => $classFQN) {
$commands->defineCommand($commandID, $classFQN);
}
return $commands;
}
if (!$value instanceof FactoryInterface) {
$class = get_called_class();
throw new \InvalidArgumentException("{$class} expects a valid command factory");
}
return $value;
}