1 | <?php |
||
14 | class UniqueIdentifier |
||
15 | { |
||
16 | /** |
||
17 | * Identifier. |
||
18 | * |
||
19 | * @var BitString |
||
20 | */ |
||
21 | protected $_uid; |
||
22 | |||
23 | /** |
||
24 | * Constructor. |
||
25 | * |
||
26 | * @param BitString $bs |
||
27 | */ |
||
28 | 16 | public function __construct(BitString $bs) |
|
29 | { |
||
30 | 16 | $this->_uid = $bs; |
|
31 | 16 | } |
|
32 | |||
33 | /** |
||
34 | * Initialize from ASN.1. |
||
35 | * |
||
36 | * @param BitString $bs |
||
37 | * |
||
38 | * @return self |
||
39 | */ |
||
40 | 4 | public static function fromASN1(BitString $bs): UniqueIdentifier |
|
41 | { |
||
42 | 4 | return new self($bs); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * Initialize from string. |
||
47 | * |
||
48 | * @param string $str |
||
49 | * |
||
50 | * @return self |
||
51 | */ |
||
52 | 12 | public static function fromString(string $str): UniqueIdentifier |
|
53 | { |
||
54 | 12 | return new self(new BitString($str)); |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Get unique identifier as a string. |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | 6 | public function string(): string |
|
63 | { |
||
64 | 6 | return $this->_uid->string(); |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * Get unique identifier as a bit string. |
||
69 | * |
||
70 | * @return BitString |
||
71 | */ |
||
72 | 1 | public function bitString(): BitString |
|
73 | { |
||
74 | 1 | return $this->_uid; |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * Get ASN.1 element. |
||
79 | * |
||
80 | * @return BitString |
||
81 | */ |
||
82 | 12 | public function toASN1(): BitString |
|
85 | } |
||
86 | } |
||
87 |