Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/GeneralName/UniformResourceIdentifier.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\IA5String;
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 *uniformResourceIdentifier* CHOICE type of *GeneralName*.
14 *
15 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
16 */
17 final class UniformResourceIdentifier extends GeneralName
18 {
19 private function __construct(
20 private readonly string $uri
21 ) {
22 parent::__construct(self::TAG_URI);
23 }
24
25 public static function create(string $uri): self
26 {
27 return new self($uri);
28 }
29
30 /**
31 * @return self
32 */
33 public static function fromChosenASN1(UnspecifiedType $el): GeneralName
34 {
35 return self::create($el->asIA5String()->string());
36 }
37
38 public function string(): string
39 {
40 return $this->uri;
41 }
42
43 public function uri(): string
44 {
45 return $this->uri;
46 }
47
48 protected function choiceASN1(): TaggedType
49 {
50 return ImplicitlyTaggedType::create($this->tag, IA5String::create($this->uri));
51 }
52 }