File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,15 @@ public function toAttribute(): XMLAttribute
4444 }
4545
4646
47+ /**
48+ * @return \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\IncludeToken $value
49+ */
50+ public function toEnum (): IncludeToken
51+ {
52+ return IncludeToken::from ($ this ->getValue ());
53+ }
54+
55+
4756 /**
4857 * @param \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\IncludeToken $value
4958 * @return static
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace SimpleSAML \WebServices \SecurityPolicy \XML \sp_200507 \Type ;
6+
7+ use DOMNodeList ;
8+ use DOMXpath ;
9+ use SimpleSAML \Assert \Assert ;
10+ use SimpleSAML \XML \DOMDocumentFactory ;
11+ use SimpleSAML \XMLSchema \Type \StringValue ;
12+
13+ /**
14+ * @package simplesaml/xml-ws-security-policy
15+ */
16+ class XPathValue extends StringValue
17+ {
18+ /**
19+ * Validate the content of the element.
20+ *
21+ * @throws \SimpleSAML\Assert\AssertionFailedException on failure
22+ */
23+ protected function validateValue (string $ content ): void
24+ {
25+ $ dom = new DOMXPath (DOMDocumentFactory::create ());
26+ $ result = $ dom ->evaluate ($ content );
27+ Assert::isInstanceOf ($ result , DOMNodeList::class);
28+ }
29+ }
Original file line number Diff line number Diff line change 44
55namespace SimpleSAML \WebServices \SecurityPolicy \XML \sp_200507 ;
66
7- use DOMNodeList ;
8- use DOMXPath ;
9- use SimpleSAML \WebServices \SecurityPolicy \Assert \Assert ;
10- use SimpleSAML \XML \DOMDocumentFactory ;
7+ use SimpleSAML \WebServices \SecurityPolicy \XML \sp_200507 \Type \XPathValue ;
118use SimpleSAML \XML \TypedTextContentTrait ;
12- use SimpleSAML \XMLSchema \Type \StringValue ;
139
1410/**
1511 * An XPath element
@@ -21,18 +17,5 @@ final class XPath extends AbstractSpElement
2117 use TypedTextContentTrait;
2218
2319
24- public const string TEXTCONTENT_TYPE = StringValue::class;
25-
26-
27- /**
28- * Validate the content of the element.
29- *
30- * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
31- */
32- protected function validateContent (string $ content ): void
33- {
34- $ dom = new DOMXPath (DOMDocumentFactory::create ());
35- $ result = $ dom ->evaluate ($ content );
36- Assert::isInstanceOf ($ result , DOMNodeList::class);
37- }
20+ public const string TEXTCONTENT_TYPE = XPathValue::class;
3821}
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ public function toAttribute(): XMLAttribute
4242 }
4343
4444
45+ /**
46+ * @return \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\IncludeToken $value
47+ */
48+ public function toEnum (): IncludeToken
49+ {
50+ return IncludeToken::from ($ this ->getValue ());
51+ }
52+
53+
4554 /**
4655 * @param \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\IncludeToken $value
4756 * @return static
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace SimpleSAML \WebServices \SecurityPolicy \XML \sp_200702 \Type ;
6+
7+ use DOMNodeList ;
8+ use DOMXpath ;
9+ use SimpleSAML \Assert \Assert ;
10+ use SimpleSAML \XML \DOMDocumentFactory ;
11+ use SimpleSAML \XMLSchema \Type \StringValue ;
12+
13+ /**
14+ * @package simplesaml/xml-ws-security-policy
15+ */
16+ class XPathValue extends StringValue
17+ {
18+ /**
19+ * Validate the content of the element.
20+ *
21+ * @throws \SimpleSAML\Assert\AssertionFailedException on failure
22+ */
23+ protected function validateValue (string $ content ): void
24+ {
25+ $ dom = new DOMXPath (DOMDocumentFactory::create ());
26+ $ result = $ dom ->evaluate ($ content );
27+ Assert::isInstanceOf ($ result , DOMNodeList::class);
28+ }
29+ }
Original file line number Diff line number Diff line change 44
55namespace SimpleSAML \WebServices \SecurityPolicy \XML \sp_200702 ;
66
7- use DOMNodeList ;
8- use DOMXPath ;
9- use SimpleSAML \WebServices \SecurityPolicy \Assert \Assert ;
10- use SimpleSAML \XML \DOMDocumentFactory ;
7+ use SimpleSAML \WebServices \SecurityPolicy \XML \sp_200702 \Type \XPathValue ;
118use SimpleSAML \XML \TypedTextContentTrait ;
12- use SimpleSAML \XMLSchema \Type \StringValue ;
139
1410/**
1511 * An XPath element
@@ -21,18 +17,5 @@ final class XPath extends AbstractSpElement
2117 use TypedTextContentTrait;
2218
2319
24- public const string TEXTCONTENT_TYPE = StringValue::class;
25-
26-
27- /**
28- * Validate the content of the element.
29- *
30- * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
31- */
32- protected function validateContent (string $ content ): void
33- {
34- $ dom = new DOMXPath (DOMDocumentFactory::create ());
35- $ result = $ dom ->evaluate ($ content );
36- Assert::isInstanceOf ($ result , DOMNodeList::class);
37- }
20+ public const string TEXTCONTENT_TYPE = XPathValue::class;
3821}
Original file line number Diff line number Diff line change @@ -53,6 +53,16 @@ public function testToAttribute(): void
5353 }
5454
5555
56+ public function testFromEnum (): void
57+ {
58+ $ x = IncludeTokenValue::fromEnum (IncludeToken::Always);
59+ $ this ->assertEquals (IncludeToken::Always, $ x ->toEnum ());
60+
61+ $ y = IncludeTokenValue::fromString (IncludeToken::Always->value );
62+ $ this ->assertEquals (IncludeToken::Always, $ y ->toEnum ());
63+ }
64+
65+
5666 /**
5767 * @return array<string, array{0: bool, 1: string}>
5868 */
Original file line number Diff line number Diff line change @@ -53,6 +53,16 @@ public function testToAttribute(): void
5353 }
5454
5555
56+ public function testFromEnum (): void
57+ {
58+ $ x = IncludeTokenValue::fromEnum (IncludeToken::Always);
59+ $ this ->assertEquals (IncludeToken::Always, $ x ->toEnum ());
60+
61+ $ y = IncludeTokenValue::fromString (IncludeToken::Always->value );
62+ $ this ->assertEquals (IncludeToken::Always, $ y ->toEnum ());
63+ }
64+
65+
5666 /**
5767 * @return array<string, array{0: bool, 1: string}>
5868 */
You can’t perform that action at this time.
0 commit comments