1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\SOAP\XML\env; |
4
|
|
|
|
5
|
|
|
use DOMElement; |
6
|
|
|
use SimpleSAML\Assert\Assert; |
7
|
|
|
use SimpleSAML\XML\Chunk; |
8
|
|
|
use SimpleSAML\XML\Constants as C; |
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
10
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
11
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class representing a env:Detail element. |
15
|
|
|
* |
16
|
|
|
* @package simplesaml/xml-soap |
17
|
|
|
*/ |
18
|
|
|
final class Detail extends AbstractSoapElement |
19
|
|
|
{ |
20
|
|
|
use ExtendableAttributesTrait; |
21
|
|
|
use ExtendableElementTrait; |
22
|
|
|
|
23
|
|
|
/** The namespace-attribute for the xs:any element */ |
24
|
|
|
public const NAMESPACE = C::XS_ANY_NS_ANY; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initialize a soap:Detail |
29
|
|
|
* |
30
|
|
|
* @param \SimpleSAML\XML\Chunk[] $children |
31
|
|
|
* @param \DOMAttr[] $namespacedAttributes |
32
|
|
|
*/ |
33
|
|
|
public function __construct(array $children = [], array $namespacedAttributes = []) |
34
|
|
|
{ |
35
|
|
|
$this->setElements($children); |
36
|
|
|
$this->setAttributesNS($namespacedAttributes); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
42
|
|
|
* |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
|
|
public function isEmptyElement(): bool |
46
|
|
|
{ |
47
|
|
|
return empty($this->elements) && empty($this->namespacedAttributes); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/* |
52
|
|
|
* Convert XML into an Detail element |
53
|
|
|
* |
54
|
|
|
* @param \DOMElement $xml The XML element we should load |
55
|
|
|
* @return static |
56
|
|
|
* |
57
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
58
|
|
|
* If the qualified name of the supplied element is wrong |
59
|
|
|
*/ |
60
|
|
|
public static function fromXML(DOMElement $xml): static |
61
|
|
|
{ |
62
|
|
|
Assert::same($xml->localName, 'Detail', InvalidDOMElementException::class); |
63
|
|
|
Assert::same($xml->namespaceURI, Detail::NS, InvalidDOMElementException::class); |
64
|
|
|
|
65
|
|
|
$children = []; |
66
|
|
|
foreach ($xml->childNodes as $child) { |
67
|
|
|
if (!($child instanceof DOMElement)) { |
68
|
|
|
continue; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$children[] = new Chunk($child); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return new static( |
75
|
|
|
$children, |
76
|
|
|
self::getAttributesNSFromXML($xml) |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Convert this Detail to XML. |
83
|
|
|
* |
84
|
|
|
* @param \DOMElement|null $parent The element we should add this Detail to. |
85
|
|
|
* @return \DOMElement This Detail-element. |
86
|
|
|
*/ |
87
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
88
|
|
|
{ |
89
|
|
|
$e = $this->instantiateParentElement($parent); |
90
|
|
|
|
91
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
92
|
|
|
$e->setAttributeNS($attr['namespaceURI'], $attr['qualifiedName'], $attr['value']); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
foreach ($this->elements as $child) { |
96
|
|
|
$e->appendChild($e->ownerDocument->importNode($child->toXML(), true)); |
|
|
|
|
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $e; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.