public function execute($command, callable $next)
    {
        $this->queue[] = function () use ($command, $next) {
            return $next($command);
        };

        if ($this->isExecuting) {
            return;
        }
        $this->isExecuting = true;

        try {
            $returnValue = $this->executeQueuedJobs();
        } catch (\Exception $e) {
            $this->isExecuting = false;
            $this->queue = [];
            throw $e;
        }

        $this->isExecuting = false;
        return $returnValue;
    }
public function execute($command, callable $next)
    {
        $this->queue[] = function () use ($command, $next) {
            return $next($command);
        };

        if ($this->isExecuting) {
            return;
        }
        $this->isExecuting = true;

        try {
            $returnValue = $this->executeQueuedJobs();
        } catch (\Exception $e) {
            $this->isExecuting = false;
            $this->queue = [];
            throw $e;
        }

        $this->isExecuting = false;
        return $returnValue;
    }
public function execute ( $ command , callable $ next ) { $ this -> queue [ ] = function ( ) use ( $ command , $ next ) { return $ next ( $ command ) ; } ; if ( $ this -> isExecuting ) { return ; } $ this -> isExecuting = true ; try { $ returnValue = $ this -> executeQueuedJobs ( ) ; } catch ( \ Exception $ e ) { $ this -> isExecuting = false ; $ this -> queue = [ ] ; throw $ e ; } $ this -> isExecuting = false ; return $ returnValue ; }
Execute the given command... after other running commands are complete.

@param object   $command
@param callable $next

@throws \Exception

@return mixed|void
Execute the given command ... after other running commands are complete .