protected function transform($middleware)
    {
        if (is_string($middleware))
        {
            return $this->container->get($middleware);
        }

        if (is_callable($middleware))
        {
            return new ClosureMiddleware($middleware);
        }

        return $middleware;
    }