Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/GeneralName/RegisteredID.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace SpomkyLabs\Pki\X509\GeneralName;
6
7 use SpomkyLabs\Pki\ASN1\Type\Primitive\ObjectIdentifier;
8 use SpomkyLabs\Pki\ASN1\Type\Tagged\ImplicitlyTaggedType;
9 use SpomkyLabs\Pki\ASN1\Type\TaggedType;
10 use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;
11
12 /**
13 * Implements *registeredID* CHOICE type of *GeneralName*.
14 *
15 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
16 */
17 final class RegisteredID extends GeneralName
18 {
19 /**
20 * @param string $oid OID in dotted format
21 */
22 private function __construct(
23 private readonly string $oid
24 ) {
25 parent::__construct(self::TAG_REGISTERED_ID);
26 }
27
28 public static function create(string $oid): self
29 {
30 return new self($oid);
31 }
32
33 /**
34 * @return self
35 */
36 public static function fromChosenASN1(UnspecifiedType $el): GeneralName
37 {
38 return self::create($el->asObjectIdentifier()->oid());
39 }
40
41 public function string(): string
42 {
43 return $this->oid;
44 }
45
46 /**
47 * Get object identifier in dotted format.
48 *
49 * @return string OID
50 */
51 public function oid(): string
52 {
53 return $this->oid;
54 }
55
56 protected function choiceASN1(): TaggedType
57 {
58 return ImplicitlyTaggedType::create($this->tag, ObjectIdentifier::create($this->oid));
59 }
60 }