private function sendResponse(MethodAbstract $method, RequestInterface $request, ResponseInterface $response, $data)
    {
        $statusCode = $response->getStatusCode();
        if (empty($statusCode)) {
            // in case we have only one defined response use this code
            $responses = $method->getResponses();
            if (count($responses) == 1) {
                $statusCode = key($responses);
            } else {
                $statusCode = 200;
            }

            $response->setStatus($statusCode);
        }

        $this->responseWriter->setBody($response, $data, $request);
    }