GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch php72 (a7f01e)
by Joni
04:53
created

DirectoryName   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 9
dl 0
loc 68
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A string() 0 3 1
A dn() 0 3 1
A fromDNString() 0 3 1
A fromChosenASN1() 0 3 1
A _choiceASN1() 0 5 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\GeneralName;
6
7
use Sop\ASN1\Type\Tagged\ExplicitlyTaggedType;
8
use Sop\ASN1\Type\TaggedType;
9
use Sop\ASN1\Type\UnspecifiedType;
10
use Sop\X501\ASN1\Name;
11
12
/**
13
 * Implements <i>directoryName</i> CHOICE type of <i>GeneralName</i>.
14
 *
15
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
16
 */
17
class DirectoryName extends GeneralName
18
{
19
    /**
20
     * Directory name.
21
     *
22
     * @var Name
23
     */
24
    protected $_dn;
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param Name $dn
30
     */
31 66
    public function __construct(Name $dn)
32
    {
33 66
        $this->_tag = self::TAG_DIRECTORY_NAME;
34 66
        $this->_dn = $dn;
35 66
    }
36
37
    /**
38
     * {@inheritdoc}
39
     *
40
     * @return self
41
     */
42 37
    public static function fromChosenASN1(UnspecifiedType $el): GeneralName
43
    {
44 37
        return new self(Name::fromASN1($el->asSequence()));
45
    }
46
47
    /**
48
     * Initialize from distinguished name string.
49
     *
50
     * @param string $str
51
     *
52
     * @return self
53
     */
54 20
    public static function fromDNString(string $str): self
55
    {
56 20
        return new self(Name::fromString($str));
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 3
    public function string(): string
63
    {
64 3
        return $this->_dn->toString();
65
    }
66
67
    /**
68
     * Get directory name.
69
     *
70
     * @return Name
71
     */
72 42
    public function dn(): Name
73
    {
74 42
        return $this->_dn;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 58
    protected function _choiceASN1(): TaggedType
81
    {
82
        // Name type is itself a CHOICE, so explicit tagging must be
83
        // employed to avoid ambiguities
84 58
        return new ExplicitlyTaggedType($this->_tag, $this->_dn->toASN1());
85
    }
86
}
87