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.

OtherName   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 16
dl 0
loc 78
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 3 1
A _choiceASN1() 0 5 1
A __construct() 0 5 1
A string() 0 3 1
A value() 0 3 1
A fromChosenASN1() 0 6 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\GeneralName;
6
7
use Sop\ASN1\Element;
8
use Sop\ASN1\Type\Constructed\Sequence;
9
use Sop\ASN1\Type\Primitive\ObjectIdentifier;
10
use Sop\ASN1\Type\Tagged\ExplicitlyTaggedType;
11
use Sop\ASN1\Type\Tagged\ImplicitlyTaggedType;
12
use Sop\ASN1\Type\TaggedType;
13
use Sop\ASN1\Type\UnspecifiedType;
14
15
/**
16
 * Implements *otherName* CHOICE type of *GeneralName*.
17
 *
18
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
19
 */
20
class OtherName extends GeneralName
21
{
22
    /**
23
     * Type OID.
24
     *
25
     * @var string
26
     */
27
    protected $_type;
28
29
    /**
30
     * Value.
31
     *
32
     * @var Element
33
     */
34
    protected $_element;
35
36
    /**
37
     * Constructor.
38
     *
39
     * @param string  $type_id OID
40
     * @param Element $el
41
     */
42 10
    public function __construct(string $type_id, Element $el)
43
    {
44 10
        $this->_tag = self::TAG_OTHER_NAME;
45 10
        $this->_type = $type_id;
46 10
        $this->_element = $el;
47 10
    }
48
49
    /**
50
     * {@inheritdoc}
51
     *
52
     * @return self
53
     */
54 9
    public static function fromChosenASN1(UnspecifiedType $el): GeneralName
55
    {
56 9
        $seq = $el->asSequence();
57 9
        $type_id = $seq->at(0)->asObjectIdentifier()->oid();
58 9
        $value = $seq->getTagged(0)->asExplicit()->asElement();
59 9
        return new self($type_id, $value);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65 1
    public function string(): string
66
    {
67 1
        return $this->_type . '/#' . bin2hex($this->_element->toDER());
68
    }
69
70
    /**
71
     * Get type OID.
72
     *
73
     * @return string
74
     */
75 1
    public function type(): string
76
    {
77 1
        return $this->_type;
78
    }
79
80
    /**
81
     * Get value element.
82
     *
83
     * @return Element
84
     */
85 1
    public function value(): Element
86
    {
87 1
        return $this->_element;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 15
    protected function _choiceASN1(): TaggedType
94
    {
95 15
        return new ImplicitlyTaggedType($this->_tag,
96 15
            new Sequence(new ObjectIdentifier($this->_type),
97 15
                new ExplicitlyTaggedType(0, $this->_element)));
98
    }
99
}
100