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.
Passed
Push — php72 ( f5fc00...61c5d1 )
by Joni
02:05
created
lib/ASN1/Type/Primitive/Enumerated.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
  */
8 8
 class Enumerated extends Integer
9 9
 {
10
-    /**
11
-     * Constructor.
12
-     *
13
-     * @param int|string $number
14
-     */
15
-    public function __construct($number)
16
-    {
17
-        parent::__construct($number);
18
-        $this->_typeTag = self::TYPE_ENUMERATED;
19
-    }
10
+	/**
11
+	 * Constructor.
12
+	 *
13
+	 * @param int|string $number
14
+	 */
15
+	public function __construct($number)
16
+	{
17
+		parent::__construct($number);
18
+		$this->_typeTag = self::TYPE_ENUMERATED;
19
+	}
20 20
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Feature/Encodable.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
9 9
  */
10 10
 interface Encodable
11 11
 {
12
-    /**
13
-     * Encode object to DER.
14
-     *
15
-     * @return string
16
-     */
17
-    public function toDER(): string;
12
+	/**
13
+	 * Encode object to DER.
14
+	 *
15
+	 * @return string
16
+	 */
17
+	public function toDER(): string;
18 18
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Feature;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/OctetString.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
  */
13 13
 class OctetString extends PrimitiveString
14 14
 {
15
-    use UniversalClass;
15
+	use UniversalClass;
16 16
     
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $string
21
-     */
22
-    public function __construct(string $string)
23
-    {
24
-        $this->_typeTag = self::TYPE_OCTET_STRING;
25
-        parent::__construct($string);
26
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $string
21
+	 */
22
+	public function __construct(string $string)
23
+	{
24
+		$this->_typeTag = self::TYPE_OCTET_STRING;
25
+		parent::__construct($string);
26
+	}
27 27
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/CharacterString.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@
 block discarded – undo
9 9
 
10 10
 class CharacterString extends PrimitiveString
11 11
 {
12
-    use UniversalClass;
12
+	use UniversalClass;
13 13
     
14
-    /**
15
-     * Constructor.
16
-     *
17
-     * @param string $string
18
-     */
19
-    public function __construct(string $string)
20
-    {
21
-        $this->_typeTag = self::TYPE_CHARACTER_STRING;
22
-        parent::__construct($string);
23
-    }
14
+	/**
15
+	 * Constructor.
16
+	 *
17
+	 * @param string $string
18
+	 */
19
+	public function __construct(string $string)
20
+	{
21
+		$this->_typeTag = self::TYPE_CHARACTER_STRING;
22
+		parent::__construct($string);
23
+	}
24 24
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/ObjectDescriptor.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -12,26 +12,26 @@
 block discarded – undo
12 12
  */
13 13
 class ObjectDescriptor extends PrimitiveString
14 14
 {
15
-    use UniversalClass;
15
+	use UniversalClass;
16 16
     
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $descriptor
21
-     */
22
-    public function __construct(string $descriptor)
23
-    {
24
-        $this->_string = $descriptor;
25
-        $this->_typeTag = self::TYPE_OBJECT_DESCRIPTOR;
26
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $descriptor
21
+	 */
22
+	public function __construct(string $descriptor)
23
+	{
24
+		$this->_string = $descriptor;
25
+		$this->_typeTag = self::TYPE_OBJECT_DESCRIPTOR;
26
+	}
27 27
     
28
-    /**
29
-     * Get the object descriptor.
30
-     *
31
-     * @return string
32
-     */
33
-    public function descriptor(): string
34
-    {
35
-        return $this->_string;
36
-    }
28
+	/**
29
+	 * Get the object descriptor.
30
+	 *
31
+	 * @return string
32
+	 */
33
+	public function descriptor(): string
34
+	{
35
+		return $this->_string;
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/Integer.php 3 patches
Switch Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,11 +71,11 @@
 block discarded – undo
71 71
         $num = $this->_number->gmpObj();
72 72
         switch (gmp_sign($num)) {
73 73
             // positive
74
-            case 1:
75
-                return self::_encodePositiveInteger($num);
76
-            // negative
77
-            case -1:
78
-                return self::_encodeNegativeInteger($num);
74
+        case 1:
75
+            return self::_encodePositiveInteger($num);
76
+        // negative
77
+        case -1:
78
+            return self::_encodeNegativeInteger($num);
79 79
         }
80 80
         // zero
81 81
         return "\0";
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -17,161 +17,161 @@
 block discarded – undo
17 17
  */
18 18
 class Integer extends Element
19 19
 {
20
-    use UniversalClass;
21
-    use PrimitiveType;
20
+	use UniversalClass;
21
+	use PrimitiveType;
22 22
 
23
-    /**
24
-     * The number.
25
-     *
26
-     * @var BigInt
27
-     */
28
-    private $_number;
23
+	/**
24
+	 * The number.
25
+	 *
26
+	 * @var BigInt
27
+	 */
28
+	private $_number;
29 29
 
30
-    /**
31
-     * Constructor.
32
-     *
33
-     * @param int|string $number Base 10 integer
34
-     */
35
-    public function __construct($number)
36
-    {
37
-        $this->_typeTag = self::TYPE_INTEGER;
38
-        if (!self::_validateNumber($number)) {
39
-            $var = is_scalar($number) ? strval($number) : gettype($number);
40
-            throw new \InvalidArgumentException("'{$var}' is not a valid number.");
41
-        }
42
-        $this->_number = new BigInt($number);
43
-    }
30
+	/**
31
+	 * Constructor.
32
+	 *
33
+	 * @param int|string $number Base 10 integer
34
+	 */
35
+	public function __construct($number)
36
+	{
37
+		$this->_typeTag = self::TYPE_INTEGER;
38
+		if (!self::_validateNumber($number)) {
39
+			$var = is_scalar($number) ? strval($number) : gettype($number);
40
+			throw new \InvalidArgumentException("'{$var}' is not a valid number.");
41
+		}
42
+		$this->_number = new BigInt($number);
43
+	}
44 44
 
45
-    /**
46
-     * Get the number as a base 10.
47
-     *
48
-     * @return string Integer as a string
49
-     */
50
-    public function number(): string
51
-    {
52
-        return $this->_number->base10();
53
-    }
45
+	/**
46
+	 * Get the number as a base 10.
47
+	 *
48
+	 * @return string Integer as a string
49
+	 */
50
+	public function number(): string
51
+	{
52
+		return $this->_number->base10();
53
+	}
54 54
 
55
-    /**
56
-     * Get the number as an integer type.
57
-     *
58
-     * @return int
59
-     */
60
-    public function intNumber(): int
61
-    {
62
-        return $this->_number->intVal();
63
-    }
55
+	/**
56
+	 * Get the number as an integer type.
57
+	 *
58
+	 * @return int
59
+	 */
60
+	public function intNumber(): int
61
+	{
62
+		return $this->_number->intVal();
63
+	}
64 64
 
65
-    /**
66
-     * {@inheritdoc}
67
-     */
68
-    protected function _encodedContentDER(): string
69
-    {
70
-        $num = $this->_number->gmpObj();
71
-        switch (gmp_sign($num)) {
72
-            // positive
73
-            case 1:
74
-                return self::_encodePositiveInteger($num);
75
-            // negative
76
-            case -1:
77
-                return self::_encodeNegativeInteger($num);
78
-        }
79
-        // zero
80
-        return "\0";
81
-    }
65
+	/**
66
+	 * {@inheritdoc}
67
+	 */
68
+	protected function _encodedContentDER(): string
69
+	{
70
+		$num = $this->_number->gmpObj();
71
+		switch (gmp_sign($num)) {
72
+			// positive
73
+			case 1:
74
+				return self::_encodePositiveInteger($num);
75
+			// negative
76
+			case -1:
77
+				return self::_encodeNegativeInteger($num);
78
+		}
79
+		// zero
80
+		return "\0";
81
+	}
82 82
 
83
-    /**
84
-     * {@inheritdoc}
85
-     */
86
-    protected static function _decodeFromDER(Identifier $identifier,
87
-        string $data, int &$offset): ElementBase
88
-    {
89
-        $idx = $offset;
90
-        $length = Length::expectFromDER($data, $idx)->intLength();
91
-        $bytes = substr($data, $idx, $length);
92
-        $idx += $length;
93
-        $neg = ord($bytes[0]) & 0x80;
94
-        // negative, apply inversion of two's complement
95
-        if ($neg) {
96
-            $len = strlen($bytes);
97
-            for ($i = 0; $i < $len; ++$i) {
98
-                $bytes[$i] = ~$bytes[$i];
99
-            }
100
-        }
101
-        $num = gmp_init(bin2hex($bytes), 16);
102
-        // negative, apply addition of two's complement
103
-        // and produce negative result
104
-        if ($neg) {
105
-            $num = gmp_neg($num + 1);
106
-        }
107
-        $offset = $idx;
108
-        // late static binding since enumerated extends integer type
109
-        return new static(gmp_strval($num, 10));
110
-    }
83
+	/**
84
+	 * {@inheritdoc}
85
+	 */
86
+	protected static function _decodeFromDER(Identifier $identifier,
87
+		string $data, int &$offset): ElementBase
88
+	{
89
+		$idx = $offset;
90
+		$length = Length::expectFromDER($data, $idx)->intLength();
91
+		$bytes = substr($data, $idx, $length);
92
+		$idx += $length;
93
+		$neg = ord($bytes[0]) & 0x80;
94
+		// negative, apply inversion of two's complement
95
+		if ($neg) {
96
+			$len = strlen($bytes);
97
+			for ($i = 0; $i < $len; ++$i) {
98
+				$bytes[$i] = ~$bytes[$i];
99
+			}
100
+		}
101
+		$num = gmp_init(bin2hex($bytes), 16);
102
+		// negative, apply addition of two's complement
103
+		// and produce negative result
104
+		if ($neg) {
105
+			$num = gmp_neg($num + 1);
106
+		}
107
+		$offset = $idx;
108
+		// late static binding since enumerated extends integer type
109
+		return new static(gmp_strval($num, 10));
110
+	}
111 111
 
112
-    /**
113
-     * Encode positive integer to DER content.
114
-     *
115
-     * @param \GMP $num
116
-     *
117
-     * @return string
118
-     */
119
-    private static function _encodePositiveInteger(\GMP $num): string
120
-    {
121
-        $bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
122
-        // if first bit is 1, prepend full zero byte
123
-        // to represent positive two's complement
124
-        if (ord($bin[0]) & 0x80) {
125
-            $bin = chr(0x00) . $bin;
126
-        }
127
-        return $bin;
128
-    }
112
+	/**
113
+	 * Encode positive integer to DER content.
114
+	 *
115
+	 * @param \GMP $num
116
+	 *
117
+	 * @return string
118
+	 */
119
+	private static function _encodePositiveInteger(\GMP $num): string
120
+	{
121
+		$bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
122
+		// if first bit is 1, prepend full zero byte
123
+		// to represent positive two's complement
124
+		if (ord($bin[0]) & 0x80) {
125
+			$bin = chr(0x00) . $bin;
126
+		}
127
+		return $bin;
128
+	}
129 129
 
130
-    /**
131
-     * Encode negative integer to DER content.
132
-     *
133
-     * @param \GMP $num
134
-     *
135
-     * @return string
136
-     */
137
-    private static function _encodeNegativeInteger(\GMP $num): string
138
-    {
139
-        $num = gmp_abs($num);
140
-        // compute number of bytes required
141
-        $width = 1;
142
-        if ($num > 128) {
143
-            $tmp = $num;
144
-            do {
145
-                ++$width;
146
-                $tmp >>= 8;
147
-            } while ($tmp > 128);
148
-        }
149
-        // compute two's complement 2^n - x
150
-        $num = gmp_pow('2', 8 * $width) - $num;
151
-        $bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
152
-        // if first bit is 0, prepend full inverted byte
153
-        // to represent negative two's complement
154
-        if (!(ord($bin[0]) & 0x80)) {
155
-            $bin = chr(0xff) . $bin;
156
-        }
157
-        return $bin;
158
-    }
130
+	/**
131
+	 * Encode negative integer to DER content.
132
+	 *
133
+	 * @param \GMP $num
134
+	 *
135
+	 * @return string
136
+	 */
137
+	private static function _encodeNegativeInteger(\GMP $num): string
138
+	{
139
+		$num = gmp_abs($num);
140
+		// compute number of bytes required
141
+		$width = 1;
142
+		if ($num > 128) {
143
+			$tmp = $num;
144
+			do {
145
+				++$width;
146
+				$tmp >>= 8;
147
+			} while ($tmp > 128);
148
+		}
149
+		// compute two's complement 2^n - x
150
+		$num = gmp_pow('2', 8 * $width) - $num;
151
+		$bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
152
+		// if first bit is 0, prepend full inverted byte
153
+		// to represent negative two's complement
154
+		if (!(ord($bin[0]) & 0x80)) {
155
+			$bin = chr(0xff) . $bin;
156
+		}
157
+		return $bin;
158
+	}
159 159
 
160
-    /**
161
-     * Test that number is valid for this context.
162
-     *
163
-     * @param mixed $num
164
-     *
165
-     * @return bool
166
-     */
167
-    private static function _validateNumber($num): bool
168
-    {
169
-        if (is_int($num)) {
170
-            return true;
171
-        }
172
-        if (is_string($num) && preg_match('/-?\d+/', $num)) {
173
-            return true;
174
-        }
175
-        return false;
176
-    }
160
+	/**
161
+	 * Test that number is valid for this context.
162
+	 *
163
+	 * @param mixed $num
164
+	 *
165
+	 * @return bool
166
+	 */
167
+	private static function _validateNumber($num): bool
168
+	{
169
+		if (is_int($num)) {
170
+			return true;
171
+		}
172
+		if (is_string($num) && preg_match('/-?\d+/', $num)) {
173
+			return true;
174
+		}
175
+		return false;
176
+	}
177 177
 }
Please login to merge, or discard this patch.
lib/ASN1/Type/Constructed/Sequence.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@
 block discarded – undo
12 12
  */
13 13
 class Sequence extends Structure
14 14
 {
15
-    /**
16
-     * Constructor.
17
-     *
18
-     * @param Element ...$elements Any number of elements
19
-     */
20
-    public function __construct(Element ...$elements)
21
-    {
22
-        $this->_typeTag = self::TYPE_SEQUENCE;
23
-        parent::__construct(...$elements);
24
-    }
15
+	/**
16
+	 * Constructor.
17
+	 *
18
+	 * @param Element ...$elements Any number of elements
19
+	 */
20
+	public function __construct(Element ...$elements)
21
+	{
22
+		$this->_typeTag = self::TYPE_SEQUENCE;
23
+		parent::__construct(...$elements);
24
+	}
25 25
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Type\Constructed;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Element.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1;
6 6
 
Please login to merge, or discard this patch.
Indentation   +442 added lines, -442 removed lines patch added patch discarded remove patch
@@ -25,473 +25,473 @@
 block discarded – undo
25 25
  */
26 26
 abstract class Element implements ElementBase
27 27
 {
28
-    // Universal type tags
29
-    const TYPE_EOC = 0x00;
30
-    const TYPE_BOOLEAN = 0x01;
31
-    const TYPE_INTEGER = 0x02;
32
-    const TYPE_BIT_STRING = 0x03;
33
-    const TYPE_OCTET_STRING = 0x04;
34
-    const TYPE_NULL = 0x05;
35
-    const TYPE_OBJECT_IDENTIFIER = 0x06;
36
-    const TYPE_OBJECT_DESCRIPTOR = 0x07;
37
-    const TYPE_EXTERNAL = 0x08;
38
-    const TYPE_REAL = 0x09;
39
-    const TYPE_ENUMERATED = 0x0a;
40
-    const TYPE_EMBEDDED_PDV = 0x0b;
41
-    const TYPE_UTF8_STRING = 0x0c;
42
-    const TYPE_RELATIVE_OID = 0x0d;
43
-    const TYPE_SEQUENCE = 0x10;
44
-    const TYPE_SET = 0x11;
45
-    const TYPE_NUMERIC_STRING = 0x12;
46
-    const TYPE_PRINTABLE_STRING = 0x13;
47
-    const TYPE_T61_STRING = 0x14;
48
-    const TYPE_VIDEOTEX_STRING = 0x15;
49
-    const TYPE_IA5_STRING = 0x16;
50
-    const TYPE_UTC_TIME = 0x17;
51
-    const TYPE_GENERALIZED_TIME = 0x18;
52
-    const TYPE_GRAPHIC_STRING = 0x19;
53
-    const TYPE_VISIBLE_STRING = 0x1a;
54
-    const TYPE_GENERAL_STRING = 0x1b;
55
-    const TYPE_UNIVERSAL_STRING = 0x1c;
56
-    const TYPE_CHARACTER_STRING = 0x1d;
57
-    const TYPE_BMP_STRING = 0x1e;
28
+	// Universal type tags
29
+	const TYPE_EOC = 0x00;
30
+	const TYPE_BOOLEAN = 0x01;
31
+	const TYPE_INTEGER = 0x02;
32
+	const TYPE_BIT_STRING = 0x03;
33
+	const TYPE_OCTET_STRING = 0x04;
34
+	const TYPE_NULL = 0x05;
35
+	const TYPE_OBJECT_IDENTIFIER = 0x06;
36
+	const TYPE_OBJECT_DESCRIPTOR = 0x07;
37
+	const TYPE_EXTERNAL = 0x08;
38
+	const TYPE_REAL = 0x09;
39
+	const TYPE_ENUMERATED = 0x0a;
40
+	const TYPE_EMBEDDED_PDV = 0x0b;
41
+	const TYPE_UTF8_STRING = 0x0c;
42
+	const TYPE_RELATIVE_OID = 0x0d;
43
+	const TYPE_SEQUENCE = 0x10;
44
+	const TYPE_SET = 0x11;
45
+	const TYPE_NUMERIC_STRING = 0x12;
46
+	const TYPE_PRINTABLE_STRING = 0x13;
47
+	const TYPE_T61_STRING = 0x14;
48
+	const TYPE_VIDEOTEX_STRING = 0x15;
49
+	const TYPE_IA5_STRING = 0x16;
50
+	const TYPE_UTC_TIME = 0x17;
51
+	const TYPE_GENERALIZED_TIME = 0x18;
52
+	const TYPE_GRAPHIC_STRING = 0x19;
53
+	const TYPE_VISIBLE_STRING = 0x1a;
54
+	const TYPE_GENERAL_STRING = 0x1b;
55
+	const TYPE_UNIVERSAL_STRING = 0x1c;
56
+	const TYPE_CHARACTER_STRING = 0x1d;
57
+	const TYPE_BMP_STRING = 0x1e;
58 58
 
59
-    /**
60
-     * Mapping from universal type tag to implementation class name.
61
-     *
62
-     * @internal
63
-     *
64
-     * @var array
65
-     */
66
-    const MAP_TAG_TO_CLASS = [
67
-        self::TYPE_EOC => Primitive\EOC::class,
68
-        self::TYPE_BOOLEAN => Primitive\Boolean::class,
69
-        self::TYPE_INTEGER => Primitive\Integer::class,
70
-        self::TYPE_BIT_STRING => Primitive\BitString::class,
71
-        self::TYPE_OCTET_STRING => Primitive\OctetString::class,
72
-        self::TYPE_NULL => Primitive\NullType::class,
73
-        self::TYPE_OBJECT_IDENTIFIER => Primitive\ObjectIdentifier::class,
74
-        self::TYPE_OBJECT_DESCRIPTOR => Primitive\ObjectDescriptor::class,
75
-        self::TYPE_REAL => Primitive\Real::class,
76
-        self::TYPE_ENUMERATED => Primitive\Enumerated::class,
77
-        self::TYPE_UTF8_STRING => Primitive\UTF8String::class,
78
-        self::TYPE_RELATIVE_OID => Primitive\RelativeOID::class,
79
-        self::TYPE_SEQUENCE => Constructed\Sequence::class,
80
-        self::TYPE_SET => Constructed\Set::class,
81
-        self::TYPE_NUMERIC_STRING => Primitive\NumericString::class,
82
-        self::TYPE_PRINTABLE_STRING => Primitive\PrintableString::class,
83
-        self::TYPE_T61_STRING => Primitive\T61String::class,
84
-        self::TYPE_VIDEOTEX_STRING => Primitive\VideotexString::class,
85
-        self::TYPE_IA5_STRING => Primitive\IA5String::class,
86
-        self::TYPE_UTC_TIME => Primitive\UTCTime::class,
87
-        self::TYPE_GENERALIZED_TIME => Primitive\GeneralizedTime::class,
88
-        self::TYPE_GRAPHIC_STRING => Primitive\GraphicString::class,
89
-        self::TYPE_VISIBLE_STRING => Primitive\VisibleString::class,
90
-        self::TYPE_GENERAL_STRING => Primitive\GeneralString::class,
91
-        self::TYPE_UNIVERSAL_STRING => Primitive\UniversalString::class,
92
-        self::TYPE_CHARACTER_STRING => Primitive\CharacterString::class,
93
-        self::TYPE_BMP_STRING => Primitive\BMPString::class,
94
-    ];
59
+	/**
60
+	 * Mapping from universal type tag to implementation class name.
61
+	 *
62
+	 * @internal
63
+	 *
64
+	 * @var array
65
+	 */
66
+	const MAP_TAG_TO_CLASS = [
67
+		self::TYPE_EOC => Primitive\EOC::class,
68
+		self::TYPE_BOOLEAN => Primitive\Boolean::class,
69
+		self::TYPE_INTEGER => Primitive\Integer::class,
70
+		self::TYPE_BIT_STRING => Primitive\BitString::class,
71
+		self::TYPE_OCTET_STRING => Primitive\OctetString::class,
72
+		self::TYPE_NULL => Primitive\NullType::class,
73
+		self::TYPE_OBJECT_IDENTIFIER => Primitive\ObjectIdentifier::class,
74
+		self::TYPE_OBJECT_DESCRIPTOR => Primitive\ObjectDescriptor::class,
75
+		self::TYPE_REAL => Primitive\Real::class,
76
+		self::TYPE_ENUMERATED => Primitive\Enumerated::class,
77
+		self::TYPE_UTF8_STRING => Primitive\UTF8String::class,
78
+		self::TYPE_RELATIVE_OID => Primitive\RelativeOID::class,
79
+		self::TYPE_SEQUENCE => Constructed\Sequence::class,
80
+		self::TYPE_SET => Constructed\Set::class,
81
+		self::TYPE_NUMERIC_STRING => Primitive\NumericString::class,
82
+		self::TYPE_PRINTABLE_STRING => Primitive\PrintableString::class,
83
+		self::TYPE_T61_STRING => Primitive\T61String::class,
84
+		self::TYPE_VIDEOTEX_STRING => Primitive\VideotexString::class,
85
+		self::TYPE_IA5_STRING => Primitive\IA5String::class,
86
+		self::TYPE_UTC_TIME => Primitive\UTCTime::class,
87
+		self::TYPE_GENERALIZED_TIME => Primitive\GeneralizedTime::class,
88
+		self::TYPE_GRAPHIC_STRING => Primitive\GraphicString::class,
89
+		self::TYPE_VISIBLE_STRING => Primitive\VisibleString::class,
90
+		self::TYPE_GENERAL_STRING => Primitive\GeneralString::class,
91
+		self::TYPE_UNIVERSAL_STRING => Primitive\UniversalString::class,
92
+		self::TYPE_CHARACTER_STRING => Primitive\CharacterString::class,
93
+		self::TYPE_BMP_STRING => Primitive\BMPString::class,
94
+	];
95 95
 
96
-    /**
97
-     * Pseudotype for all string types.
98
-     *
99
-     * May be used as an expectation parameter.
100
-     *
101
-     * @var int
102
-     */
103
-    const TYPE_STRING = -1;
96
+	/**
97
+	 * Pseudotype for all string types.
98
+	 *
99
+	 * May be used as an expectation parameter.
100
+	 *
101
+	 * @var int
102
+	 */
103
+	const TYPE_STRING = -1;
104 104
 
105
-    /**
106
-     * Pseudotype for all time types.
107
-     *
108
-     * May be used as an expectation parameter.
109
-     *
110
-     * @var int
111
-     */
112
-    const TYPE_TIME = -2;
105
+	/**
106
+	 * Pseudotype for all time types.
107
+	 *
108
+	 * May be used as an expectation parameter.
109
+	 *
110
+	 * @var int
111
+	 */
112
+	const TYPE_TIME = -2;
113 113
 
114
-    /**
115
-     * Mapping from universal type tag to human readable name.
116
-     *
117
-     * @internal
118
-     *
119
-     * @var array
120
-     */
121
-    const MAP_TYPE_TO_NAME = [
122
-        self::TYPE_EOC => 'EOC',
123
-        self::TYPE_BOOLEAN => 'BOOLEAN',
124
-        self::TYPE_INTEGER => 'INTEGER',
125
-        self::TYPE_BIT_STRING => 'BIT STRING',
126
-        self::TYPE_OCTET_STRING => 'OCTET STRING',
127
-        self::TYPE_NULL => 'NULL',
128
-        self::TYPE_OBJECT_IDENTIFIER => 'OBJECT IDENTIFIER',
129
-        self::TYPE_OBJECT_DESCRIPTOR => 'ObjectDescriptor',
130
-        self::TYPE_EXTERNAL => 'EXTERNAL',
131
-        self::TYPE_REAL => 'REAL',
132
-        self::TYPE_ENUMERATED => 'ENUMERATED',
133
-        self::TYPE_EMBEDDED_PDV => 'EMBEDDED PDV',
134
-        self::TYPE_UTF8_STRING => 'UTF8String',
135
-        self::TYPE_RELATIVE_OID => 'RELATIVE-OID',
136
-        self::TYPE_SEQUENCE => 'SEQUENCE',
137
-        self::TYPE_SET => 'SET',
138
-        self::TYPE_NUMERIC_STRING => 'NumericString',
139
-        self::TYPE_PRINTABLE_STRING => 'PrintableString',
140
-        self::TYPE_T61_STRING => 'T61String',
141
-        self::TYPE_VIDEOTEX_STRING => 'VideotexString',
142
-        self::TYPE_IA5_STRING => 'IA5String',
143
-        self::TYPE_UTC_TIME => 'UTCTime',
144
-        self::TYPE_GENERALIZED_TIME => 'GeneralizedTime',
145
-        self::TYPE_GRAPHIC_STRING => 'GraphicString',
146
-        self::TYPE_VISIBLE_STRING => 'VisibleString',
147
-        self::TYPE_GENERAL_STRING => 'GeneralString',
148
-        self::TYPE_UNIVERSAL_STRING => 'UniversalString',
149
-        self::TYPE_CHARACTER_STRING => 'CHARACTER STRING',
150
-        self::TYPE_BMP_STRING => 'BMPString',
151
-        self::TYPE_STRING => 'Any String',
152
-        self::TYPE_TIME => 'Any Time',
153
-    ];
114
+	/**
115
+	 * Mapping from universal type tag to human readable name.
116
+	 *
117
+	 * @internal
118
+	 *
119
+	 * @var array
120
+	 */
121
+	const MAP_TYPE_TO_NAME = [
122
+		self::TYPE_EOC => 'EOC',
123
+		self::TYPE_BOOLEAN => 'BOOLEAN',
124
+		self::TYPE_INTEGER => 'INTEGER',
125
+		self::TYPE_BIT_STRING => 'BIT STRING',
126
+		self::TYPE_OCTET_STRING => 'OCTET STRING',
127
+		self::TYPE_NULL => 'NULL',
128
+		self::TYPE_OBJECT_IDENTIFIER => 'OBJECT IDENTIFIER',
129
+		self::TYPE_OBJECT_DESCRIPTOR => 'ObjectDescriptor',
130
+		self::TYPE_EXTERNAL => 'EXTERNAL',
131
+		self::TYPE_REAL => 'REAL',
132
+		self::TYPE_ENUMERATED => 'ENUMERATED',
133
+		self::TYPE_EMBEDDED_PDV => 'EMBEDDED PDV',
134
+		self::TYPE_UTF8_STRING => 'UTF8String',
135
+		self::TYPE_RELATIVE_OID => 'RELATIVE-OID',
136
+		self::TYPE_SEQUENCE => 'SEQUENCE',
137
+		self::TYPE_SET => 'SET',
138
+		self::TYPE_NUMERIC_STRING => 'NumericString',
139
+		self::TYPE_PRINTABLE_STRING => 'PrintableString',
140
+		self::TYPE_T61_STRING => 'T61String',
141
+		self::TYPE_VIDEOTEX_STRING => 'VideotexString',
142
+		self::TYPE_IA5_STRING => 'IA5String',
143
+		self::TYPE_UTC_TIME => 'UTCTime',
144
+		self::TYPE_GENERALIZED_TIME => 'GeneralizedTime',
145
+		self::TYPE_GRAPHIC_STRING => 'GraphicString',
146
+		self::TYPE_VISIBLE_STRING => 'VisibleString',
147
+		self::TYPE_GENERAL_STRING => 'GeneralString',
148
+		self::TYPE_UNIVERSAL_STRING => 'UniversalString',
149
+		self::TYPE_CHARACTER_STRING => 'CHARACTER STRING',
150
+		self::TYPE_BMP_STRING => 'BMPString',
151
+		self::TYPE_STRING => 'Any String',
152
+		self::TYPE_TIME => 'Any Time',
153
+	];
154 154
 
155
-    /**
156
-     * Element's type tag.
157
-     *
158
-     * @var int
159
-     */
160
-    protected $_typeTag;
155
+	/**
156
+	 * Element's type tag.
157
+	 *
158
+	 * @var int
159
+	 */
160
+	protected $_typeTag;
161 161
 
162
-    /**
163
-     * Whether type shall be encoded with indefinite length.
164
-     *
165
-     * @var bool
166
-     */
167
-    protected $_indefiniteLength = false;
162
+	/**
163
+	 * Whether type shall be encoded with indefinite length.
164
+	 *
165
+	 * @var bool
166
+	 */
167
+	protected $_indefiniteLength = false;
168 168
 
169
-    /**
170
-     * {@inheritdoc}
171
-     */
172
-    abstract public function typeClass(): int;
169
+	/**
170
+	 * {@inheritdoc}
171
+	 */
172
+	abstract public function typeClass(): int;
173 173
 
174
-    /**
175
-     * {@inheritdoc}
176
-     */
177
-    abstract public function isConstructed(): bool;
174
+	/**
175
+	 * {@inheritdoc}
176
+	 */
177
+	abstract public function isConstructed(): bool;
178 178
 
179
-    /**
180
-     * Decode element from DER data.
181
-     *
182
-     * @param string   $data   DER encoded data
183
-     * @param null|int $offset Reference to the variable that contains offset
184
-     *                         into the data where to start parsing.
185
-     *                         Variable is updated to the offset next to the
186
-     *                         parsed element. If null, start from offset 0.
187
-     *
188
-     * @throws DecodeException           If decoding fails
189
-     * @throws \UnexpectedValueException If called in the context of an expected
190
-     *                                   type, but decoding yields another type
191
-     *
192
-     * @return ElementBase
193
-     */
194
-    public static function fromDER(string $data, int &$offset = null): ElementBase
195
-    {
196
-        $idx = $offset ?? 0;
197
-        // decode identifier
198
-        $identifier = Identifier::fromDER($data, $idx);
199
-        // determine class that implements type specific decoding
200
-        $cls = self::_determineImplClass($identifier);
201
-        try {
202
-            // decode remaining element
203
-            $element = $cls::_decodeFromDER($identifier, $data, $idx);
204
-        } catch (\LogicException $e) {
205
-            // rethrow as a RuntimeException for unified exception handling
206
-            throw new DecodeException(
207
-                sprintf('Error while decoding %s.',
208
-                    self::tagToName($identifier->intTag())), 0, $e);
209
-        }
210
-        // if called in the context of a concrete class, check
211
-        // that decoded type matches the type of a calling class
212
-        $called_class = get_called_class();
213
-        if (self::class != $called_class) {
214
-            if (!$element instanceof $called_class) {
215
-                throw new \UnexpectedValueException(
216
-                    sprintf('%s expected, got %s.', $called_class,
217
-                        get_class($element)));
218
-            }
219
-        }
220
-        // update offset for the caller
221
-        if (isset($offset)) {
222
-            $offset = $idx;
223
-        }
224
-        return $element;
225
-    }
179
+	/**
180
+	 * Decode element from DER data.
181
+	 *
182
+	 * @param string   $data   DER encoded data
183
+	 * @param null|int $offset Reference to the variable that contains offset
184
+	 *                         into the data where to start parsing.
185
+	 *                         Variable is updated to the offset next to the
186
+	 *                         parsed element. If null, start from offset 0.
187
+	 *
188
+	 * @throws DecodeException           If decoding fails
189
+	 * @throws \UnexpectedValueException If called in the context of an expected
190
+	 *                                   type, but decoding yields another type
191
+	 *
192
+	 * @return ElementBase
193
+	 */
194
+	public static function fromDER(string $data, int &$offset = null): ElementBase
195
+	{
196
+		$idx = $offset ?? 0;
197
+		// decode identifier
198
+		$identifier = Identifier::fromDER($data, $idx);
199
+		// determine class that implements type specific decoding
200
+		$cls = self::_determineImplClass($identifier);
201
+		try {
202
+			// decode remaining element
203
+			$element = $cls::_decodeFromDER($identifier, $data, $idx);
204
+		} catch (\LogicException $e) {
205
+			// rethrow as a RuntimeException for unified exception handling
206
+			throw new DecodeException(
207
+				sprintf('Error while decoding %s.',
208
+					self::tagToName($identifier->intTag())), 0, $e);
209
+		}
210
+		// if called in the context of a concrete class, check
211
+		// that decoded type matches the type of a calling class
212
+		$called_class = get_called_class();
213
+		if (self::class != $called_class) {
214
+			if (!$element instanceof $called_class) {
215
+				throw new \UnexpectedValueException(
216
+					sprintf('%s expected, got %s.', $called_class,
217
+						get_class($element)));
218
+			}
219
+		}
220
+		// update offset for the caller
221
+		if (isset($offset)) {
222
+			$offset = $idx;
223
+		}
224
+		return $element;
225
+	}
226 226
 
227
-    /**
228
-     * {@inheritdoc}
229
-     */
230
-    public function toDER(): string
231
-    {
232
-        $identifier = new Identifier($this->typeClass(),
233
-            $this->isConstructed() ? Identifier::CONSTRUCTED : Identifier::PRIMITIVE,
234
-            $this->_typeTag);
235
-        $content = $this->_encodedContentDER();
236
-        if ($this->_indefiniteLength) {
237
-            $length = new Length(0, true);
238
-            $eoc = new Primitive\EOC();
239
-            return $identifier->toDER() . $length->toDER() . $content .
240
-                $eoc->toDER();
241
-        }
242
-        $length = new Length(strlen($content));
243
-        return $identifier->toDER() . $length->toDER() . $content;
244
-    }
227
+	/**
228
+	 * {@inheritdoc}
229
+	 */
230
+	public function toDER(): string
231
+	{
232
+		$identifier = new Identifier($this->typeClass(),
233
+			$this->isConstructed() ? Identifier::CONSTRUCTED : Identifier::PRIMITIVE,
234
+			$this->_typeTag);
235
+		$content = $this->_encodedContentDER();
236
+		if ($this->_indefiniteLength) {
237
+			$length = new Length(0, true);
238
+			$eoc = new Primitive\EOC();
239
+			return $identifier->toDER() . $length->toDER() . $content .
240
+				$eoc->toDER();
241
+		}
242
+		$length = new Length(strlen($content));
243
+		return $identifier->toDER() . $length->toDER() . $content;
244
+	}
245 245
 
246
-    /**
247
-     * {@inheritdoc}
248
-     */
249
-    public function tag(): int
250
-    {
251
-        return $this->_typeTag;
252
-    }
246
+	/**
247
+	 * {@inheritdoc}
248
+	 */
249
+	public function tag(): int
250
+	{
251
+		return $this->_typeTag;
252
+	}
253 253
 
254
-    /**
255
-     * {@inheritdoc}
256
-     */
257
-    public function isType(int $tag): bool
258
-    {
259
-        // if element is context specific
260
-        if (Identifier::CLASS_CONTEXT_SPECIFIC === $this->typeClass()) {
261
-            return false;
262
-        }
263
-        // negative tags identify an abstract pseudotype
264
-        if ($tag < 0) {
265
-            return $this->_isPseudoType($tag);
266
-        }
267
-        return $this->_isConcreteType($tag);
268
-    }
254
+	/**
255
+	 * {@inheritdoc}
256
+	 */
257
+	public function isType(int $tag): bool
258
+	{
259
+		// if element is context specific
260
+		if (Identifier::CLASS_CONTEXT_SPECIFIC === $this->typeClass()) {
261
+			return false;
262
+		}
263
+		// negative tags identify an abstract pseudotype
264
+		if ($tag < 0) {
265
+			return $this->_isPseudoType($tag);
266
+		}
267
+		return $this->_isConcreteType($tag);
268
+	}
269 269
 
270
-    /**
271
-     * {@inheritdoc}
272
-     */
273
-    public function expectType(int $tag): ElementBase
274
-    {
275
-        if (!$this->isType($tag)) {
276
-            throw new \UnexpectedValueException(
277
-                sprintf('%s expected, got %s.', self::tagToName($tag),
278
-                    $this->_typeDescriptorString()));
279
-        }
280
-        return $this;
281
-    }
270
+	/**
271
+	 * {@inheritdoc}
272
+	 */
273
+	public function expectType(int $tag): ElementBase
274
+	{
275
+		if (!$this->isType($tag)) {
276
+			throw new \UnexpectedValueException(
277
+				sprintf('%s expected, got %s.', self::tagToName($tag),
278
+					$this->_typeDescriptorString()));
279
+		}
280
+		return $this;
281
+	}
282 282
 
283
-    /**
284
-     * {@inheritdoc}
285
-     */
286
-    public function isTagged(): bool
287
-    {
288
-        return $this instanceof TaggedType;
289
-    }
283
+	/**
284
+	 * {@inheritdoc}
285
+	 */
286
+	public function isTagged(): bool
287
+	{
288
+		return $this instanceof TaggedType;
289
+	}
290 290
 
291
-    /**
292
-     * {@inheritdoc}
293
-     */
294
-    public function expectTagged(?int $tag = null): TaggedType
295
-    {
296
-        if (!$this->isTagged()) {
297
-            throw new \UnexpectedValueException(
298
-                sprintf('Context specific element expected, got %s.',
299
-                    Identifier::classToName($this->typeClass())));
300
-        }
301
-        if (isset($tag) && $this->tag() !== $tag) {
302
-            throw new \UnexpectedValueException(
303
-                sprintf('Tag %d expected, got %d.', $tag, $this->tag()));
304
-        }
305
-        return $this;
306
-    }
291
+	/**
292
+	 * {@inheritdoc}
293
+	 */
294
+	public function expectTagged(?int $tag = null): TaggedType
295
+	{
296
+		if (!$this->isTagged()) {
297
+			throw new \UnexpectedValueException(
298
+				sprintf('Context specific element expected, got %s.',
299
+					Identifier::classToName($this->typeClass())));
300
+		}
301
+		if (isset($tag) && $this->tag() !== $tag) {
302
+			throw new \UnexpectedValueException(
303
+				sprintf('Tag %d expected, got %d.', $tag, $this->tag()));
304
+		}
305
+		return $this;
306
+	}
307 307
 
308
-    /**
309
-     * Whether element has indefinite length.
310
-     *
311
-     * @return bool
312
-     */
313
-    public function hasIndefiniteLength(): bool
314
-    {
315
-        return $this->_indefiniteLength;
316
-    }
308
+	/**
309
+	 * Whether element has indefinite length.
310
+	 *
311
+	 * @return bool
312
+	 */
313
+	public function hasIndefiniteLength(): bool
314
+	{
315
+		return $this->_indefiniteLength;
316
+	}
317 317
 
318
-    /**
319
-     * Get self with indefinite length encoding set.
320
-     *
321
-     * @param bool $indefinite True for indefinite length, false for definite
322
-     *                         length
323
-     *
324
-     * @return self
325
-     */
326
-    public function withIndefiniteLength(bool $indefinite = true): self
327
-    {
328
-        $obj = clone $this;
329
-        $obj->_indefiniteLength = $indefinite;
330
-        return $obj;
331
-    }
318
+	/**
319
+	 * Get self with indefinite length encoding set.
320
+	 *
321
+	 * @param bool $indefinite True for indefinite length, false for definite
322
+	 *                         length
323
+	 *
324
+	 * @return self
325
+	 */
326
+	public function withIndefiniteLength(bool $indefinite = true): self
327
+	{
328
+		$obj = clone $this;
329
+		$obj->_indefiniteLength = $indefinite;
330
+		return $obj;
331
+	}
332 332
 
333
-    /**
334
-     * {@inheritdoc}
335
-     */
336
-    final public function asElement(): Element
337
-    {
338
-        return $this;
339
-    }
333
+	/**
334
+	 * {@inheritdoc}
335
+	 */
336
+	final public function asElement(): Element
337
+	{
338
+		return $this;
339
+	}
340 340
 
341
-    /**
342
-     * Get element decorated with UnspecifiedType object.
343
-     *
344
-     * @return UnspecifiedType
345
-     */
346
-    public function asUnspecified(): UnspecifiedType
347
-    {
348
-        return new UnspecifiedType($this);
349
-    }
341
+	/**
342
+	 * Get element decorated with UnspecifiedType object.
343
+	 *
344
+	 * @return UnspecifiedType
345
+	 */
346
+	public function asUnspecified(): UnspecifiedType
347
+	{
348
+		return new UnspecifiedType($this);
349
+	}
350 350
 
351
-    /**
352
-     * Get human readable name for an universal tag.
353
-     *
354
-     * @param int $tag
355
-     *
356
-     * @return string
357
-     */
358
-    public static function tagToName(int $tag): string
359
-    {
360
-        if (!array_key_exists($tag, self::MAP_TYPE_TO_NAME)) {
361
-            return "TAG {$tag}";
362
-        }
363
-        return self::MAP_TYPE_TO_NAME[$tag];
364
-    }
351
+	/**
352
+	 * Get human readable name for an universal tag.
353
+	 *
354
+	 * @param int $tag
355
+	 *
356
+	 * @return string
357
+	 */
358
+	public static function tagToName(int $tag): string
359
+	{
360
+		if (!array_key_exists($tag, self::MAP_TYPE_TO_NAME)) {
361
+			return "TAG {$tag}";
362
+		}
363
+		return self::MAP_TYPE_TO_NAME[$tag];
364
+	}
365 365
 
366
-    /**
367
-     * Get the content encoded in DER.
368
-     *
369
-     * Returns the DER encoded content without identifier and length header
370
-     * octets.
371
-     *
372
-     * @return string
373
-     */
374
-    abstract protected function _encodedContentDER(): string;
366
+	/**
367
+	 * Get the content encoded in DER.
368
+	 *
369
+	 * Returns the DER encoded content without identifier and length header
370
+	 * octets.
371
+	 *
372
+	 * @return string
373
+	 */
374
+	abstract protected function _encodedContentDER(): string;
375 375
 
376
-    /**
377
-     * Decode type-specific element from DER.
378
-     *
379
-     * @param Identifier $identifier Pre-parsed identifier
380
-     * @param string     $data       DER data
381
-     * @param int        $offset     Offset in data to the next byte after identifier
382
-     *
383
-     * @throws DecodeException If decoding fails
384
-     *
385
-     * @return ElementBase
386
-     */
387
-    protected static function _decodeFromDER(Identifier $identifier,
388
-        string $data, int &$offset): ElementBase
389
-    {
390
-        throw new \BadMethodCallException(
391
-            __METHOD__ . ' must be implemented in derived class.');
392
-    }
376
+	/**
377
+	 * Decode type-specific element from DER.
378
+	 *
379
+	 * @param Identifier $identifier Pre-parsed identifier
380
+	 * @param string     $data       DER data
381
+	 * @param int        $offset     Offset in data to the next byte after identifier
382
+	 *
383
+	 * @throws DecodeException If decoding fails
384
+	 *
385
+	 * @return ElementBase
386
+	 */
387
+	protected static function _decodeFromDER(Identifier $identifier,
388
+		string $data, int &$offset): ElementBase
389
+	{
390
+		throw new \BadMethodCallException(
391
+			__METHOD__ . ' must be implemented in derived class.');
392
+	}
393 393
 
394
-    /**
395
-     * Determine the class that implements the type.
396
-     *
397
-     * @param Identifier $identifier
398
-     *
399
-     * @return string Class name
400
-     */
401
-    protected static function _determineImplClass(Identifier $identifier): string
402
-    {
403
-        switch ($identifier->typeClass()) {
404
-            case Identifier::CLASS_UNIVERSAL:
405
-                $cls = self::_determineUniversalImplClass($identifier->intTag());
406
-                // constructed strings may be present in BER
407
-                if ($identifier->isConstructed() &&
408
-                    is_subclass_of($cls, PrimitiveString::class)) {
409
-                    $cls = ConstructedString::class;
410
-                }
411
-                return $cls;
412
-            case Identifier::CLASS_CONTEXT_SPECIFIC:
413
-                return ContextSpecificType::class;
414
-            case Identifier::CLASS_APPLICATION:
415
-                return ApplicationType::class;
416
-            case Identifier::CLASS_PRIVATE:
417
-                return PrivateType::class;
418
-        }
419
-        throw new \UnexpectedValueException(
420
-            sprintf('%s %d not implemented.',
421
-                Identifier::classToName($identifier->typeClass()),
422
-                $identifier->tag()));
423
-    }
394
+	/**
395
+	 * Determine the class that implements the type.
396
+	 *
397
+	 * @param Identifier $identifier
398
+	 *
399
+	 * @return string Class name
400
+	 */
401
+	protected static function _determineImplClass(Identifier $identifier): string
402
+	{
403
+		switch ($identifier->typeClass()) {
404
+			case Identifier::CLASS_UNIVERSAL:
405
+				$cls = self::_determineUniversalImplClass($identifier->intTag());
406
+				// constructed strings may be present in BER
407
+				if ($identifier->isConstructed() &&
408
+					is_subclass_of($cls, PrimitiveString::class)) {
409
+					$cls = ConstructedString::class;
410
+				}
411
+				return $cls;
412
+			case Identifier::CLASS_CONTEXT_SPECIFIC:
413
+				return ContextSpecificType::class;
414
+			case Identifier::CLASS_APPLICATION:
415
+				return ApplicationType::class;
416
+			case Identifier::CLASS_PRIVATE:
417
+				return PrivateType::class;
418
+		}
419
+		throw new \UnexpectedValueException(
420
+			sprintf('%s %d not implemented.',
421
+				Identifier::classToName($identifier->typeClass()),
422
+				$identifier->tag()));
423
+	}
424 424
 
425
-    /**
426
-     * Determine the class that implements an universal type of the given tag.
427
-     *
428
-     * @param int $tag
429
-     *
430
-     * @throws \UnexpectedValueException
431
-     *
432
-     * @return string Class name
433
-     */
434
-    protected static function _determineUniversalImplClass(int $tag): string
435
-    {
436
-        if (!array_key_exists($tag, self::MAP_TAG_TO_CLASS)) {
437
-            throw new \UnexpectedValueException(
438
-                "Universal tag {$tag} not implemented.");
439
-        }
440
-        return self::MAP_TAG_TO_CLASS[$tag];
441
-    }
425
+	/**
426
+	 * Determine the class that implements an universal type of the given tag.
427
+	 *
428
+	 * @param int $tag
429
+	 *
430
+	 * @throws \UnexpectedValueException
431
+	 *
432
+	 * @return string Class name
433
+	 */
434
+	protected static function _determineUniversalImplClass(int $tag): string
435
+	{
436
+		if (!array_key_exists($tag, self::MAP_TAG_TO_CLASS)) {
437
+			throw new \UnexpectedValueException(
438
+				"Universal tag {$tag} not implemented.");
439
+		}
440
+		return self::MAP_TAG_TO_CLASS[$tag];
441
+	}
442 442
 
443
-    /**
444
-     * Get textual description of the type for debugging purposes.
445
-     *
446
-     * @return string
447
-     */
448
-    protected function _typeDescriptorString(): string
449
-    {
450
-        if (Identifier::CLASS_UNIVERSAL == $this->typeClass()) {
451
-            return self::tagToName($this->_typeTag);
452
-        }
453
-        return sprintf('%s TAG %d', Identifier::classToName($this->typeClass()),
454
-            $this->_typeTag);
455
-    }
443
+	/**
444
+	 * Get textual description of the type for debugging purposes.
445
+	 *
446
+	 * @return string
447
+	 */
448
+	protected function _typeDescriptorString(): string
449
+	{
450
+		if (Identifier::CLASS_UNIVERSAL == $this->typeClass()) {
451
+			return self::tagToName($this->_typeTag);
452
+		}
453
+		return sprintf('%s TAG %d', Identifier::classToName($this->typeClass()),
454
+			$this->_typeTag);
455
+	}
456 456
 
457
-    /**
458
-     * Check whether the element is a concrete type of a given tag.
459
-     *
460
-     * @param int $tag
461
-     *
462
-     * @return bool
463
-     */
464
-    private function _isConcreteType(int $tag): bool
465
-    {
466
-        // if tag doesn't match
467
-        if ($this->tag() != $tag) {
468
-            return false;
469
-        }
470
-        // if type is universal check that instance is of a correct class
471
-        if (Identifier::CLASS_UNIVERSAL == $this->typeClass()) {
472
-            $cls = self::_determineUniversalImplClass($tag);
473
-            if (!$this instanceof $cls) {
474
-                return false;
475
-            }
476
-        }
477
-        return true;
478
-    }
457
+	/**
458
+	 * Check whether the element is a concrete type of a given tag.
459
+	 *
460
+	 * @param int $tag
461
+	 *
462
+	 * @return bool
463
+	 */
464
+	private function _isConcreteType(int $tag): bool
465
+	{
466
+		// if tag doesn't match
467
+		if ($this->tag() != $tag) {
468
+			return false;
469
+		}
470
+		// if type is universal check that instance is of a correct class
471
+		if (Identifier::CLASS_UNIVERSAL == $this->typeClass()) {
472
+			$cls = self::_determineUniversalImplClass($tag);
473
+			if (!$this instanceof $cls) {
474
+				return false;
475
+			}
476
+		}
477
+		return true;
478
+	}
479 479
 
480
-    /**
481
-     * Check whether the element is a pseudotype.
482
-     *
483
-     * @param int $tag
484
-     *
485
-     * @return bool
486
-     */
487
-    private function _isPseudoType(int $tag): bool
488
-    {
489
-        switch ($tag) {
490
-            case self::TYPE_STRING:
491
-                return $this instanceof StringType;
492
-            case self::TYPE_TIME:
493
-                return $this instanceof TimeType;
494
-        }
495
-        return false;
496
-    }
480
+	/**
481
+	 * Check whether the element is a pseudotype.
482
+	 *
483
+	 * @param int $tag
484
+	 *
485
+	 * @return bool
486
+	 */
487
+	private function _isPseudoType(int $tag): bool
488
+	{
489
+		switch ($tag) {
490
+			case self::TYPE_STRING:
491
+				return $this instanceof StringType;
492
+			case self::TYPE_TIME:
493
+				return $this instanceof TimeType;
494
+		}
495
+		return false;
496
+	}
497 497
 }
Please login to merge, or discard this patch.
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -401,20 +401,20 @@  discard block
 block discarded – undo
401 401
     protected static function _determineImplClass(Identifier $identifier): string
402 402
     {
403 403
         switch ($identifier->typeClass()) {
404
-            case Identifier::CLASS_UNIVERSAL:
405
-                $cls = self::_determineUniversalImplClass($identifier->intTag());
406
-                // constructed strings may be present in BER
407
-                if ($identifier->isConstructed() &&
408
-                    is_subclass_of($cls, PrimitiveString::class)) {
409
-                    $cls = ConstructedString::class;
410
-                }
411
-                return $cls;
412
-            case Identifier::CLASS_CONTEXT_SPECIFIC:
413
-                return ContextSpecificType::class;
414
-            case Identifier::CLASS_APPLICATION:
415
-                return ApplicationType::class;
416
-            case Identifier::CLASS_PRIVATE:
417
-                return PrivateType::class;
404
+        case Identifier::CLASS_UNIVERSAL:
405
+            $cls = self::_determineUniversalImplClass($identifier->intTag());
406
+            // constructed strings may be present in BER
407
+            if ($identifier->isConstructed() &&
408
+                is_subclass_of($cls, PrimitiveString::class)) {
409
+                $cls = ConstructedString::class;
410
+            }
411
+            return $cls;
412
+        case Identifier::CLASS_CONTEXT_SPECIFIC:
413
+            return ContextSpecificType::class;
414
+        case Identifier::CLASS_APPLICATION:
415
+            return ApplicationType::class;
416
+        case Identifier::CLASS_PRIVATE:
417
+            return PrivateType::class;
418 418
         }
419 419
         throw new \UnexpectedValueException(
420 420
             sprintf('%s %d not implemented.',
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
     private function _isPseudoType(int $tag): bool
488 488
     {
489 489
         switch ($tag) {
490
-            case self::TYPE_STRING:
491
-                return $this instanceof StringType;
492
-            case self::TYPE_TIME:
493
-                return $this instanceof TimeType;
490
+        case self::TYPE_STRING:
491
+            return $this instanceof StringType;
492
+        case self::TYPE_TIME:
493
+            return $this instanceof TimeType;
494 494
         }
495 495
         return false;
496 496
     }
Please login to merge, or discard this patch.
lib/ASN1/Type/Constructed/Set.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\ASN1\Type\Constructed;
6 6
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         $obj = clone $this;
36 36
         usort($obj->_elements,
37
-            function (Element $a, Element $b) {
37
+            function(Element $a, Element $b) {
38 38
                 if ($a->typeClass() != $b->typeClass()) {
39 39
                     return $a->typeClass() < $b->typeClass() ? -1 : 1;
40 40
                 }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $obj = clone $this;
59 59
         usort($obj->_elements,
60
-            function (Element $a, Element $b) {
60
+            function(Element $a, Element $b) {
61 61
                 $a_der = $a->toDER();
62 62
                 $b_der = $b->toDER();
63 63
                 return strcmp($a_der, $b_der);
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -12,56 +12,56 @@
 block discarded – undo
12 12
  */
13 13
 class Set extends Structure
14 14
 {
15
-    /**
16
-     * Constructor.
17
-     *
18
-     * @param Element ...$elements Any number of elements
19
-     */
20
-    public function __construct(Element ...$elements)
21
-    {
22
-        $this->_typeTag = self::TYPE_SET;
23
-        parent::__construct(...$elements);
24
-    }
15
+	/**
16
+	 * Constructor.
17
+	 *
18
+	 * @param Element ...$elements Any number of elements
19
+	 */
20
+	public function __construct(Element ...$elements)
21
+	{
22
+		$this->_typeTag = self::TYPE_SET;
23
+		parent::__construct(...$elements);
24
+	}
25 25
 
26
-    /**
27
-     * Sort by canonical ascending order.
28
-     *
29
-     * Used for DER encoding of SET type.
30
-     *
31
-     * @return self
32
-     */
33
-    public function sortedSet(): self
34
-    {
35
-        $obj = clone $this;
36
-        usort($obj->_elements,
37
-            function (Element $a, Element $b) {
38
-                if ($a->typeClass() != $b->typeClass()) {
39
-                    return $a->typeClass() < $b->typeClass() ? -1 : 1;
40
-                }
41
-                if ($a->tag() == $b->tag()) {
42
-                    return 0;
43
-                }
44
-                return $a->tag() < $b->tag() ? -1 : 1;
45
-            });
46
-        return $obj;
47
-    }
26
+	/**
27
+	 * Sort by canonical ascending order.
28
+	 *
29
+	 * Used for DER encoding of SET type.
30
+	 *
31
+	 * @return self
32
+	 */
33
+	public function sortedSet(): self
34
+	{
35
+		$obj = clone $this;
36
+		usort($obj->_elements,
37
+			function (Element $a, Element $b) {
38
+				if ($a->typeClass() != $b->typeClass()) {
39
+					return $a->typeClass() < $b->typeClass() ? -1 : 1;
40
+				}
41
+				if ($a->tag() == $b->tag()) {
42
+					return 0;
43
+				}
44
+				return $a->tag() < $b->tag() ? -1 : 1;
45
+			});
46
+		return $obj;
47
+	}
48 48
 
49
-    /**
50
-     * Sort by encoding ascending order.
51
-     *
52
-     * Used for DER encoding of SET OF type.
53
-     *
54
-     * @return self
55
-     */
56
-    public function sortedSetOf(): self
57
-    {
58
-        $obj = clone $this;
59
-        usort($obj->_elements,
60
-            function (Element $a, Element $b) {
61
-                $a_der = $a->toDER();
62
-                $b_der = $b->toDER();
63
-                return strcmp($a_der, $b_der);
64
-            });
65
-        return $obj;
66
-    }
49
+	/**
50
+	 * Sort by encoding ascending order.
51
+	 *
52
+	 * Used for DER encoding of SET OF type.
53
+	 *
54
+	 * @return self
55
+	 */
56
+	public function sortedSetOf(): self
57
+	{
58
+		$obj = clone $this;
59
+		usort($obj->_elements,
60
+			function (Element $a, Element $b) {
61
+				$a_der = $a->toDER();
62
+				$b_der = $b->toDER();
63
+				return strcmp($a_der, $b_der);
64
+			});
65
+		return $obj;
66
+	}
67 67
 }
Please login to merge, or discard this patch.