UndesiredStatusReportVoter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 17
ccs 3
cts 7
cp 0.4286
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A voteOnTrust() 0 15 4
1
<?php
2
3
namespace MadWizard\WebAuthn\Policy\Trust\Voter;
4
5
use MadWizard\WebAuthn\Attestation\TrustAnchor\MetadataInterface;
6
use MadWizard\WebAuthn\Attestation\TrustPath\TrustPathInterface;
7
use MadWizard\WebAuthn\Policy\Trust\TrustVote;
8
use MadWizard\WebAuthn\Server\Registration\RegistrationResultInterface;
9
10
final class UndesiredStatusReportVoter implements TrustVoterInterface
11
{
12 1
    public function voteOnTrust(
13
        RegistrationResultInterface $registrationResult,
14
        TrustPathInterface $trustPath,
15
        ?MetadataInterface $metadata
16
    ): TrustVote {
17 1
        if ($metadata === null) {
18 1
            return TrustVote::abstain();
19
        }
20
21
        foreach ($metadata->getStatusReports() as $sr) {
22
            if ($sr->hasUndesiredStatus()) {
23
                return TrustVote::untrusted();
24
            }
25
        }
26
        return TrustVote::abstain();
27
    }
28
}
29