<commit_before><?php

function noeudXml($produit, $noeud, &$xml, $exceptions = array()) {
	foreach ($noeud as $key => $children) {
		if (!is_numeric($key)) {
			$xml .= "<$key>";
			$xml .= noeudXml($produit, $children, $xml, $exceptions);
			$xml .= "</$key>";
		} else {
			$val = $produit->getTotalVolume($noeud);
			if ($val) {
				return (in_array($noeud->getKey(), $exceptions))? $val : sprintf("%01.02f", $val);
			} else {
				return (in_array($noeud->getKey(), array('stock-debut-periode', 'stock-fin-periode')))? 0 : null;
			}
		}
	}
}

function storeMultiArray(&$node, $keys, $value) {
	$k = array_shift($keys);
	if (!$k) {
		if (!is_array($node)) {
			return $value + $node;
		}else{
			return $value;
		}
	}
	if (!is_array($node)) {
		$node = array();
	}
	$node[$k] = storeMultiArray($node[$k], $keys, $value);
	return $node;
}

function multiArray2XML($preXML) {
	$xml = '';
	foreach ($preXML as $k => $v) {
		if (is_array($v)) {
			$xml .= "<$k>";
			$xml .= multiArray2XML($v);
			$xml .= "</$k>";
		}else{
			$xml .= "<$k>";
                        $xml .= $v;
                        $xml .= "</$k>";
		}
	}
	return $xml;
}

function details2XmlDouane($detail) {
	$confDetail = $detail->getConfig()->getDocument()->declaration->detail;
        $preXML = array();
        foreach (array('stocks_debut', 'entrees', 'sorties', 'stocks_fin') as $type) {
	  foreach ($detail->get($type) as $k => $v) {
		if ($v && $confDetail->get($type)->exist($k) && $confDetail->get($type)->get($k)->douane_cat) {
                        $preXML = storeMultiArray($preXML, split('/', $confDetail->get($type)->get($k)->douane_cat),  $v);
		}
	  }
	}
	return multiArray2XML($preXML);
}

function formatXml($xml, $level = 0) {
	while (preg_match("/\<[a-zA-Z0-9\-\_]*\>\<\/[a-zA-Z0-9\-\_]*\>/", $xml)) {<commit_msg>Quatre chiffres après la virgule pour ls volumes<commit_after><?php

function noeudXml($produit, $noeud, &$xml, $exceptions = array()) {
	foreach ($noeud as $key => $children) {
		if (!is_numeric($key)) {
			$xml .= "<$key>";
			$xml .= noeudXml($produit, $children, $xml, $exceptions);
			$xml .= "</$key>";
		} else {
			$val = $produit->getTotalVolume($noeud);
			if ($val) {
				return (in_array($noeud->getKey(), $exceptions))? $val : sprintf("%01.02f", $val);
			} else {
				return (in_array($noeud->getKey(), array('stock-debut-periode', 'stock-fin-periode')))? 0 : null;
			}
		}
	}
}

function storeMultiArray(&$node, $keys, $value) {
	$k = array_shift($keys);
	if (!$k) {
		if (!is_array($node)) {
			return $value + $node;
		}else{
			return $value;
		}
	}
	if (!is_array($node)) {
		$node = array();
	}
	$node[$k] = storeMultiArray($node[$k], $keys, $value);
	return $node;
}

function multiArray2XML($preXML) {
	$xml = '';
	foreach ($preXML as $k => $v) {
		if (is_array($v)) {
			$xml .= "<$k>";
			$xml .= multiArray2XML($v);
			$xml .= "</$k>";
		}else{
			$xml .= "<$k>";
                        $xml .= sprintf('%.04f', $v);
                        $xml .= "</$k>";
		}
	}
	return $xml;
}

function details2XmlDouane($detail) {
	$confDetail = $detail->getConfig()->getDocument()->declaration->detail;
        $preXML = array();
        foreach (array('stocks_debut', 'entrees', 'sorties', 'stocks_fin') as $type) {
	  foreach ($detail->get($type) as $k => $v) {
		if ($v && $confDetail->get($type)->exist($k) && $confDetail->get($type)->get($k)->douane_cat) {
                        $preXML = storeMultiArray($preXML, split('/', $confDetail->get($type)->get($k)->douane_cat),  $v);
		}
	  }
	}
	return multiArray2XML($preXML);
}

function formatXml($xml, $level = 0) {
	while (preg_match("/\<[a-zA-Z0-9\-\_]*\>\<\/[a-zA-Z0-9\-\_]*\>/", $xml)) {
{'fraction_non_alphanumeric': 0.24789115646258503, 'fraction_numerical': 0.00816326530612245, 'mean_word_length': 3.1963470319634704, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 30}, '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': '3869429', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1437, 'n_words': 264}