StatusReport::getCertificationDescriptor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace MadWizard\WebAuthn\Metadata\Statement;
4
5
use MadWizard\WebAuthn\Format\DataValidator;
6
7
class StatusReport
8
{
9
    /**
10
     * @var string
11
     *
12
     * @see AuthenticatorStatus
13
     */
14
    private $status;
15
16
    /**
17
     * @var string|null
18
     */
19
    private $effectiveDate;
20
21
    /**
22
     * @var string|null
23
     */
24
    private $certificate;
25
26
    /**
27
     * @var string|null
28
     */
29
    private $url;
30
31
    /**
32
     * @var string|null
33
     */
34
    private $certificationDescriptor;
35
36
    /**
37
     * @var string|null
38
     */
39
    private $certificateNumber;
40
41
    /**
42
     * @var string|null
43
     */
44
    private $certificationPolicyVersion;
45
46
    /**
47
     * @var string|null
48
     */
49
    private $certificationRequirementsVersion;
50
51
    private function __construct(array $values)
52
    {
53
        $this->status = $values['status'];
54
        $this->effectiveDate = $values['effectiveDate'] ?? null;
55
        $this->certificate = $values['certificate'] ?? null;
56
        $this->url = $values['url'] ?? null;
57
        $this->certificationDescriptor = $values['certificationDescriptor'] ?? null;
58
        $this->certificateNumber = $values['certificateNumber'] ?? null;
59
        $this->certificationPolicyVersion = $values['certificationPolicyVersion'] ?? null;
60
        $this->certificationRequirementsVersion = $values['certificationRequirementsVersion'] ?? null;
61
    }
62
63
    public static function fromArray(array $report): self
64
    {
65
        DataValidator::checkArray($report, [
66
            'status' => 'string',
67
            'effectiveDate' => '?string',
68
            'certificate' => '?string',
69
            'url' => '?string',
70
            'certificationDescriptor' => '?string',
71
            'certificateNumber' => '?string',
72
            'certificationPolicyVersion' => '?string',
73
            'certificationRequirementsVersion' => '?string',
74
        ], false);
75
76
        return new StatusReport($report);
77
    }
78
79
    public function getStatus(): string
80
    {
81
        return $this->status;
82
    }
83
84
    public function hasUndesiredStatus(): bool
85
    {
86
        return in_array($this->status, AuthenticatorStatus::LIST_UNDESIRED_STATUS, true);
87
    }
88
89
    public function getEffectiveDate(): ?string
90
    {
91
        return $this->effectiveDate;
92
    }
93
94
    public function getCertificate(): ?string
95
    {
96
        return $this->certificate;
97
    }
98
99
    public function getUrl(): ?string
100
    {
101
        return $this->url;
102
    }
103
104
    public function getCertificationDescriptor(): ?string
105
    {
106
        return $this->certificationDescriptor;
107
    }
108
109
    public function getCertificateNumber(): ?string
110
    {
111
        return $this->certificateNumber;
112
    }
113
114
    public function getCertificationPolicyVersion(): ?string
115
    {
116
        return $this->certificationPolicyVersion;
117
    }
118
119
    public function getCertificationRequirementsVersion(): ?string
120
    {
121
        return $this->certificationRequirementsVersion;
122
    }
123
}
124