private static function processDataSources(\DOMDocument $xml, Config &$config) { $sources = $xml->getElementsByTagName(self::DATA_SOURCE_ELEMENT); foreach ($sources as $source) { $type = DataSourceType::valueOf($source->getAttribute('type')); $name = $source->getAttribute('name'); $host = $source->getElementsByTagName('host')->item(0)->nodeValue; $port = $source->getElementsByTagName('port')->length == 0 ? null : $source->getElementsByTagName('port')->item(0)->nodeValue; $username = $source->getElementsByTagName('username')->item(0)->nodeValue; $password = $source->getElementsByTagName('password')->item(0)->nodeValue; $database = $source->getElementsByTagName('database')->item(0)->nodeValue; $dataSource = new DataSourceConfig($type, $name, $host, $port, $username, $password, $database); $config->addDataSource($dataSource); } }