lithium\test\Mocker::_filter PHP Method

_filter() protected static method

Executes a set of filters against a method by taking a method's main implementation as a callback, and iteratively wrapping the filters around it.
See also: lithium\util\collection\Filters
protected static _filter ( string $class, string | array $method, array $params, Closure $callback, array $filters = [] ) : mixed
$class string Fully namespaced class to apply filters.
$method string | array The name of the method being executed, or an array containing the name of the class that defined the method, and the method name.
$params array An associative array containing all the parameters passed into the method.
$callback Closure The method's implementation, wrapped in a closure.
$filters array Additional filters to apply to the method for this call only.
return mixed
    protected static function _filter($class, $method, $params, $callback, $filters = array())
    {
        $hasNoFilters = empty(static::$_methodFilters[$class][$method]);
        if ($hasNoFilters && !$filters && !Filters::hasApplied($class, $method)) {
            return $callback($class, $params, null);
        }
        if (!isset(static::$_methodFilters[$class][$method])) {
            static::$_methodFilters += array($class => array());
            static::$_methodFilters[$class][$method] = array();
        }
        $data = array_merge(static::$_methodFilters[$class][$method], $filters, array($callback));
        return Filters::run($class, $params, compact('data', 'class', 'method'));
    }