src/Resolver.php
protected function resolveOne($middleware, &$key = null)
    {
        if ($middleware instanceof Closure) {
            $key = $key ? $this->castKey($key) : "";

        } elseif ($this->isAbstract($middleware)) {
            $key = $this->castKey($key, $middleware);
            $middleware = new $middleware;

        } elseif (is_object($middleware) && $middleware instanceof MiddlewareInterface) {
            $key = $this->castKey($key, get_class($middleware));

        } elseif (is_callable($middleware)) {
            $key = $key ? $this->castKey($key) : "";

        } elseif ($middleware instanceof MiddlewareCollection) {
            $key = $middleware->getId();
            $middleware = $this->resolveMany($middleware, $middleware->getId());

        } else {
            $middleware = false;
        }
        return $middleware;
    }
protected function resolveOne($middleware, &$key = null)
    {
        if ($middleware instanceof Closure) {
            $key = $key ? $this->castKey($key) : "";

        } elseif ($this->isAbstract($middleware)) {
            $key = $this->castKey($key, $middleware);
            $middleware = new $middleware;

        } elseif (is_object($middleware) && $middleware instanceof MiddlewareInterface) {
            $key = $this->castKey($key, get_class($middleware));

        } elseif (is_callable($middleware)) {
            $key = $key ? $this->castKey($key) : "";

        } elseif ($middleware instanceof MiddlewareCollection) {
            $key = $middleware->getId();
            $middleware = $this->resolveMany($middleware, $middleware->getId());

        } else {
            $middleware = false;
        }
        return $middleware;
    }
Resolve a single middleware.

@param mixed $middleware
@param null $key
@return bool|\Closure|\MichaelRShelton\MiddleMan\Interfaces\MiddlewareInterface