ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Scope.php
Go to the documentation of this file.
1<?php
2
4
6
13class Scope
14{
18 const NS = 'urn:mace:shibboleth:metadata:1.0';
19
25 public $scope;
26
32 public $regexp = false;
33
39 public function __construct(\DOMElement $xml = null)
40 {
41 if ($xml === null) {
42 return;
43 }
44
45 $this->scope = $xml->textContent;
46 $this->regexp = Utils::parseBoolean($xml, 'regexp', false);
47 }
48
55 public function toXML(\DOMElement $parent)
56 {
57 assert(is_string($this->scope));
58 assert(is_bool($this->regexp) || is_null($this->regexp));
59
60 $doc = $parent->ownerDocument;
61
62 $e = $doc->createElementNS(Scope::NS, 'shibmd:Scope');
63 $parent->appendChild($e);
64
65 $e->appendChild($doc->createTextNode($this->scope));
66
67 if ($this->regexp === true) {
68 $e->setAttribute('regexp', 'true');
69 } else {
70 $e->setAttribute('regexp', 'false');
71 }
72
73 return $e;
74 }
75}
An exception for terminatinating execution or to throw for unit testing.
static parseBoolean(\DOMElement $node, $attributeName, $default=null)
Parse a boolean attribute.
Definition: Utils.php:276
__construct(\DOMElement $xml=null)
Create a Scope.
Definition: Scope.php:39
toXML(\DOMElement $parent)
Convert this Scope to XML.
Definition: Scope.php:55
const NS
The namespace used for the Scope extension element.
Definition: Scope.php:18