protected function toString($data)
    {
        if ($data instanceof \SimpleXMLElement) {
            return $data->asXML();
        } elseif ($data instanceof \DOMDocument) {
            return $data->saveXML();
        } elseif (is_string($data)) {
            return $data;
        }

        throw new \InvalidArgumentException(
            sprintf(
                'Invalid XML content type, %s provided.',
                gettype($data)
            )
        );
    }