Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/GeneralName/X400Address.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\Constructed\Sequence;
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 *x400Address* CHOICE type of *GeneralName*.
14 *
15 * Currently acts as a parking object for decoding.
16 *
17 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
18 *
19 * @todo Implement ORAddress type
20 */
21 final class X400Address extends GeneralName
22 {
23 protected function __construct(
24 private readonly Sequence $element
25 ) {
26 parent::__construct(self::TAG_X400_ADDRESS);
27 }
28
29 public static function create(Sequence $element): self
30 {
31 return new self($element);
32 }
33
34 public static function fromChosenASN1(UnspecifiedType $el): self
35 {
36 return self::create($el->asSequence());
37 }
38
39 public function string(): string
40 {
41 return bin2hex($this->element->toDER());
42 }
43
44 protected function choiceASN1(): TaggedType
45 {
46 return ImplicitlyTaggedType::create($this->tag, $this->element);
47 }
48 }