/** * @internal * * @param \SimpleXMLElement $xml * * @return Shipment */ public static function fromXml(\SimpleXMLElement $xml) { $shipment = new Shipment(); $shipment->setIsResponse(); if (isset($xml->Shipper)) { $shipment->setShipper(Shipper::fromXml($xml->Shipper)); } if (isset($xml->ShipTo->Address)) { $shipment->setDestination(InstructionalAddress::fromXml($xml->ShipTo->Address)); } if (isset($xml->Package)) { foreach ($xml->Package as $package) { $shipment->addPackage(Package::fromXml($package)); } } if (isset($xml->Service)) { $shipment->setService(Service::fromXml($xml->Service)); } return $shipment; }
/** * @internal * * @param Weight $weight * * @return Package */ public function setWeight(Weight $weight) { parent::setWeight($weight); return $this; }