protected function _format($type) {
        $response = array(
            'success' => $this->_success,
            'data' => $this->_data
        );

        if ($this->_code) {
            $response['code'] = $this->_code;
        }

        switch (strtolower($type)) {
            case 'json':
                $format = TypeConverter::toJson($response);
            break;
            case 'xml':
                $format = TypeConverter::toXml($response);
            break;
            case 'html';
            case 'text':
            default:
                $format = (string) $this->_data;
            break;
        }

        return $format;
    }