protected function wrapAtomEntry($entity, array $links = null)
    {
        Validate::notNull($entity, 'entity');

        $content = new Content();
        $content->setType(Resources::XML_CONTENT_TYPE);
        $content->setText(ContentPropertiesSerializer::serialize($entity));

        $atomEntry = new Entry();
        $atomEntry->setContent($content);

        if ($links) {
            $atomEntry->setLink($links);
        }

        $xmlWriter = new \XMLWriter();
        $xmlWriter->openMemory();
        $atomEntry->writeXml($xmlWriter);

        return $xmlWriter->outputMemory();
    }