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
Push — master ( a7fcfa...a41913 )
by Joni
04:13
created

OtherName::fromChosenASN1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 10
ccs 9
cts 9
cp 1
rs 9.4285
c 1
b 1
f 0
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
3
namespace X509\GeneralName;
4
5
use ASN1\Element;
6
use ASN1\Type\Constructed\Sequence;
7
use ASN1\Type\Primitive\ObjectIdentifier;
8
use ASN1\Type\Tagged\ExplicitlyTaggedType;
9
use ASN1\Type\Tagged\ImplicitlyTaggedType;
10
use ASN1\Type\UnspecifiedType;
11
12
13
/**
14
 * Implements <i>otherName</i> CHOICE type of <i>GeneralName</i>.
15
 *
16
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.6
17
 */
18
class OtherName extends GeneralName
19
{
20
	/**
21
	 * Type OID.
22
	 *
23
	 * @var string $_type
24
	 */
25
	protected $_type;
26
	
27
	/**
28
	 * Value.
29
	 *
30
	 * @var Element $_element
31
	 */
32
	protected $_element;
33
	
34
	/**
35
	 * Constructor
36
	 *
37
	 * @param string $type_id OID
38
	 * @param Element $el
39
	 */
40 6
	public function __construct($type_id, Element $el) {
41 6
		$this->_tag = self::TAG_OTHER_NAME;
42 6
		$this->_type = $type_id;
43 6
		$this->_element = $el;
44 6
	}
45
	
46
	/**
47
	 *
48
	 * @param UnspecifiedType $el
49
	 * @return self
50
	 */
51 5
	public static function fromChosenASN1(UnspecifiedType $el) {
52 5
		$seq = $el->asSequence();
53 5
		$type_id = $seq->at(0)
54 5
			->asObjectIdentifier()
55 5
			->oid();
56 5
		$value = $seq->getTagged(0)
57 5
			->asExplicit()
58 5
			->asElement();
59 5
		return new self($type_id, $value);
60
	}
61
	
62 1
	public function string() {
63 1
		return $this->_type . "/#" . bin2hex($this->_element->toDER());
64
	}
65
	
66
	/**
67
	 * Get type OID.
68
	 *
69
	 * @return string
70
	 */
71 1
	public function type() {
72 1
		return $this->_type;
73
	}
74
	
75
	/**
76
	 * Get value element.
77
	 *
78
	 * @return Element
79
	 */
80 1
	public function value() {
81 1
		return $this->_element;
82
	}
83
	
84 2
	protected function _choiceASN1() {
85 2
		return new ImplicitlyTaggedType($this->_tag, 
86 2
			new Sequence(new ObjectIdentifier($this->_type), 
87 2
				new ExplicitlyTaggedType(0, $this->_element)));
88
	}
89
}
90