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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 67
ccs 16
cts 16
cp 1
rs 10
c 5
b 1
f 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
toASN1() 0 1 ?
string() 0 1 ?
A type() 0 3 1
A fromChosenASN1() 0 4 1
A fromASN1() 0 12 4
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