/** * @param \SimpleXMLElement $xml * * @return Order * @throws BpostXmlNoReferenceFoundException * @throws BpostNotImplementedException */ public static function createFromXML(\SimpleXMLElement $xml) { // @todo work with classmaps ... if (!isset($xml->reference)) { throw new BpostXmlNoReferenceFoundException(); } $order = new Order((string) $xml->reference); if (isset($xml->costCenter) && $xml->costCenter != '') { $order->setCostCenter((string) $xml->costCenter); } if (isset($xml->orderLine)) { foreach ($xml->orderLine as $orderLine) { $order->addLine(Line::createFromXML($orderLine)); } } if (isset($xml->box)) { foreach ($xml->box as $box) { $order->addBox(Box::createFromXML($box)); } } return $order; }