Fakerino\Configuration\ConfigurationFile\XmlConfigurationFile::xml2array PHP Method

xml2array() private method

Converts an XML string in an array
private xml2array ( SimpleXMLElement $xmlObject, array $out = [] ) : array
$xmlObject SimpleXMLElement
$out array
return array
    private function xml2array($xmlObject, $out = array())
    {
        foreach ($xmlObject->attributes() as $attr => $val) {
            $out['@attributes'][$attr] = (string) $val;
        }
        $hasChilds = false;
        foreach ($xmlObject as $index => $node) {
            $hasChilds = true;
            $out[$index][] = $this->xml2array($node);
        }
        if (!$hasChilds && ($val = (string) $xmlObject)) {
            $out['@value'] = $val;
        }
        foreach ($out as $key => $vals) {
            if (is_array($vals) && count($vals) === 1 && array_key_exists(0, $vals)) {
                $out[$key] = $vals[0];
            }
        }
        return $out;
    }
XmlConfigurationFile