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

AuthenticatorSelectionCriteria   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getUserVerification() 0 3 1
A jsonSerialize() 0 6 1
A getAuthenticatorAttachment() 0 3 1
A isRequireResidentKey() 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 AuthenticatorSelectionCriteria implements \JsonSerializable
17
{
18
    public const AUTHENTICATOR_ATTACHMENT_PLATFORM = 'platform';
19
    public const AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM = 'cross-platform';
20
21
    public const USER_VERIFICATION_REQUIREMENT_REQUIRED = 'required';
22
    public const USER_VERIFICATION_REQUIREMENT_PREFERRED = 'preferred';
23
    public const USER_VERIFICATION_REQUIREMENT_DISCOURAGED = 'discouraged';
24
25
    /**
26
     * @var string
27
     */
28
    private $authenticatorAttachment;
29
30
    /**
31
     * @var bool
32
     */
33
    private $requireResidentKey;
34
35
    /**
36
     * @var string
37
     */
38
    private $userVerification;
39
40
    /**
41
     * AuthenticatorSelectionCriteria constructor.
42
     *
43
     * @param string $authenticatorAttachment
44
     * @param bool   $requireResidentKey
45
     * @param string $userVerification
46
     */
47
    public function __construct(string $authenticatorAttachment, bool $requireResidentKey, string $userVerification)
48
    {
49
        $this->authenticatorAttachment = $authenticatorAttachment;
50
        $this->requireResidentKey = $requireResidentKey;
51
        $this->userVerification = $userVerification;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getAuthenticatorAttachment(): string
58
    {
59
        return $this->authenticatorAttachment;
60
    }
61
62
    /**
63
     * @return bool
64
     */
65
    public function isRequireResidentKey(): bool
66
    {
67
        return $this->requireResidentKey;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getUserVerification(): string
74
    {
75
        return $this->userVerification;
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function jsonSerialize()
82
    {
83
        return [
84
            'authenticatorAttachment' => $this->authenticatorAttachment,
85
            'requireResidentKey'      => $this->requireResidentKey,
86
            'userVerification'        => $this->userVerification,
87
        ];
88
    }
89
}
90