/** * @param SimpleXMLElement $xml * * @return DeliveryMethod */ public static function createFromXML(SimpleXMLElement $xml) { /* <characteristic displayValue="Basic (0-500 EUR)" value="1" name="Insurance range code"/> */ $attributes = $xml->attributes(); $children = $xml->children(); $deliveryMethod = new self(); $deliveryMethod->setName($attributes['name']); $deliveryMethod->setVisibility($attributes['visiblity']); if (isset($children->product)) { foreach ($children->product as $productXml) { $deliveryMethod->addProduct(Product::createFromXML($productXml)); } } return $deliveryMethod; }