中间件条件触发

@param $that
@param null $function
@param mixed ...$params
@return $this|Collection
961552
public static function run($function=null,$callback=null) {
        $that = self::instance();

        if($function instanceof \Closure) {
            $callback = $function;
            $function = Router::driver()->function;
        }

        $that->on($that->defaultCall,$callback);

        return $that->with($function);
    }
305947
public static function load($params = null)
    {
        if (!isset(self::$_instance)) {
            self::$_instance = new Auth($params);
        }

        return self::$_instance;
    }
452574
public function Where( $Func )
	{

		if ( $Func != null ){

			$repo = array();

			$Func = new Expression( $Func );

			foreach ( $this->repository as $item )
				if ( $Func->execute( $item ) )
					$repo[] = $item;

		} else {

			$repo = $this->repository;

		}

		return $this->getClone()->setRepository( $repo );

	}
439431
function intersection(Set $that) {
        $intersection = $this->cloneEmpty();

        $this->addIf($intersection, $this, [$that, 'has']);

        return $intersection;
    }
207431
public function where($statement, $params = null)
    {
        $this->where[] = $statement;
        $this->addParams($params);

        return $this;
    }
1319404
protected function getRaw($key, $function = null)
    {
        if (!$this->isString($key)) {
            /* If $key is not valid string throws InvalidArgumentException */
            throw new InvalidArgumentException('Cache key must be not empty string');
        }

        $item = $this->getCachedItem($key);

        if ($item && !$this->isExpired($item)) {
            return !is_null($function) ? $function($item->get()) : $item->get();
        }
    }
253733
public function appendJs($selector, $function, ...$params)
    {
        array_unshift($params, $selector, $function);
        $this->append([static::TYPE_INLINE, call_user_func_array([$this, 'build'], $params)]);
        return $this;
    }
688745
public function set($param1, $param2 = null)
    {
        // do nothing if we get nothing
        if (empty($param1))
        {
            return $this;
        }
        
        // when param 2 is not null we assume that only one set is passed
        // like: set( 'name', 'Lu' ); instead of set( array( 'name' => 'Lu' ) );
        if ( !is_null( $param2 ) )
        {
            $param1 = array( $param1 => $param2 );
        }
        
        // merge the new values with the existing ones.
        $this->values = array_merge( $this->values, $param1 ); 
        
        // return self so we can continue running the next function
        return $this;
    }
707395
public function params($params = null)
    {
        if (null !== $params) {
            $this->params = $params;

            return $this;
        }

        return $this->params;
    }
869932
function chain($funcs,$args=NULL) {
		$out=[];
		foreach (is_array($funcs)?$funcs:$this->split($funcs) as $func)
			$out[]=$this->call($func,$args);
		return $out;
	}
1325879
public function invoke($collection=null, $function_name=null, $arguments=null) {
    $args = self::_wrapArgs(func_get_args(), 2);
    $__ = new self;
    list($collection, $function_name) = $__->first($args, 2);
    $arguments = $__->rest(func_get_args(), 2);
    
    // If passed an array or string, return an array
    // If passed an object, return an object
    $is_obj = is_object($collection);
    $result = (empty($arguments)) ? array_map($function_name, (array) $collection) : array_map($function_name, (array) $collection, $arguments);
    if($is_obj) $result = (object) $result;
    
    return self::_wrap($result);
  }
47067
public function reduce(callable $func = null, $initial = null)
    {
        if (null === $func) {
            return parent::reduce(static function ($carry, $item) {
                $carry += $item;

                return $carry;
            }, $initial ?? 0);
        }

        return parent::reduce($func, $initial);
    }
419153
public static function combine(/* $func1, $func2, ... */)
    {
        $functions = func_get_args();

        foreach ($functions as $function) {
            static::validate($function);
        }

        return function() use ($functions) {
            $result = array();
            $args = func_get_args();

            foreach ($functions as $function) {
                $result[] = call_user_func_array($function, $args);
            }

            return $result;
        };
    }
26063
public function request($function, array $params = array(), $cache = null)
    {
        $request = $this->startRequest($function, $params, $cache);

        return $this->fetchResponse($request);
    }
258625
public function unpack(callable $func = null): self
    {
        $func = $func ?? static function (...$args) {
            yield from $args;
        };

        /** @psalm-suppress MixedArgument */
        return $this->map(static function (/* iterable */ $args = null) use ($func) {
            return $func(...$args ?? []);
        });
    }
1294664
public static function load($params = null)
    {
        if (!isset(self::$_instance)) {
            self::$_instance = new Email($params);
        }

        return self::$_instance;
    }
926374
public function map(Closure $func)
    {
        return new static($this->type, $this->elements->map($func)->toArray());
    }