@param $handler
@param $condition

@return array

@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
@throws \ReflectionException
331640
protected function resolveHandlerAndCondition($handler, $condition): array
    {
        if (is_int($handler) || (is_string($handler) && !class_exists($handler))) {
            list($handler, $condition) = [$condition, $handler];
        }

        return [$this->makeClosure($handler), $condition];
    }
1142331
public static function throw_if($condition, $exception, ...$parameters)
    {
        if ($condition) {
            throw (\is_string($exception) ? new $exception(...$parameters) : $exception);
        }

        return $condition;
    }
12274
public function getPreconditionByHandle($handle)
    {
        $list = $this->config->get('install.preconditions');
        if (!isset($list[$handle])) {
            throw new Exception(sprintf('Unable to find an install precondition with handle %s', $handle));
        }
        if (!$list[$handle]) {
            throw new Exception(sprintf('The precondition with handle %s is disabled', $handle));
        }
        $className = $list[$handle];
        $instance = $this->getPreconditionByClassName($className);

        return $instance;
    }
534828
public function handler($handler = null)
    {
        if ($handler !== null) {
            $this->handler = $this->getRealHandler($handler);
        }

        return $this->handler;
    }
404789
protected function handleException($handler, Throwable $exception)
	{
		if($handler instanceof Closure)
		{
			return $handler($exception);
		}

		return $this->handlerFactory($handler)->handle($exception);
	}
1264224
public function findComponentByHandler($handler)
    {
        foreach ($this->page->components as $component) {
            if ($component->methodExists($handler)) {
                return $component;
            }
        }

        foreach ($this->layout->components as $component) {
            if ($component->methodExists($handler)) {
                return $component;
            }
        }

        return null;
    }
480699
protected function validateConditionTrigger($condition_id, array $args)
    {
        try {
            $handlers = $this->condition->getHandlers();
            return static::call($handlers, $condition_id, 'validate', $args);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
248554
protected function getHandlerAdapter($handler)
    {
        foreach ($this->handlerAdapters as $ha) {
            if ($ha->supports($handler)) {
                return $ha;
            }
        }
        throw new \Exception("No adapter for handler [".get_class($handler)."]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler.");
    }
332188
public function setHandler($handler, $handlerMethod = null) : void
    {
        if (!is_callable($handler) && is_null($handlerMethod)) {
            throw new \InvalidArgumentException(
                'In case the $handler is not a callable, $handlerMethod must specify a method to be called'
            );
        }
        $this->handler = $handler;
        $this->handlerMethod = $handlerMethod;
    }
636238
private function _prepareCondition(ConditionInterface $condition = null)
	{
		$this->condition = $this->expressionBuilderFactory->create($condition)->build();
	}
288754
protected function getCount($condition)
    {
        $class = $this->className;
        return $class::find()
            ->select(['id', $this->leftAttribute, $this->rightAttribute, $this->rootAttribute])
            ->where($condition)
            ->count();
    }
242263
public static function getBy($conditions, $constructor=null)
	{
		$ret = self::getListBy($conditions,$constructor);
		$count = count($ret);
		if ($count === 0)
		{
			return static::find();
		}
		else
		{
			debug_assert($count === 1, 'getBy expects single or no result, but `'.$count.'` resulted.');
			return array_shift($ret);
		}
	}
764689
public function map($handler)
    {
        $result = array();

        foreach ($this as $id => $document) {
            $result[$id] = $handler($document);
        }

        return $result;
    }
1197205
public function filter($handler)
    {
        $result = array();

        foreach ($this as $id => $document) {
            if (!$handler($document)) {
                continue;
            }

            $result[$id] = $document;
        }

        return $result;
    }
74298
protected function callHandler(array $condition, array $data)
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $condition['id'], 'process', array($condition, $data, $this));
        } catch (Exception $ex) {
            return false;
        }
    }
1099452
public function pushHandler($handler)
    {
        if (is_callable($handler)) {
            $handler = new CallbackHandler($handler);
        }

        if (!$handler instanceof HandlerInterface) {
            throw new InvalidArgumentException(
                  "Argument to " . __METHOD__ . " must be a callable, or instance of "
                . "Whoops\\Handler\\HandlerInterface"
            );
        }

        $this->handlerStack[] = $handler;
        return $this;
    }
1206005
private function extract($handler)
    {
        if (is_array($handler)) {
            return $this->fromClassMethodArray($handler);
        }
        if (strpos($handler, self::CHAR_AT) !== false) {
            return $this->fromAtNotation($handler);
        }
        if (strpos($handler, self::CHAR_DOT) !== false) {
            return $this->fromDotNotation($handler);
        }
        return $this->fromClassName($handler);
    }