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

AuthenticatorSelectionCriteria::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
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