Failed Conditions
Push — master ( 104856...f1eb38 )
by Florent
02:37
created

PublicKeyCredentialDescriptor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTransports() 0 3 1
A getType() 0 3 1
A jsonSerialize() 0 6 1
A __construct() 0 5 1
A getId() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 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 PublicKeyCredentialDescriptor implements \JsonSerializable
17
{
18
    public const PUBLIC_KEY_CREDENTIAL_TYPE_PUBLIC_KEY = 'public-key';
19
20
    public const AUTHENTICATOR_TRANSPORT_USB = 'usb';
21
    public const AUTHENTICATOR_TRANSPORT_NFC = 'nfc';
22
    public const AUTHENTICATOR_TRANSPORT_BLE = 'ble';
23
24
    /**
25
     * @var string
26
     */
27
    private $type;
28
29
    /**
30
     * @var string
31
     */
32
    private $id;
33
34
    /**
35
     * @var string[]
36
     */
37
    private $transports;
38
39
    /**
40
     * PublicKeyCredentialDescriptor constructor.
41
     *
42
     * @param string   $type
43
     * @param string   $id
44
     * @param string[] $transports
45
     */
46
    public function __construct(string $type, string $id, array $transports)
47
    {
48
        $this->type = $type;
49
        $this->id = $id;
50
        $this->transports = $transports;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getType(): string
57
    {
58
        return $this->type;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getId(): string
65
    {
66
        return $this->id;
67
    }
68
69
    /**
70
     * @return string[]
71
     */
72
    public function getTransports(): array
73
    {
74
        return $this->transports;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function jsonSerialize()
81
    {
82
        return [
83
            'type'       => $this->type,
84
            'id'         => $this->id,
85
            'transports' => $this->transports,
86
        ];
87
    }
88
}
89