85 if (!
$xml->hasAttribute(
'contactType')) {
86 throw new \Exception(
'Missing contactType on ContactPerson.');
88 $this->contactType =
$xml->getAttribute(
'contactType');
92 $this->Company = self::getStringElement(
$xml,
'Company');
93 $this->GivenName = self::getStringElement(
$xml,
'GivenName');
94 $this->SurName = self::getStringElement(
$xml,
'SurName');
95 $this->EmailAddress = self::getStringElements(
$xml,
'EmailAddress');
96 $this->TelephoneNumber = self::getStringElements(
$xml,
'TelephoneNumber');
98 foreach (
$xml->attributes as $attr) {
99 if ($attr->nodeName ==
"contactType") {
103 $this->ContactPersonAttributes[$attr->nodeName] = $attr->nodeValue;
116 assert(is_string(
$name));
122 $ret[] = $i->textContent;
138 assert(is_string(
$name));
140 $e = self::getStringElements($parent,
$name);
145 throw new \Exception(
'More than one ' .
$name .
' in ' . $parent->tagName);
159 assert(is_string($this->contactType));
161 assert(is_null($this->Company) || is_string($this->Company));
162 assert(is_null($this->GivenName) || is_string($this->GivenName));
163 assert(is_null($this->SurName) || is_string($this->SurName));
164 assert(is_array($this->EmailAddress));
165 assert(is_array($this->TelephoneNumber));
166 assert(is_array($this->ContactPersonAttributes));
168 $doc = $parent->ownerDocument;
171 $parent->appendChild($e);
173 $e->setAttribute(
'contactType', $this->contactType);
175 foreach ($this->ContactPersonAttributes as $attr => $val) {
176 $e->setAttribute($attr, $val);
181 if (isset($this->Company)) {
184 if (isset($this->GivenName)) {
187 if (isset($this->SurName)) {
190 if (!empty($this->EmailAddress)) {
193 if (!empty($this->TelephoneNumber)) {
static addStrings(\DOMElement $parent, $namespace, $name, $localized, array $values)
Append string elements.
static addString(\DOMElement $parent, $namespace, $name, $value)
Append string element.
const NS_MD
The namespace for the SAML 2 metadata.
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
static addList(\DOMElement $parent, array $extensions)
Add a list of Extensions to the given element.
static getList(\DOMElement $parent)
Get a list of Extensions in the given element.