AttestationConstant   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 40
ccs 2
cts 2
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A convertType() 0 3 1
1
<?php
2
3
namespace MadWizard\WebAuthn\Metadata\Statement;
4
5
use MadWizard\WebAuthn\Attestation\AttestationType;
6
7
final class AttestationConstant
8
{
9
    /**
10
     * Indicates full basic attestation as defined in [UAFProtocol].
11
     */
12
    public const TAG_ATTESTATION_BASIC_FULL = 0x3E07;
13
14
    /**
15
     * Indicates surrogate basic attestation as defined in [UAFProtocol].
16
     */
17
    public const TAG_ATTESTATION_BASIC_SURROGATE = 0x3E08;
18
19
    public const TAG_ATTESTATION_ATT_CA = 0x3E0A;
20
21
    /**
22
     * Indicates use of elliptic curve based direct anonymous attestation as defined in [FIDOEcdaaAlgorithm].
23
     */
24
    public const TAG_ATTESTATION_ECDAA = 0x3E09;
25
26
    private const MAP = [
27
        AttestationType::BASIC => self::TAG_ATTESTATION_BASIC_FULL,
28
        AttestationType::SELF => self::TAG_ATTESTATION_BASIC_SURROGATE,
29
        AttestationType::ATT_CA => self::TAG_ATTESTATION_ATT_CA,
30
        AttestationType::ECDAA => self::TAG_ATTESTATION_ECDAA,
31
    ];
32
33
    /**
34
     * @codeCoverageIgnore
35
     */
36
    private function __construct()
37
    {
38
    }
39
40
    /**
41
     * Converts AttestationType style constant to numerical constant.
42
     * Returns null if there is no equivalent.
43
     */
44 3
    public static function convertType(string $type): ?int
45
    {
46 3
        return self::MAP[$type] ?? null;
47
    }
48
}
49