AbstractAuthenticationQueryType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

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