/**
* Get the return value from the callable.
*
* Parameters can be can handled in three ways:
* - null - Nothing passed to the callback
* - Indexed array - Value of each element will be passed to function in order
* - Associative array - Key names will attempt to match to the callable function variable names
*/
protected function invokeCallable(callable $callback, $callbackArguments)
{
if ($callbackArguments === null) {
return call_user_func($callback);
}
if (Arr::isIndexedArray($callbackArguments)) {
return call_user_func_array($callback, (array) $callbackArguments);
}
$orderedArgs = $this->getArguments($callback, $callbackArguments);
return call_user_func_array($callback, $orderedArgs);
}