| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Webauthn\MetadataService\Statement; |
| 6 |
|
| 7 |
use Webauthn\Exception\MetadataStatementLoadingException; |
| 8 |
|
| 9 |
readonly class Version |
| 10 |
{ |
| 11 |
public function __construct( |
| 12 |
public ?int $major, |
| 13 |
public ?int $minor |
| 14 |
) { |
| 15 |
if ($major === null && $minor === null) { |
| 16 |
throw MetadataStatementLoadingException::create('Invalid data. Must contain at least one item'); |
| 17 |
} |
| 18 |
$major >= 0 || throw MetadataStatementLoadingException::create('Invalid argument "major"'); |
| 19 |
$minor >= 0 || throw MetadataStatementLoadingException::create('Invalid argument "minor"'); |
| 20 |
} |
| 21 |
|
| 22 |
public static function create(?int $major, ?int $minor): self |
| 23 |
{ |
| 24 |
return new self($major, $minor); |
| 25 |
} |
| 26 |
} |