public function buildXMLConfig(array $classesMetadata, string $path)
    {
        foreach ($classesMetadata as $alias => $classMetadata) {
            $dom = new \DOMDocument("1.0", "utf-8");
            $dom->preserveWhiteSpace = false;
            $dom->formatOutput = true;
            $root = $dom->createElement("dependencies");
            $dom->appendChild($root);

            // Build alias from class name if missing
            $alias = $alias ?? strtolower(str_replace('\\', '_', $classMetadata->className));

            $classData = $dom->createElement('instance');
            $classData->setAttribute('service', $alias);
            $classData->setAttribute('class', $classMetadata->className);

            foreach ($classMetadata->scopes as $scope) {
                $classData->setAttribute('scope', $scope);
            }

            $methodsData = $dom->createElement('methods');
            foreach ($classMetadata->methodsMetadata as $method => $methodMetadata) {
                if (count($methodMetadata->dependencies)) {
                    $methodData = $dom->createElement($method);
                    $argumentsData = $dom->createElement('arguments');
                    foreach ($methodMetadata->dependencies as $argument => $dependency) {
                        $argumentData = $dom->createElement($argument);
                        $this->setAttribute($dependency, $argumentData, $classesMetadata);
                        $argumentsData->appendChild($argumentData);
                    }
                    $methodData->appendChild($argumentsData);
                    $methodsData->appendChild($methodData);
                }
            }
            $classData->appendChild($methodsData);

            $propertiesData = $dom->createElement('properties');
            foreach ($classMetadata->propertiesMetadata as $property => $propertyMetadata) {
                if ($propertyMetadata->dependency !== null && $propertyMetadata->dependency !== '') {
                    $propertyData = $dom->createElement($property);
                    $this->setAttribute($propertyMetadata->dependency, $propertyData, $classesMetadata);
                    $propertiesData->appendChild($propertyData);
                }
            }

            $classData->appendChild($propertiesData);
            $root->appendChild($classData);
            $dom->save($path . $alias . '.xml');
        }
    }