protected function extractTookFromResponse(array $response)
    {
        if (is_null($response['body'])) {
            return null;
        }
        $content = stream_get_contents($response['body']);
        rewind($response['body']);

        if (preg_match('/\"took\":(\d+)/', $content, $matches)) {
            return (int) $matches[1];
        }

        return null;
    }