Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/Certificate/UniqueIdentifier.php

raw symbols SCIP
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 * Implements *UniqueIdentifier* ASN.1 type.
11 *
12 * @see https://tools.ietf.org/html/rfc5280#section-4.1.2.8
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 * Initialize from ASN.1.
28 */
29 public static function fromASN1(BitString $bs): self
30 {
31 return self::create($bs);
32 }
33
34 /**
35 * Initialize from string.
36 */
37 public static function fromString(string $str): self
38 {
39 return self::create(BitString::create($str));
40 }
41
42 /**
43 * Get unique identifier as a string.
44 */
45 public function string(): string
46 {
47 return $this->uid->string();
48 }
49
50 /**
51 * Get unique identifier as a bit string.
52 */
53 public function bitString(): BitString
54 {
55 return $this->uid;
56 }
57
58 /**
59 * Get ASN.1 element.
60 */
61 public function toASN1(): BitString
62 {
63 return $this->uid;
64 }
65 }