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

PolicyQualifierInfo::fromQualifierASN1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.125

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 4
cp 0.5
rs 10
c 1
b 1
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1.125
1
<?php
2
3
namespace X509\Certificate\Extension\CertificatePolicy;
4
5
use ASN1\Element;
6
use ASN1\Type\Constructed\Sequence;
7
use ASN1\Type\Primitive\ObjectIdentifier;
8
use ASN1\Type\UnspecifiedType;
9
10
11
/**
12
 * Base class for <i>PolicyQualifierInfo</i> ASN.1 types used by
13
 * 'Certificate Policies' certificate extension.
14
 *
15
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.4
16
 */
17
abstract class PolicyQualifierInfo
18
{
19
	/**
20
	 * OID for the CPS Pointer qualifier.
21
	 *
22
	 * @var string
23
	 */
24
	const OID_CPS = "1.3.6.1.5.5.7.2.1";
25
	
26
	/**
27
	 * OID for the user notice qualifier.
28
	 *
29
	 * @var string
30
	 */
31
	const OID_UNOTICE = "1.3.6.1.5.5.7.2.2";
32
	
33
	/**
34
	 * Qualifier identifier.
35
	 *
36
	 * @var string $_oid
37
	 */
38
	protected $_oid;
39
	
40
	/**
41
	 * Generate ASN.1 for the 'qualifier' field.
42
	 *
43
	 * @return Element
44
	 */
45
	abstract protected function _qualifierASN1();
46
	
47
	/**
48
	 * Initialize from qualifier ASN.1 element.
49
	 *
50
	 * @param UnspecifiedType $el
51
	 * @return self
52
	 */
53 1
	public static function fromQualifierASN1(UnspecifiedType $el) {
54
		throw new \BadMethodCallException(
55
			__FUNCTION__ . " must be implemented in the derived class.");
56 1
	}
57
	
58
	/**
59
	 * Initialize from ASN.1.
60
	 *
61
	 * @param Sequence $seq
62
	 * @throws \UnexpectedValueException
63
	 * @return self
64
	 */
65 10
	public static function fromASN1(Sequence $seq) {
66 10
		$oid = $seq->at(0)
67 10
			->asObjectIdentifier()
68 10
			->oid();
69
		switch ($oid) {
70 10
		case self::OID_CPS:
71 8
			return CPSQualifier::fromQualifierASN1($seq->at(1));
72 8
		case self::OID_UNOTICE:
73 7
			return UserNoticeQualifier::fromQualifierASN1($seq->at(1));
74
		}
75 1
		throw new \UnexpectedValueException("Qualifier $oid not supported.");
76
	}
77
	
78
	/**
79
	 * Get qualifier identifier.
80
	 *
81
	 * @return string
82
	 */
83 12
	public function oid() {
84 12
		return $this->_oid;
85
	}
86
	
87
	/**
88
	 * Generate ASN.1 structure.
89
	 *
90
	 * @return Sequence
91
	 */
92 6
	public function toASN1() {
93 6
		return new Sequence(new ObjectIdentifier($this->_oid), 
94 6
			$this->_qualifierASN1());
95
	}
96
}
97