UndesiredStatusReportVoter::voteOnTrust()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 6.9849

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
c 1
b 0
f 0
nc 4
nop 3
dl 0
loc 15
ccs 3
cts 7
cp 0.4286
crap 6.9849
rs 10
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