src/Middleware/Dispatcher.php
protected function transform($middleware, $wrappable = true)
    {
        if (is_a($middleware, Application::MIDDLEWARE) === false) {
            $approach = (boolean) $this->approach($middleware);

            $response = $approach === self::SINGLE_PASS ? $this->response : null;

            $wrapper = new CallableMiddlewareWrapper($middleware, $response);

            $middleware = $wrappable === true ? $wrapper : $middleware;
        }

        return $middleware;
    }
protected function transform($middleware, $wrappable = true)
    {
        if (is_a($middleware, Application::MIDDLEWARE) === false) {
            $approach = (boolean) $this->approach($middleware);

            $response = $approach === self::SINGLE_PASS ? $this->response : null;

            $wrapper = new CallableMiddlewareWrapper($middleware, $response);

            $middleware = $wrappable === true ? $wrapper : $middleware;
        }

        return $middleware;
    }
Transforms the specified middleware into a PSR-15 middleware.

@param  \Interop\Http\ServerMiddleware\MiddlewareInterface|\Closure $middleware
@param  boolean                                                     $wrappable
@return \Interop\Http\ServerMiddleware\MiddlewareInterface