| 1 |
<?php |
| 2 |
|
| 3 |
declare(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 |
|
| 14 |
namespace WP_DEFENDER_VENDOR\Webauthn\MetadataService; |
| 15 |
|
| 16 |
use WP_DEFENDER_VENDOR\Assert\Assertion; |
| 17 |
|
| 18 |
class BiometricAccuracyDescriptor extends AbstractDescriptor |
| 19 |
{ |
| 20 |
/** |
| 21 |
* @var float|null |
| 22 |
*/ |
| 23 |
private $FAR; |
| 24 |
|
| 25 |
/** |
| 26 |
* @var float|null |
| 27 |
*/ |
| 28 |
private $FRR; |
| 29 |
|
| 30 |
/** |
| 31 |
* @var float|null |
| 32 |
*/ |
| 33 |
private $EER; |
| 34 |
|
| 35 |
/** |
| 36 |
* @var float|null |
| 37 |
*/ |
| 38 |
private $FAAR; |
| 39 |
|
| 40 |
/** |
| 41 |
* @var int|null |
| 42 |
*/ |
| 43 |
private $maxReferenceDataSets; |
| 44 |
|
| 45 |
public function __construct(?float $FAR, ?float $FRR, ?float $EER, ?float $FAAR, ?int $maxReferenceDataSets, ?int $maxRetries = null, ?int $blockSlowdown = null) |
| 46 |
{ |
| 47 |
Assertion::greaterOrEqualThan($maxReferenceDataSets, 0, Utils::logicException('Invalid data. The value of "maxReferenceDataSets" must be a positive integer')); |
| 48 |
$this->FRR = $FRR; |
| 49 |
$this->FAR = $FAR; |
| 50 |
$this->EER = $EER; |
| 51 |
$this->FAAR = $FAAR; |
| 52 |
$this->maxReferenceDataSets = $maxReferenceDataSets; |
| 53 |
parent::__construct($maxRetries, $blockSlowdown); |
| 54 |
} |
| 55 |
|
| 56 |
public function getFAR(): ?float |
| 57 |
{ |
| 58 |
return $this->FAR; |
| 59 |
} |
| 60 |
|
| 61 |
public function getFRR(): ?float |
| 62 |
{ |
| 63 |
return $this->FRR; |
| 64 |
} |
| 65 |
|
| 66 |
public function getEER(): ?float |
| 67 |
{ |
| 68 |
return $this->EER; |
| 69 |
} |
| 70 |
|
| 71 |
public function getFAAR(): ?float |
| 72 |
{ |
| 73 |
return $this->FAAR; |
| 74 |
} |
| 75 |
|
| 76 |
public function getMaxReferenceDataSets(): ?int |
| 77 |
{ |
| 78 |
return $this->maxReferenceDataSets; |
| 79 |
} |
| 80 |
|
| 81 |
public static function createFromArray(array $data): self |
| 82 |
{ |
| 83 |
return new self( |
| 84 |
$data['FAR'] ?? null, |
| 85 |
$data['FRR'] ?? null, |
| 86 |
$data['EER'] ?? null, |
| 87 |
$data['FAAR'] ?? null, |
| 88 |
$data['maxReferenceDataSets'] ?? null, |
| 89 |
$data['maxRetries'] ?? null, |
| 90 |
$data['blockSlowdown'] ?? null |
| 91 |
); |
| 92 |
} |
| 93 |
|
| 94 |
public function jsonSerialize(): array |
| 95 |
{ |
| 96 |
$data = [ |
| 97 |
'FAR' => $this->FAR, |
| 98 |
'FRR' => $this->FRR, |
| 99 |
'EER' => $this->EER, |
| 100 |
'FAAR' => $this->FAAR, |
| 101 |
'maxReferenceDataSets' => $this->maxReferenceDataSets, |
| 102 |
'maxRetries' => $this->getMaxRetries(), |
| 103 |
'blockSlowdown' => $this->getBlockSlowdown(), |
| 104 |
]; |
| 105 |
|
| 106 |
return Utils::filterNullValues($data); |
| 107 |
} |
| 108 |
} |
| 109 |
|