public function use($middleware): void
    {
        if (!is_subclass_of($middleware, MiddlewareInterface::class)) {
            if (!is_callable($middleware)) {
                throw new ApplicationException(sprintf(
                    'Middleware must be either class or object that implements `%s`',
                    MiddlewareInterface::class
                ));
            }

            $middleware = new CallableMiddleware($middleware);
        }

        $this->middleware[] = $middleware;
    }
public function use($middleware): void
    {
        if (!is_subclass_of($middleware, MiddlewareInterface::class)) {
            if (!is_callable($middleware)) {
                throw new ApplicationException(sprintf(
                    'Middleware must be either class or object that implements `%s`',
                    MiddlewareInterface::class
                ));
            }

            $middleware = new CallableMiddleware($middleware);
        }

        $this->middleware[] = $middleware;
    }
public function use ( $ middleware ) : void { if ( ! is_subclass_of ( $ middleware , MiddlewareInterface :: class ) ) { if ( ! is_callable ( $ middleware ) ) { throw new ApplicationException ( sprintf ( 'Middleware must be either class or object that implements `%s`' , MiddlewareInterface :: class ) ) ; } $ middleware = new CallableMiddleware ( $ middleware ) ; } $ this -> middleware [ ] = $ middleware ; }
Registers PSR-15 compatible middelware.
Middleware can be either callable object which accepts PSR-7 server request interface and returns
response interface, or just class name that implements psr-15 middleware or its instance.

@param MiddlewareInterface|callable $middleware
Registers PSR - 15 compatible middelware . Middleware can be either callable object which accepts PSR - 7 server request interface and returns response interface or just class name that implements psr - 15 middleware or its instance .