FullName::names()   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\Certificate\Extension\DistributionPoint;
6
7
use ASN1\Type\Constructed\Sequence;
8
use X509\GeneralName\GeneralNames;
9
use X509\GeneralName\UniformResourceIdentifier;
10
11
/**
12
 * Implements 'fullName' ASN.1 CHOICE type of <i>DistributionPointName</i>
13
 * used by 'CRL Distribution Points' certificate extension.
14
 *
15
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.13
16
 */
17
class FullName extends DistributionPointName
18
{
19
    /**
20
     * Names.
21
     *
22
     * @var GeneralNames $_names
23
     */
24
    protected $_names;
25
    
26
    /**
27
     * Constructor.
28
     *
29
     * @param GeneralNames $names
30
     */
31 15
    public function __construct(GeneralNames $names)
32
    {
33 15
        $this->_tag = self::TAG_FULL_NAME;
34 15
        $this->_names = $names;
35 15
    }
36
    
37
    /**
38
     * Initialize with a single URI.
39
     *
40
     * @param string $uri
41
     * @return self
42
     */
43 2
    public static function fromURI(string $uri): self
44
    {
45 2
        return new self(new GeneralNames(new UniformResourceIdentifier($uri)));
46
    }
47
    
48
    /**
49
     * Get names.
50
     *
51
     * @return GeneralNames
52
     */
53 3
    public function names(): GeneralNames
54
    {
55 3
        return $this->_names;
56
    }
57
    
58
    /**
59
     *
60
     * {@inheritdoc}
61
     * @return Sequence
62
     */
63 18
    protected function _valueASN1(): Sequence
64
    {
65 18
        return $this->_names->toASN1();
66
    }
67
}
68