/** * @param \SimpleXMLElement $xml * @return Address */ public static function createFromXML(\SimpleXMLElement $xml) { $address = new Address(); if (isset($xml->streetName) && $xml->streetName != '') { $address->setStreetName((string) $xml->streetName); } if (isset($xml->number) && $xml->number != '') { $address->setNumber((string) $xml->number); } if (isset($xml->box) && $xml->box != '') { $address->setBox((string) $xml->box); } if (isset($xml->postalCode) && $xml->postalCode != '') { $address->setPostalCode((string) $xml->postalCode); } if (isset($xml->locality) && $xml->locality != '') { $address->setLocality((string) $xml->locality); } if (isset($xml->countryCode) && $xml->countryCode != '') { $address->setCountryCode((string) $xml->countryCode); } return $address; }
/** * @param \SimpleXMLElement $xml * @param Customer $instance * * @return Customer * @throws BpostInvalidLengthException */ public static function createFromXMLHelper(\SimpleXMLElement $xml, Customer $instance) { if (isset($xml->name) && $xml->name != '') { $instance->setName((string) $xml->name); } if (isset($xml->company) && $xml->company != '') { $instance->setCompany((string) $xml->company); } if (isset($xml->address)) { $instance->setAddress(Address::createFromXML($xml->address)); } if (isset($xml->emailAddress) && $xml->emailAddress != '') { $instance->setEmailAddress((string) $xml->emailAddress); } if (isset($xml->phoneNumber) && $xml->phoneNumber != '') { $instance->setPhoneNumber((string) $xml->phoneNumber); } return $instance; }