private function loadV2(\SimpleXmlElement $xml, \Dice\Dice $dice) { foreach ($xml as $key => $value) { $rule = $dice->getRule((string) $value->name); if ($value->call) { foreach ($value->call as $name => $call) { $callArgs = []; foreach ($call->children() as $key => $param) { $callArgs[] = $this->getComponent($param); } $rule['call'][] = [(string) $call['method'], $callArgs]; } } if (isset($value['inherit'])) { $rule['inherit'] = $value['inherit'] == 'false' ? false : true; } if ($value['instanceOf']) { $rule['instanceOf'] = (string) $value['instanceOf']; } if (isset($value['shared'])) { $rule['shared'] = (string) $value['shared'] === 'true'; } if ($value->constructParams) { foreach ($value->constructParams->children() as $child) { $rule['constructParams'][] = $this->getComponent($child); } } if ($value->substitute) { foreach ($value->substitute as $use) { $rule['substitutions'][(string) $use['as']] = $this->getComponent($use['use'], true); } } if ($value->shareInstances) { foreach ($value->shareInstances->children() as $share) { $rule['shareInstances'][] = $this->getComponent($share); } } $dice->addRule((string) $value['name'], $rule); } }