ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Logo.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\XML\mdui;
4
11class Logo
12{
18 public $url;
19
25 public $width;
26
32 public $height;
33
39 public $lang;
40
47 public function __construct(\DOMElement $xml = null)
48 {
49 if ($xml === null) {
50 return;
51 }
52
53 if (!$xml->hasAttribute('width')) {
54 throw new \Exception('Missing width of Logo.');
55 }
56 if (!$xml->hasAttribute('height')) {
57 throw new \Exception('Missing height of Logo.');
58 }
59 if (!is_string($xml->textContent) || !strlen($xml->textContent)) {
60 throw new \Exception('Missing url value for Logo.');
61 }
62 $this->url = $xml->textContent;
63 $this->width = (int) $xml->getAttribute('width');
64 $this->height = (int) $xml->getAttribute('height');
65 $this->lang = $xml->hasAttribute('xml:lang') ? $xml->getAttribute('xml:lang') : null;
66 }
67
74 public function toXML(\DOMElement $parent)
75 {
76 assert(is_int($this->width));
77 assert(is_int($this->height));
78 assert(is_string($this->url));
79
80 $doc = $parent->ownerDocument;
81
82 $e = $doc->createElementNS(Common::NS, 'mdui:Logo');
83 $e->appendChild($doc->createTextNode($this->url));
84 $e->setAttribute('width', (int) $this->width);
85 $e->setAttribute('height', (int) $this->height);
86 if (isset($this->lang)) {
87 $e->setAttribute('xml:lang', $this->lang);
88 }
89 $parent->appendChild($e);
90
91 return $e;
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
toXML(\DOMElement $parent)
Convert this Logo to XML.
Definition: Logo.php:74
__construct(\DOMElement $xml=null)
Initialize a Logo.
Definition: Logo.php:47
$xml
Definition: metadata.php:240