Passed
Pull Request — master (#4)
by Tim
02:01
created

getAuthenticationMethod()   A

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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML11\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML11\XML\saml\Subject;
10
use SimpleSAML\XML\Exception\SchemaViolationException;
11
12
/**
13
 * Abstract class to be implemented by all the authentication queries in this namespace
14
 *
15
 * @package simplesamlphp/saml11
16
 */
17
abstract class AbstractAuthenticationQueryType extends AbstractSubjectQueryAbstractType
18
{
19
    /**
20
     * Initialize a samlp:AuthenticationQuery element.
21
     *
22
     * @param \SimpleSAML\SAML11\XML\saml\Subject $subject
23
     * @param string $authenticationMethod
24
     */
25
    public function __construct(
26
        Subject $subject,
27
        protected string $authenticationMethod,
28
    ) {
29
        Assert::validURI($authenticationMethod, SchemaViolationException::class);
30
31
        parent::__construct($subject);
32
    }
33
34
35
    /**
36
     * @return string
37
     */
38
    public function getAuthenticationMethod(): string
39
    {
40
        return $this->authenticationMethod;
41
    }
42
43
44
    /**
45
     * Convert this AuthenticationQuery to XML.
46
     *
47
     * @param \DOMElement $parent The element we are converting to XML.
48
     * @return \DOMElement The XML element after adding the data corresponding to this SubjectQuery.
49
     */
50
    public function toXML(?DOMElement $parent = null): DOMElement
51
    {
52
        $e = parent::toXML($parent);
53
        $e->setAttribute('AuthenticationMethod', $this->getAuthenticationMethod());
54
55
        return $e;
56
    }
57
}
58