1<?php
2
3declare(strict_types=1);
4
5/*
6 * The MIT License (MIT)
7 *
8 * Copyright (c) 2014-2021 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
14namespace Webauthn\MetadataService;
15
16use JsonSerializable;
17
18class BiometricStatusReport implements JsonSerializable
19{
20    /**
21     * @var int
22     */
23    private $certLevel;
24
25    /**
26     * @var int
27     */
28    private $modality;
29
30    /**
31     * @var string|null
32     */
33    private $effectiveDate;
34
35    /**
36     * @var string|null
37     */
38    private $certificationDescriptor;
39
40    /**
41     * @var string|null
42     */
43    private $certificateNumber;
44
45    /**
46     * @var string|null
47     */
48    private $certificationPolicyVersion;
49
50    /**
51     * @var string|null
52     */
53    private $certificationRequirementsVersion;
54
55    public function getCertLevel(): int
56    {
57        return $this->certLevel;
58    }
59
60    public function getModality(): int
61    {
62        return $this->modality;
63    }
64
65    public function getEffectiveDate(): ?string
66    {
67        return $this->effectiveDate;
68    }
69
70    public function getCertificationDescriptor(): ?string
71    {
72        return $this->certificationDescriptor;
73    }
74
75    public function getCertificateNumber(): ?string
76    {
77        return $this->certificateNumber;
78    }
79
80    public function getCertificationPolicyVersion(): ?string
81    {
82        return $this->certificationPolicyVersion;
83    }
84
85    public function getCertificationRequirementsVersion(): ?string
86    {
87        return $this->certificationRequirementsVersion;
88    }
89
90    public static function createFromArray(array $data): self
91    {
92        $object = new self();
93        $object->certLevel = $data['certLevel'] ?? null;
94        $object->modality = $data['modality'] ?? null;
95        $object->effectiveDate = $data['effectiveDate'] ?? null;
96        $object->certificationDescriptor = $data['certificationDescriptor'] ?? null;
97        $object->certificateNumber = $data['certificateNumber'] ?? null;
98        $object->certificationPolicyVersion = $data['certificationPolicyVersion'] ?? null;
99        $object->certificationRequirementsVersion = $data['certificationRequirementsVersion'] ?? null;
100
101        return $object;
102    }
103
104    public function jsonSerialize(): array
105    {
106        $data = [
107            'certLevel' => $this->certLevel,
108            'modality' => $this->modality,
109            'effectiveDate' => $this->effectiveDate,
110            'certificationDescriptor' => $this->certificationDescriptor,
111            'certificateNumber' => $this->certificateNumber,
112            'certificationPolicyVersion' => $this->certificationPolicyVersion,
113            'certificationRequirementsVersion' => $this->certificationRequirementsVersion,
114        ];
115
116        return array_filter($data, static function ($var): bool {return null !== $var; });
117    }
118}
119