ProxyGrantingTicket::validateContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\CAS\XML\cas;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\StringElementTrait;
11
12
/**
13
 * Class for CAS proxyGrantingTicket
14
 *
15
 * @package simplesamlphp/cas
16
 */
17
final class ProxyGrantingTicket extends AbstractCasElement
18
{
19
    use StringElementTrait;
20
21
    /** @var string */
22
    final public const LOCALNAME = 'proxyGrantingTicket';
23
24
25
    /**
26
     * @param string $content
27
     */
28
    final public function __construct(string $content)
29
    {
30
        $this->setContent($content);
31
    }
32
33
34
    /**
35
     * Validate the content of the element.
36
     *
37
     * @param string $content  The value to go in the XML textContent
38
     * @throws \Exception on failure
39
     * @return void
40
     */
41
    protected function validateContent(string $content): void
42
    {
43
        Assert::notWhitespaceOnly($content);
44
    }
45
46
47
    /**
48
     * Convert XML into a cas:proxyGrantingTicket
49
     *
50
     * @param \DOMElement $xml The XML element we should load
51
     * @return static
52
     *
53
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
54
     *   If the qualified name of the supplied element is wrong
55
     */
56
    public static function fromXML(DOMElement $xml): static
57
    {
58
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
59
        Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class);
60
61
        return new static($xml->textContent);
62
    }
63
}
64