NoneAttestationVerifier::getSupportedFormat()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MadWizard\WebAuthn\Attestation\Verifier;
4
5
use MadWizard\WebAuthn\Attestation\AttestationType;
6
use MadWizard\WebAuthn\Attestation\AuthenticatorData;
7
use MadWizard\WebAuthn\Attestation\Registry\AttestationFormatInterface;
8
use MadWizard\WebAuthn\Attestation\Registry\BuiltInAttestationFormat;
9
use MadWizard\WebAuthn\Attestation\Statement\AttestationStatementInterface;
10
use MadWizard\WebAuthn\Attestation\Statement\NoneAttestationStatement;
11
use MadWizard\WebAuthn\Attestation\TrustPath\EmptyTrustPath;
12
use MadWizard\WebAuthn\Exception\VerificationException;
13
14
final class NoneAttestationVerifier implements AttestationVerifierInterface
15
{
16 1
    public function verify(AttestationStatementInterface $attStmt, AuthenticatorData $authenticatorData, string $clientDataHash): VerificationResult
17
    {
18 1
        if (!($attStmt instanceof NoneAttestationStatement)) {
19
            throw new VerificationException('Expecting NoneAttestationStatement.');
20
        }
21 1
        return new VerificationResult(AttestationType::NONE, new EmptyTrustPath());
22
    }
23
24 19
    public function getSupportedFormat(): AttestationFormatInterface
25
    {
26 19
        return new BuiltInAttestationFormat(
27 19
            NoneAttestationStatement::FORMAT_ID,
28 19
            NoneAttestationStatement::class,
29
            $this
30
        );
31
    }
32
}
33