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

Target::fromChosenASN1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 1
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace X509\Certificate\Extension\Target;
4
5
use ASN1\Element;
6
use ASN1\Type\TaggedType;
7
8
9
/**
10
 * Base class for <i>Target</i> ASN.1 CHOICE type.
11
 *
12
 * @link https://tools.ietf.org/html/rfc5755#section-4.3.2
13
 */
14
abstract class Target
15
{
16
	const TYPE_NAME = 0;
17
	const TYPE_GROUP = 1;
18
	const TYPE_CERT = 2;
19
	
20
	/**
21
	 * Type tag.
22
	 *
23
	 * @var int $_type
24
	 */
25
	protected $_type;
26
	
27
	/**
28
	 * Generate ASN.1 element.
29
	 *
30
	 * @return Element
31
	 */
32
	abstract public function toASN1();
33
	
34
	/**
35
	 * Get string value of the target.
36
	 *
37
	 * @return string
38
	 */
39
	abstract public function string();
40
	
41
	/**
42
	 * Initialize concrete object from the chocen ASN.1 element.
43
	 *
44
	 * @param TaggedType $el
45
	 * @return self
46
	 */
47 1
	public static function fromChosenASN1(TaggedType $el) {
48 1
		throw new \BadMethodCallException(
49 1
			__FUNCTION__ . " must be implemented in the derived class.");
50
	}
51
	
52
	/**
53
	 * Parse from ASN.1.
54
	 *
55
	 * @param TaggedType $el
56
	 * @throws \UnexpectedValueException
57
	 * @return self
58
	 */
59 8
	public static function fromASN1(TaggedType $el) {
60 8
		switch ($el->tag()) {
61 8
		case self::TYPE_NAME:
62 5
			return TargetName::fromChosenASN1($el->asExplicit()->asTagged());
63 5
		case self::TYPE_GROUP:
64 3
			return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged());
65 2
		case self::TYPE_CERT:
66 1
			throw new \RuntimeException("targetCert not supported.");
67 1
		}
68 1
		throw new \UnexpectedValueException(
69 1
			"Target type " . $el->tag() . " not supported.");
70
	}
71
	
72
	/**
73
	 * Get type tag.
74
	 *
75
	 * @return int
76
	 */
77 4
	public function type() {
78 4
		return $this->_type;
79
	}
80
}
81