public function serializeArray(
            $array,
            XmlStreamWriter $xmlWriter,
            string $tagName = null,
            string $elementTagName = null
    ): XmlStreamWriter {
        if (null === $tagName) {
            $tagName = 'array';
        }

        if (!empty($tagName)) {
            $xmlWriter->writeStartElement($tagName);
        }

        foreach ($array as $key => $value) {
            if (is_int($key)) {
                $this->serialize($value, $xmlWriter, $elementTagName);
            } else {
                $this->serialize($value, $xmlWriter, $key);
            }
        }

        if (!empty($tagName)) {
            $xmlWriter->writeEndElement();
        }

        return $xmlWriter;
    }