src/Middleware.php
public static function history(History $history)
    {
        return function (callable $handler) use ($history) {
            return function (
                CommandInterface $command,
                RequestInterface $request = null
            ) use ($handler, $history) {
                $ticket = $history->start($command, $request);
                return $handler($command, $request)
                    ->then(
                        function ($result) use ($history, $ticket) {
                            $history->finish($ticket, $result);
                            return $result;
                        },
                        function ($reason) use ($history, $ticket) {
                            $history->finish($ticket, $reason);
                            return Promise\rejection_for($reason);
                        }
                    );
            };
        };
    }
public static function history(History $history)
    {
        return function (callable $handler) use ($history) {
            return function (
                CommandInterface $command,
                RequestInterface $request = null
            ) use ($handler, $history) {
                $ticket = $history->start($command, $request);
                return $handler($command, $request)
                    ->then(
                        function ($result) use ($history, $ticket) {
                            $history->finish($ticket, $result);
                            return $result;
                        },
                        function ($reason) use ($history, $ticket) {
                            $history->finish($ticket, $reason);
                            return Promise\rejection_for($reason);
                        }
                    );
            };
        };
    }
public static function history ( History $ history ) { return function ( callable $ handler ) use ( $ history ) { return function ( CommandInterface $ command , RequestInterface $ request = null ) use ( $ handler , $ history ) { $ ticket = $ history -> start ( $ command , $ request ) ; return $ handler ( $ command , $ request ) -> then ( function ( $ result ) use ( $ history , $ ticket ) { $ history -> finish ( $ ticket , $ result ) ; return $ result ; } , function ( $ reason ) use ( $ history , $ ticket ) { $ history -> finish ( $ ticket , $ reason ) ; return Promise \ rejection_for ( $ reason ) ; } ) ; } ; } ; }
Tracks command and request history using a history container.

This is useful for testing.

@param History $history History container to store entries.

@return callable
Tracks command and request history using a history container .