Passed
Push — master ( 3569aa...ab7ae0 )
by Florent
02:27
created

PublicKeyCredential::createFromJson()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 13
nc 5
nop 1
dl 0
loc 20
rs 9.5222
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A PublicKeyCredential::getPublicKeyCredentialDescriptor() 0 3 1
A PublicKeyCredential::jsonSerialize() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace U2FAuthentication\Fido2;
15
16
class PublicKeyCredential extends Credential
17
{
18
    /**
19
     * @var string
20
     */
21
    private $rawId;
22
23
    /**
24
     * @var AuthenticatorAttestationResponse
25
     */
26
    private $response;
27
28
    /**
29
     * PublicKeyCredential constructor.
30
     */
31
    public function __construct(string $id, string $type, string $rawId, AuthenticatorAttestationResponse $response)
32
    {
33
        parent::__construct($id, $type);
34
        $this->rawId = $rawId;
35
        $this->response = $response;
36
    }
37
38
    public function getRawId(): string
39
    {
40
        return $this->rawId;
41
    }
42
43
    public function getResponse(): AuthenticatorAttestationResponse
44
    {
45
        return $this->response;
46
    }
47
48
    /**
49
     * @param string[] $transport
50
     */
51
    public function getPublicKeyCredentialDescriptor(array $transport = []): PublicKeyCredentialDescriptor
52
    {
53
        return new PublicKeyCredentialDescriptor($this->getType(), $this->getId(), $transport);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function jsonSerialize(): array
60
    {
61
        return [
62
            'id' => $this->getId(),
63
            'type' => $this->getType(),
64
            'rawId' => $this->getRawId(),
65
            'response' => $this->response,
66
        ];
67
    }
68
}
69