lithium\test\Mocker::applyFilter PHP Метод

applyFilter() публичный статический Метод

Apply a closure to a method of the current static object.
См. также: lithium\core\StaticObject::_filter()
См. также: lithium\util\collection\Filters
public static applyFilter ( string $class, mixed $method = null, Closure $filter = null ) : void
$class string Fully namespaced class to apply filters.
$method mixed The name of the method to apply the closure to. Can either be a single method name as a string, or an array of method names. Can also be false to remove all filters on the current object.
$filter Closure The closure that is used to filter the method(s), can also be false to remove all the current filters for the given method.
Результат void
    public static function applyFilter($class, $method = null, $filter = null)
    {
        if ($class === false) {
            return static::$_methodFilters = array();
        }
        if ($method === false) {
            return static::$_methodFilters[$class] = array();
        }
        foreach ((array) $method as $m) {
            if (!isset(static::$_methodFilters[$class][$m]) || $filter === false) {
                static::$_methodFilters[$class][$m] = array();
            }
            if ($filter !== false) {
                static::$_methodFilters[$class][$m][] = $filter;
            }
        }
    }

Usage Example

Пример #1
0
 public function tearDown()
 {
     Mocker::applyFilter(false);
 }