SubjectConfirmationMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 2
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