| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\Certificate; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Type\Primitive\BitString; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
final class UniqueIdentifier |
| 15 |
{ |
| 16 |
private function __construct( |
| 17 |
private readonly BitString $uid |
| 18 |
) { |
| 19 |
} |
| 20 |
|
| 21 |
public static function create(BitString $uid): self |
| 22 |
{ |
| 23 |
return new self($uid); |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public static function fromASN1(BitString $bs): self |
| 30 |
{ |
| 31 |
return self::create($bs); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public static function fromString(string $str): self |
| 38 |
{ |
| 39 |
return self::create(BitString::create($str)); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public function string(): string |
| 46 |
{ |
| 47 |
return $this->uid->string(); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public function bitString(): BitString |
| 54 |
{ |
| 55 |
return $this->uid; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
public function toASN1(): BitString |
| 62 |
{ |
| 63 |
return $this->uid; |
| 64 |
} |
| 65 |
} |