public static on ( mixed $context, string $method, array $params, Closure $callback, array $filters = [] ) : mixed | ||
$context | mixed | The instance or class name context to perform the filtering on. |
$method | string | The name of the method which is going the be filtered. |
$params | array | The parameters passed to the original method. |
$callback | Closure | The original method logic closure. |
$filters | array | Additional filters to apply to the method for this call only. |
return | mixed | Returns The result of the chain. |
public static function on($context, $method, $params, $callback, $filters = [])
{
if (!static::$_enabled) {
array_unshift($params, null);
return call_user_func_array($callback, $params);
}
$filters = array_merge(static::filters($context, $method), $filters, [$callback]);
$chain = new Chain(compact('filters', 'method', 'params'));
$closure = $chain->rewind();
array_unshift($params, $chain);
return call_user_func_array($closure, $params);
}
/** * The default `'quit'` filter. */ protected function _quit() { return Filter::on($this, 'quit', [$this->suite()->passed()], function ($chain, $success) { }); }