Passed
Push — master ( 458ff0...f0588e )
by Tim
09:01 queued 05:54
created

AuthenticatingAuthority   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 33
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateContent() 0 3 1
A fromXML() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\XMLStringElementTrait;
11
12
/**
13
 * Class representing a saml:AuthenticatingAuthority element.
14
 *
15
 * @package simplesaml/saml2
16
 */
17
final class AuthenticatingAuthority extends AbstractSamlElement
18
{
19
    use XMLStringElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\XMLStringElementTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority: $localName, $namespaceURI
Loading history...
20
21
22
    /**
23
     * Validate the content of the element.
24
     *
25
     * @param string $content  The value to go in the XML textContent
26
     * @throws \Exception on failure
27
     * @return void
28
     */
29
    protected function validateContent(string $content): void
30
    {
31
        Assert::notWhitespaceOnly($content);
32
    }
33
34
35
    /**
36
     * Convert XML into an AuthenticatingAuthority
37
     *
38
     * @param \DOMElement $xml The XML element we should load
39
     * @return self
40
     *
41
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
42
     *   If the qualified name of the supplied element is wrong
43
     */
44
    public static function fromXML(DOMElement $xml): object
45
    {
46
        Assert::same($xml->localName, 'AuthenticatingAuthority', InvalidDOMElementException::class);
47
        Assert::same($xml->namespaceURI, AuthenticatingAuthority::NS, InvalidDOMElementException::class);
48
49
        return new self($xml->textContent);
50
    }
51
}
52
53