public function toXML(\DOMElement $parent)
{
assert('is_string($this->contactType)');
assert('is_array($this->Extensions)');
assert('is_null($this->Company) || is_string($this->Company)');
assert('is_null($this->GivenName) || is_string($this->GivenName)');
assert('is_null($this->SurName) || is_string($this->SurName)');
assert('is_array($this->EmailAddress)');
assert('is_array($this->TelephoneNumber)');
assert('is_array($this->ContactPersonAttributes)');
$doc = $parent->ownerDocument;
$e = $doc->createElementNS(Constants::NS_MD, 'md:ContactPerson');
$parent->appendChild($e);
$e->setAttribute('contactType', $this->contactType);
foreach ($this->ContactPersonAttributes as $attr => $val) {
$e->setAttribute($attr, $val);
}
Extensions::addList($e, $this->Extensions);
if (isset($this->Company)) {
Utils::addString($e, Constants::NS_MD, 'md:Company', $this->Company);
}
if (isset($this->GivenName)) {
Utils::addString($e, Constants::NS_MD, 'md:GivenName', $this->GivenName);
}
if (isset($this->SurName)) {
Utils::addString($e, Constants::NS_MD, 'md:SurName', $this->SurName);
}
if (!empty($this->EmailAddress)) {
Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', false, $this->EmailAddress);
}
if (!empty($this->TelephoneNumber)) {
Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', false, $this->TelephoneNumber);
}
return $e;
}