99use SimpleSAML \XML \Exception \InvalidDOMElementException ;
1010use SimpleSAML \XML \Exception \SchemaViolationException ;
1111use SimpleSAML \XML \ExtendableAttributesTrait ;
12- use SimpleSAML \XML \StringElementTrait ;
12+ use SimpleSAML \XML \TypedTextContentTrait ;
1313use SimpleSAML \XML \XsNamespace as NS ;
14+ use SimpleSAML \XMLSchema \Type \AnyURIValue ;
15+ use SimpleSAML \XMLSchema \Type \StringValue ;
1416
1517/**
1618 * A BinaryExchangeType element
2022abstract class AbstractBinaryExchangeType extends AbstractWstElement
2123{
2224 use ExtendableAttributesTrait;
23- use StringElementTrait;
25+ use TypedTextContentTrait;
26+
27+
28+ /** @var string */
29+ public const TEXTCONTENT_TYPE = StringValue::class;
2430
2531 /** The namespace-attribute for the xs:anyAttribute element */
2632 public const XS_ANY_ATTR_NAMESPACE = NS ::OTHER ;
2733
2834
2935 /**
30- * @param string $content
31- * @param string $valueType
32- * @param string $encodingType
36+ * @param \SimpleSAML\XMLSchema\Type\StringValue $content
37+ * @param \SimpleSAML\XMLSchema\Type\AnyURIValue $valueType
38+ * @param \SimpleSAML\XMLSchema\Type\AnyURIValue $encodingType
3339 * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
3440 */
3541 final public function __construct (
36- string $ content ,
37- protected string $ valueType ,
38- protected string $ encodingType ,
42+ StringValue $ content ,
43+ protected AnyURIValue $ valueType ,
44+ protected AnyURIValue $ encodingType ,
3945 array $ namespacedAttributes ,
4046 ) {
41- Assert::validURI ($ valueType , SchemaViolationException::class);
42- Assert::validURI ($ encodingType , SchemaViolationException::class);
43-
4447 $ this ->setContent ($ content );
4548 $ this ->setAttributesNS ($ namespacedAttributes );
4649 }
@@ -49,9 +52,9 @@ final public function __construct(
4952 /**
5053 * Get the valueType property.
5154 *
52- * @return string
55+ * @return \SimpleSAML\XMLSchema\Type\AnyURIValue
5356 */
54- public function getValueType (): string
57+ public function getValueType (): AnyURIValue
5558 {
5659 return $ this ->valueType ;
5760 }
@@ -60,9 +63,9 @@ public function getValueType(): string
6063 /**
6164 * Get the valueType property.
6265 *
63- * @return string
66+ * @return \SimpleSAML\XMLSchema\Type\AnyURIValue
6467 */
65- public function getEncodingType (): string
68+ public function getEncodingType (): AnyURIValue
6669 {
6770 return $ this ->encodingType ;
6871 }
@@ -83,9 +86,9 @@ public static function fromXML(DOMElement $xml): static
8386 Assert::same ($ xml ->namespaceURI , static ::NS , InvalidDOMElementException::class);
8487
8588 return new static (
86- $ xml ->textContent ,
87- self ::getAttribute ($ xml , 'ValueType ' ),
88- self ::getAttribute ($ xml , 'EncodingType ' ),
89+ StringValue:: fromString ( $ xml ->textContent ) ,
90+ self ::getAttribute ($ xml , 'ValueType ' , AnyURIValue::class ),
91+ self ::getAttribute ($ xml , 'EncodingType ' , AnyURIValue::class ),
8992 self ::getAttributesNSFromXML ($ xml ),
9093 );
9194 }
@@ -100,10 +103,10 @@ public static function fromXML(DOMElement $xml): static
100103 public function toXML (?DOMElement $ parent = null ): DOMElement
101104 {
102105 $ e = $ this ->instantiateParentElement ($ parent );
103- $ e ->textContent = $ this ->getContent ();
106+ $ e ->textContent = $ this ->getContent ()-> getValue () ;
104107
105- $ e ->setAttribute ('ValueType ' , $ this ->getValueType ());
106- $ e ->setAttribute ('EncodingType ' , $ this ->getEncodingType ());
108+ $ e ->setAttribute ('ValueType ' , $ this ->getValueType ()-> getValue () );
109+ $ e ->setAttribute ('EncodingType ' , $ this ->getEncodingType ()-> getValue () );
107110
108111 foreach ($ this ->getAttributesNS () as $ attr ) {
109112 $ attr ->toXML ($ e );
0 commit comments