src/Middleware/ProfileMiddleware.php
public function profile() : \Closure
    {
        $stopwatch = $this->stopwatch;

        return function (callable $handler) use ($stopwatch) {

            return function ($request, array $options) use ($handler, $stopwatch) {
                $event = $stopwatch->start(
                    sprintf('%s %s', $request->getMethod(), $request->getUri()),
                    'eight_points_guzzle'
                );

                return $handler($request, $options)->then(

                    function ($response) use ($event) {
                        $event->stop();

                        return $response;
                    },

                    function ($reason) use ($event) {
                        $event->stop();

                        return \GuzzleHttp\Promise\rejection_for($reason);
                    }
                );
            };
        };
    }
public function profile() : \Closure
    {
        $stopwatch = $this->stopwatch;

        return function (callable $handler) use ($stopwatch) {

            return function ($request, array $options) use ($handler, $stopwatch) {
                $event = $stopwatch->start(
                    sprintf('%s %s', $request->getMethod(), $request->getUri()),
                    'eight_points_guzzle'
                );

                return $handler($request, $options)->then(

                    function ($response) use ($event) {
                        $event->stop();

                        return $response;
                    },

                    function ($reason) use ($event) {
                        $event->stop();

                        return \GuzzleHttp\Promise\rejection_for($reason);
                    }
                );
            };
        };
    }
public function profile ( ) : \ Closure { $ stopwatch = $ this -> stopwatch ; return function ( callable $ handler ) use ( $ stopwatch ) { return function ( $ request , array $ options ) use ( $ handler , $ stopwatch ) { $ event = $ stopwatch -> start ( sprintf ( '%s %s' , $ request -> getMethod ( ) , $ request -> getUri ( ) ) , 'eight_points_guzzle' ) ; return $ handler ( $ request , $ options ) -> then ( function ( $ response ) use ( $ event ) { $ event -> stop ( ) ; return $ response ; } , function ( $ reason ) use ( $ event ) { $ event -> stop ( ) ; return \ GuzzleHttp \ Promise \ rejection_for ( $ reason ) ; } ) ; } ; } ; }
Profiling each Request

@return \Closure
Profiling each Request