/**
  * Log the response.
  *
  * @param mixed $response
  * @param IEvent $event
  */
 protected function logResponse($response, IEvent $event)
 {
     $content = '';
     if (is_string($response)) {
         $content = $response;
     } elseif ($response instanceof LaravelResponse || $response instanceof JsonResponse) {
         $content = $response->getContent();
     }
     $message = new Response($response->getStatusCode(), $response->headers->all(), $content);
     $result = $this->extractor->getResponse($message);
     $this->logger->end($event, $result['response']);
 }
 function it_handles_communication_logging(CommunicationLogger $logger, CommunicationExtractor $extractor, Request $request, Response $response, HeaderBag $requestHeaders, IEvent $event)
 {
     $request->getMethod()->shouldBeCalled()->willReturn('POST');
     $request->getContent()->shouldBeCalled()->willReturn('request');
     $request->getUri()->shouldBeCalled()->willReturn('http://example.com');
     $request->headers = $requestHeaders;
     $requestHeaders->all()->shouldBeCalled()->willReturn([]);
     $next = function (Request $request) use($response) {
         return new Response();
     };
     $extractor->getRequest(Argument::type(GuzzleRequest::class))->shouldBeCalled()->willReturn(['request' => 'request']);
     $extractor->getResponse(Argument::type(GuzzleResponse::class))->shouldBeCalled()->willReturn(['response' => 'response']);
     $logger->begin('request', 'http://example.com', 'POST', '')->shouldBeCalled()->willReturn($event);
     $logger->end($event, 'response')->shouldBeCalled();
     $this->handle($request, $next);
 }