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 ( f4ded9...a7fcfa )
by Joni
04:09
created

UserNoticeQualifier::_fromASN1()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 11
cts 11
cp 1
rs 9.4285
nc 4
cc 3
eloc 9
nop 1
crap 3
1
<?php
2
3
namespace X509\Certificate\Extension\CertificatePolicy;
4
5
use ASN1\Element;
6
use ASN1\Type\Constructed\Sequence;
7
use ASN1\Type\UnspecifiedType;
8
9
10
/**
11
 * Implements <i>UserNotice</i> ASN.1 type used by
12
 * 'Certificate Policies' certificate extension.
13
 *
14
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.4
15
 */
16
class UserNoticeQualifier extends PolicyQualifierInfo
17
{
18
	/**
19
	 * Explicit notice text.
20
	 *
21
	 * @var DisplayText $_text
22
	 */
23
	protected $_text;
24
	
25
	/**
26
	 * Notice reference.
27
	 *
28
	 * @var NoticeReference $_ref
29
	 */
30
	protected $_ref;
31
	
32
	/**
33
	 * Constructor
34
	 *
35
	 * @param DisplayText|null $text
36
	 * @param NoticeReference|null $ref
37
	 */
38 12
	public function __construct(DisplayText $text = null, 
39
			NoticeReference $ref = null) {
40 12
		$this->_oid = self::OID_UNOTICE;
41 12
		$this->_text = $text;
42 12
		$this->_ref = $ref;
43 12
	}
44
	
45
	/**
46
	 *
47
	 * @param UnspecifiedType $el
48
	 * @return self
49
	 */
50 7
	public static function fromQualifierASN1(UnspecifiedType $el) {
51 7
		$seq = $el->asSequence();
52 7
		$ref = null;
53 7
		$text = null;
54 7
		$idx = 0;
55 7
		if ($seq->has($idx, Element::TYPE_SEQUENCE)) {
56 6
			$ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence());
57 6
		}
58 7
		if ($seq->has($idx, Element::TYPE_STRING)) {
59 7
			$text = DisplayText::fromASN1($seq->at($idx)->asString());
60 7
		}
61 7
		return new self($text, $ref);
62
	}
63
	
64
	/**
65
	 * Whether explicit text is present.
66
	 */
67 4
	public function hasExplicitText() {
68 4
		return isset($this->_text);
69
	}
70
	
71
	/**
72
	 * Get explicit text.
73
	 *
74
	 * @return DisplayText
75
	 */
76 4
	public function explicitText() {
77 4
		if (!$this->hasExplicitText()) {
78 1
			throw new \LogicException("explicitText not set.");
79
		}
80 3
		return $this->_text;
81
	}
82
	
83
	/**
84
	 * Whether notice reference is present.
85
	 *
86
	 * @return bool
87
	 */
88 4
	public function hasNoticeRef() {
89 4
		return isset($this->_ref);
90
	}
91
	
92
	/**
93
	 * Get notice reference.
94
	 *
95
	 * @throws \RuntimeException
96
	 * @return NoticeReference
97
	 */
98 4
	public function noticeRef() {
99 4
		if (!$this->hasNoticeRef()) {
100 1
			throw new \LogicException("noticeRef not set.");
101
		}
102 3
		return $this->_ref;
103
	}
104
	
105 4
	protected function _qualifierASN1() {
106 4
		$elements = array();
107 4
		if (isset($this->_ref)) {
108 3
			$elements[] = $this->_ref->toASN1();
109 3
		}
110 4
		if (isset($this->_text)) {
111 4
			$elements[] = $this->_text->toASN1();
112 4
		}
113 4
		return new Sequence(...$elements);
114
	}
115
}
116