public function appendOnCondition($middleware, callable $condition, $priority = 0): Server
    {
        if (!is_array($middleware)) {
            $middleware = [$middleware];
        }

        foreach ($middleware as $mw) {
            $this->stack[$priority][] = [$condition, $mw];
        }

        return $this;
    }
public function appendOnCondition($middleware, callable $condition, $priority = 0): Server
    {
        if (!is_array($middleware)) {
            $middleware = [$middleware];
        }

        foreach ($middleware as $mw) {
            $this->stack[$priority][] = [$condition, $mw];
        }

        return $this;
    }
public function appendOnCondition ( $ middleware , callable $ condition , $ priority = 0 ) : Server { if ( ! is_array ( $ middleware ) ) { $ middleware = [ $ middleware ] ; } foreach ( $ middleware as $ mw ) { $ this -> stack [ $ priority ] [ ] = [ $ condition , $ mw ] ; } return $ this ; }
Adds a middleware to the stack only if the condition returns true.

The `$condition` parameter must be a callable and it will be called with the
`ServerRequestInterface` object as argument.

@param MiddlewareInterface|callable|array $middleware
@param callable                           $condition
@param int                                $priority
@return $this
Adds a middleware to the stack only if the condition returns true .