BuiltInAttestationFormat   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
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 41
ccs 12
cts 12
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormatId() 0 3 1
A __construct() 0 5 1
A createStatement() 0 4 1
A getVerifier() 0 3 1
1
<?php
2
3
namespace MadWizard\WebAuthn\Attestation\Registry;
4
5
use MadWizard\WebAuthn\Attestation\AttestationObject;
6
use MadWizard\WebAuthn\Attestation\Statement\AttestationStatementInterface;
7
use MadWizard\WebAuthn\Attestation\Verifier\AttestationVerifierInterface;
8
9
class BuiltInAttestationFormat implements AttestationFormatInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    private $formatId;
15
16
    /**
17
     * @var string
18
     */
19
    private $statementClass;
20
21
    /**
22
     * @var AttestationVerifierInterface
23
     */
24
    private $verifier;
25
26
    /**
27
     * @phpstan-param class-string<AttestationStatementInterface> $statementClass
28
     */
29 30
    public function __construct(string $formatId, string $statementClass, AttestationVerifierInterface $verifier)
30
    {
31 30
        $this->formatId = $formatId;
32 30
        $this->statementClass = $statementClass;
33 30
        $this->verifier = $verifier;
34 30
    }
35
36 30
    public function getFormatId(): string
37
    {
38 30
        return $this->formatId;
39
    }
40
41 3
    public function createStatement(AttestationObject $attestationObject): AttestationStatementInterface
42
    {
43 3
        $class = $this->statementClass;
44 3
        return new $class($attestationObject);
45
    }
46
47 10
    public function getVerifier(): AttestationVerifierInterface
48
    {
49 10
        return $this->verifier;
50
    }
51
}
52