@@ -24,20 +24,20 @@ final class RequestAuthenticated extends AbstractEcpElement
2424 /**
2525 * Create a ECP RequestAuthenticated element.
2626 *
27- * @param bool $mustUnderstand
27+ * @param bool|null $mustUnderstand
2828 */
2929 public function __construct (
30- protected bool $ mustUnderstand ,
30+ protected ? bool $ mustUnderstand = false ,
3131 ) {
3232 }
3333
3434
3535 /**
3636 * Collect the value of the mustUnderstand-property
3737 *
38- * @return bool
38+ * @return bool|null
3939 */
40- public function getMustUnderstand (): bool
40+ public function getMustUnderstand (): ? bool
4141 {
4242 return $ this ->mustUnderstand ;
4343 }
@@ -66,23 +66,29 @@ public static function fromXML(DOMElement $xml): static
6666 MissingAttributeException::class,
6767 );
6868
69- $ mustUnderstand = $ xml ->getAttributeNS (C::NS_SOAP_ENV_11 , 'mustUnderstand ' );
70- $ actor = $ xml ->getAttributeNS (C::NS_SOAP_ENV_11 , 'actor ' );
69+ $ mustUnderstand = null ;
70+ if ($ xml ->hasAttributeNS (C::NS_SOAP_ENV_11 , 'mustUnderstand ' )) {
71+ $ mustUnderstand = $ xml ->getAttributeNS (C::NS_SOAP_ENV_11 , 'mustUnderstand ' );
7172
72- Assert::oneOf (
73- $ mustUnderstand ,
74- ['0 ' , '1 ' ],
75- 'Invalid value of env:mustUnderstand attribute in <ecp:RequestAuthenticated>. ' ,
76- ProtocolViolationException::class,
77- );
73+ Assert::nullOrOneOf (
74+ $ mustUnderstand ,
75+ ['0 ' , '1 ' ],
76+ 'Invalid value of env:mustUnderstand attribute in <ecp:RequestAuthenticated>. ' ,
77+ ProtocolViolationException::class,
78+ );
79+
80+ $ mustUnderstand = boolval ($ mustUnderstand );
81+ }
82+
83+ $ actor = $ xml ->getAttributeNS (C::NS_SOAP_ENV_11 , 'actor ' );
7884 Assert::same (
7985 $ actor ,
8086 'http://schemas.xmlsoap.org/soap/actor/next ' ,
8187 'Invalid value of env:actor attribute in <ecp:RequestAuthenticated>. ' ,
8288 ProtocolViolationException::class,
8389 );
8490
85- return new static (boolval ( $ mustUnderstand) );
91+ return new static ($ mustUnderstand );
8692 }
8793
8894
@@ -95,7 +101,11 @@ public static function fromXML(DOMElement $xml): static
95101 public function toXML (DOMElement $ parent = null ): DOMElement
96102 {
97103 $ e = $ this ->instantiateParentElement ($ parent );
98- $ e ->setAttributeNS (C::NS_SOAP_ENV_11 , 'env:mustUnderstand ' , strval (intval ($ this ->getMustUnderstand ())));
104+
105+ if ($ this ->getMustUnderstand () !== null ) {
106+ $ e ->setAttributeNS (C::NS_SOAP_ENV_11 , 'env:mustUnderstand ' , strval (intval ($ this ->getMustUnderstand ())));
107+ }
108+
99109 $ e ->setAttributeNS (C::NS_SOAP_ENV_11 , 'env:actor ' , C::SOAP_ACTOR_NEXT );
100110
101111 return $ e ;
0 commit comments