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   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 5
dl 0
loc 100
ccs 38
cts 38
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A fromQualifierASN1() 0 13 3
A hasExplicitText() 0 3 1
A explicitText() 0 6 2
A hasNoticeRef() 0 3 1
A noticeRef() 0 6 2
A _qualifierASN1() 0 10 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