UniformResourceIdentifier::uri()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace X509\GeneralName;
6
7
use ASN1\Type\UnspecifiedType;
8
use ASN1\Type\Primitive\IA5String;
9
use ASN1\Type\Tagged\ImplicitlyTaggedType;
10
use ASN1\Type\TaggedType;
11
12
/**
13
 * Implements <i>uniformResourceIdentifier</i> CHOICE type of
14
 * <i>GeneralName</i>.
15
 *
16
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.6
17
 */
18
class UniformResourceIdentifier extends GeneralName
19
{
20
    /**
21
     * URI.
22
     *
23
     * @var string $_uri
24
     */
25
    protected $_uri;
26
    
27
    /**
28
     * Constructor.
29
     *
30
     * @param string $uri
31
     */
32 62
    public function __construct(string $uri)
33
    {
34 62
        $this->_tag = self::TAG_URI;
35 62
        $this->_uri = $uri;
36 62
    }
37
    
38
    /**
39
     *
40
     * @param UnspecifiedType $el
41
     * @return self
42
     */
43 34
    public static function fromChosenASN1(UnspecifiedType $el): self
44
    {
45 34
        return new self($el->asIA5String()->string());
46
    }
47
    
48
    /**
49
     *
50
     * {@inheritdoc}
51
     */
52 15
    public function string(): string
53
    {
54 15
        return $this->_uri;
55
    }
56
    
57
    /**
58
     * Get URI.
59
     *
60
     * @return string
61
     */
62 5
    public function uri(): string
63
    {
64 5
        return $this->_uri;
65
    }
66
    
67
    /**
68
     *
69
     * {@inheritdoc}
70
     */
71 53
    protected function _choiceASN1(): TaggedType
72
    {
73 53
        return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_uri));
74
    }
75
}
76