AttestationConstant::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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