<commit_before><?php
namespace PharIo\Phive {

    abstract class XmlRepository {

        /**
         * @var string
         */
        private $filename = '';

        /**
         * @var \DOMDocument
         */
        private $dom;

        /**
         * @var \DOMXPath
         */
        private $xPath;

        /**
         * @param File $filename
         */
        public function __construct(Filename $filename) {
            $this->filename = $filename;
            $this->init();
        }

        /**
         * @return \DOMDocument
         */
        protected function getDom() {
            return $this->dom;
        }

        /**
         * @return string
         */
        protected function getFilename() {
            return $this->filename;
        }

        /**
         * @return \DOMXPath
         */
        protected function getXPath() {
            return $this->xPath;
        }

        /**
         * @return string
         */
        abstract protected function getRootElementName();

        /**
         * @return string
         */
        abstract protected function getNamespace();

        /**
         *
         */
        private function init() {
            $this->dom = new \DOMDocument('1.0', 'UTF-8');
            $this->dom->preserveWhiteSpace = false;
            $this->dom->formatOutput = true;
            if ($this->filename->exists()) {
                $this->dom->load($this->filename->asString());
            } else {
                $this->dom->appendChild($this->dom->createElement($this->getRootElementName()));
            }
            $this->xPath = new \DOMXPath($this->dom);
            $this->xPath->registerNamespace('phive', $this->getNamespace());
        }

    }

}

<commit_msg>Make fallback XML root element be in correct namespace<commit_after><?php
namespace PharIo\Phive {

    abstract class XmlRepository {

        /**
         * @var string
         */
        private $filename = '';

        /**
         * @var \DOMDocument
         */
        private $dom;

        /**
         * @var \DOMXPath
         */
        private $xPath;

        /**
         * @param File $filename
         */
        public function __construct(Filename $filename) {
            $this->filename = $filename;
            $this->init();
        }

        /**
         * @return \DOMDocument
         */
        protected function getDom() {
            return $this->dom;
        }

        /**
         * @return string
         */
        protected function getFilename() {
            return $this->filename;
        }

        /**
         * @return \DOMXPath
         */
        protected function getXPath() {
            return $this->xPath;
        }

        /**
         * @return string
         */
        abstract protected function getRootElementName();

        /**
         * @return string
         */
        abstract protected function getNamespace();

        /**
         *
         */
        private function init() {
            $this->dom = new \DOMDocument('1.0', 'UTF-8');
            $this->dom->preserveWhiteSpace = false;
            $this->dom->formatOutput = true;
            if ($this->filename->exists()) {
                $this->dom->load($this->filename->asString());
            } else {
                $this->dom->appendChild($this->dom->createElementNS($this->getNamespace(), $this->getRootElementName()));
            }
            $this->xPath = new \DOMXPath($this->dom);
            $this->xPath->registerNamespace('phive', $this->getNamespace());
        }

    }

}


{'fraction_non_alphanumeric': 0.13983286908077994, 'fraction_numerical': 0.001671309192200557, 'mean_word_length': 1.28, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4028183', 'n_tokens_mistral': 933, 'n_tokens_neox': 901, 'n_words': 173}