/** * Create an address from XML. SimpleXMLElement passed must have immediate children like AddressLine1, City, etc. * @internal * * @param \SimpleXMLElement $xml * * @return \SimpleUPS\Address */ public static function fromXml(\SimpleXMLElement $xml) { $address = new Address(); $address->setIsResponse(); //@todo Consider alternatives for what to do with Consignee if (isset($xml->AddressLine1)) { $street = $xml->AddressLine1; if (isset($xml->AddressLine2)) { $street .= ' ' . $xml->AddressLine2; } if (isset($xml->AddressLine3)) { $street .= ' ' . $xml->AddressLine3; } $address->setStreet(trim((string) $street)); } if (isset($xml->City)) { $address->setCity($xml->City); } if (isset($xml->StateProvinceCode)) { $address->setStateProvinceCode((string) $xml->StateProvinceCode); } if (isset($xml->PostalCode)) { $address->setPostalCode((string) $xml->PostalCode); } if (isset($xml->CountryCode)) { $address->setCountryCode((string) $xml->CountryCode); } return $address; }