Passed
Push — master ( 68b106...6cdc56 )
by Thomas
01:58
created

RegistrationResult::getAttestationObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MadWizard\WebAuthn\Server\Registration;
4
5
use MadWizard\WebAuthn\Attestation\AttestationObject;
6
use MadWizard\WebAuthn\Attestation\AuthenticatorData;
7
use MadWizard\WebAuthn\Attestation\TrustAnchor\MetadataInterface;
8
use MadWizard\WebAuthn\Attestation\Verifier\VerificationResult;
9
use MadWizard\WebAuthn\Credential\CredentialId;
10
use MadWizard\WebAuthn\Crypto\CoseKeyInterface;
11
12
final class RegistrationResult implements RegistrationResultInterface // TODO: use interface everywhere
13
{ // TODO: add credentialRegistration?
14
    /**
15
     * @var CredentialId
16
     */
17
    private $credentialId;
18
19
    /**
20
     * @var AuthenticatorData
21
     */
22
    private $authenticatorData;
23
24
    /**
25
     * @var VerificationResult
26
     */
27
    private $verificationResult;
28
29
    /**
30
     * @var MetadataInterface|null
31
     */
32
    private $metadata;
33
34
    /**
35
     * @var AttestationObject
36
     */
37
    private $attestationObject;
38
39 1
    public function __construct(CredentialId $credentialId, AuthenticatorData $authenticatorData, AttestationObject $attestationObject, VerificationResult $verificationResult, ?MetadataInterface $metadata = null)
40
    {
41 1
        $this->credentialId = $credentialId;
42 1
        $this->authenticatorData = $authenticatorData;
43 1
        $this->verificationResult = $verificationResult;
44 1
        $this->metadata = $metadata;
45 1
        $this->attestationObject = $attestationObject;
46 1
    }
47
48 1
    public function getCredentialId(): CredentialId
49
    {
50 1
        return $this->credentialId;
51
    }
52
53 1
    public function getPublicKey(): CoseKeyInterface
54
    {
55 1
        return $this->authenticatorData->getKey();
56
    }
57
58 1
    public function getVerificationResult(): VerificationResult
59
    {
60 1
        return $this->verificationResult;
61
    }
62
63 1
    public function getSignatureCounter(): int
64
    {
65 1
        return $this->authenticatorData->getSignCount();
66
    }
67
68
    public function getAttestationObject(): AttestationObject
69
    {
70
        return $this->attestationObject;
71
    }
72
73
    public function getAuthenticatorData(): AuthenticatorData
74
    {
75
        return $this->authenticatorData;
76
    }
77
78
    public function getMetadata(): ?MetadataInterface
79
    {
80
        return $this->metadata;
81
    }
82
83 1
    public function withMetadata(?MetadataInterface $metadata): RegistrationResult
84
    {
85 1
        return new RegistrationResult($this->credentialId, $this->authenticatorData, $this->attestationObject, $this->verificationResult, $metadata);
86
    }
87
}
88