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

PublicKeyCredentialEntity   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A __construct() 0 4 1
A getIcon() 0 3 1
A jsonSerialize() 0 10 2
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 PublicKeyCredentialEntity implements \JsonSerializable
17
{
18
    /**
19
     * @var string
20
     */
21
    private $name;
22
23
    /**
24
     * @var null|string
25
     */
26
    private $icon;
27
28
    /**
29
     * PublicKeyCredentialEntity constructor.
30
     *
31
     * @param string      $name
32
     * @param null|string $icon
33
     */
34
    public function __construct(string $name, ?string $icon)
35
    {
36
        $this->name = $name;
37
        $this->icon = $icon;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getName(): string
44
    {
45
        return $this->name;
46
    }
47
48
    /**
49
     * @return null|string
50
     */
51
    public function getIcon(): ?string
52
    {
53
        return $this->icon;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function jsonSerialize()
60
    {
61
        $json = [
62
            'name' => $this->name,
63
        ];
64
        if ($this->icon) {
65
            $json['icon'] = $this->icon;
66
        }
67
68
        return $json;
69
    }
70
}
71