AuthenticatorSelectionCriteria   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 73
ccs 26
cts 28
cp 0.9286
rs 10
wmc 14

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getUserVerification() 0 3 1
A getAuthenticatorAttachment() 0 3 1
A getAsArray() 0 14 4
A setAuthenticatorAttachment() 0 6 3
A getRequireResidentKey() 0 3 1
A setRequireResidentKey() 0 3 1
A setUserVerification() 0 6 3
1
<?php
2
3
namespace MadWizard\WebAuthn\Dom;
4
5
use InvalidArgumentException;
6
7
final class AuthenticatorSelectionCriteria extends AbstractDictionary
8
{
9
    /**
10
     * Platform attachment value from the AuthenticatorAttachment enumeration.
11
     *
12
     * @see AuthenticatorAttachment
13
     *
14
     * @var string|null
15
     */
16
    private $authenticatorAttachment;
17
18
    /**
19
     * @var bool|null
20
     */
21
    private $requireResidentKey;
22
23
    /**
24
     * @see UserVerificationRequirement
25
     *
26
     * @var string|null
27
     */
28
    private $userVerification;
29
30 2
    public function getAuthenticatorAttachment(): ?string
31
    {
32 2
        return $this->authenticatorAttachment;
33
    }
34
35 2
    public function setAuthenticatorAttachment(?string $value): void
36
    {
37 2
        if ($value !== null && !AuthenticatorAttachment::isValidValue($value)) {
38 1
            throw new InvalidArgumentException(sprintf('Value %s is not a valid AuthenticatorAttachment', $value));
39
        }
40 1
        $this->authenticatorAttachment = $value;
41 1
    }
42
43 2
    public function getRequireResidentKey(): ?bool
44
    {
45 2
        return $this->requireResidentKey;
46
    }
47
48 1
    public function setRequireResidentKey(?bool $value): void
49
    {
50 1
        $this->requireResidentKey = $value;
51 1
    }
52
53 2
    public function getUserVerification(): ?string
54
    {
55 2
        return $this->userVerification;
56
    }
57
58 3
    public function setUserVerification(?string $value): void
59
    {
60 3
        if ($value !== null && !UserVerificationRequirement::isValidValue($value)) {
61 1
            throw new InvalidArgumentException(sprintf('Value %s is not a valid UserVerificationRequirement', $value));
62
        }
63 2
        $this->userVerification = $value;
64 2
    }
65
66 1
    public function getAsArray(): array
67
    {
68 1
        $map = [];
69 1
        if ($this->authenticatorAttachment !== null) {
70
            $map['authenticatorAttachment'] = $this->authenticatorAttachment;
71
        }
72
73 1
        if ($this->requireResidentKey !== null) {
74
            $map['requireResidentKey'] = $this->requireResidentKey;
75
        }
76 1
        if ($this->userVerification !== null) {
77 1
            $map['userVerification'] = $this->userVerification;
78
        }
79 1
        return $map;
80
    }
81
}
82