SubjectConfirmationMethod::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator;
6
7
use SimpleSAML\SAML2\Assertion\Validation\Result;
8
use SimpleSAML\SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
9
use SimpleSAML\SAML2\Constants as C;
10
use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
11
12
use function sprintf;
13
14
final class SubjectConfirmationMethod implements SubjectConfirmationConstraintValidator
15
{
16
    /**
17
     * @param \SimpleSAML\SAML2\XML\saml\SubjectConfirmation $subjectConfirmation
18
     * @param \SimpleSAML\SAML2\Assertion\Validation\Result $result
19
     */
20
    public function validate(
21
        SubjectConfirmation $subjectConfirmation,
22
        Result $result,
23
    ): void {
24
        if ($subjectConfirmation->getMethod()->getValue() !== C::CM_BEARER) {
25
            $result->addError(sprintf(
26
                'Invalid Method on SubjectConfirmation, currently only Bearer (%s) is supported',
27
                C::CM_BEARER,
28
            ));
29
        }
30
    }
31
}
32