File tree Expand file tree Collapse file tree 1 file changed +29
-12
lines changed
Expand file tree Collapse file tree 1 file changed +29
-12
lines changed Original file line number Diff line number Diff line change 1919 */
2020trait TypedTextContentTrait
2121{
22+ /** @var \SimpleSAML\XML\Type\ValueTypeInterface $content */
23+ protected ValueTypeInterface $ content ;
24+
25+
2226 /**
2327 * @param \SimpleSAML\XML\Type\ValueTypeInterface $content
2428 */
2529 public function __construct (
26- protected ValueTypeInterface $ content ,
30+ ValueTypeInterface $ content ,
2731 ) {
32+ $ this ->setContent ($ content );
33+ }
34+
35+
36+ /**
37+ * Set the content of the element.
38+ *
39+ * @param \SimpleSAML\XML\Type\ValueTypeInterface $content The value to go in the XML textContent
40+ */
41+ protected function setContent (ValueTypeInterface $ content ): void
42+ {
43+ Assert::isAOf ($ content , static ::getTextContentType (), InvalidValueTypeException::class);
44+ $ this ->content = $ content ;
45+ }
46+
47+
48+ /**
49+ * Get the typed content of the element
50+ *
51+ * @return \SimpleSAML\XML\Type\ValueTypeInterface
52+ */
53+ public function getContent (): ValueTypeInterface
54+ {
55+ return $ this ->content ;
2856 }
2957
3058
@@ -51,17 +79,6 @@ public static function fromXML(DOMElement $xml): static
5179 }
5280
5381
54- /**
55- * Get the typed content of the element
56- *
57- * @return \SimpleSAML\XML\Type\ValueTypeInterface
58- */
59- public function getContent (): ValueTypeInterface
60- {
61- return $ this ->content ;
62- }
63-
64-
6582 /**
6683 * Create XML from this class
6784 *
You can’t perform that action at this time.
0 commit comments