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 — php70 ( e15417...9941dc )
by Joni
03:18
created
lib/ASN1/Type/Primitive/UniversalString.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,29 +14,29 @@
 block discarded – undo
14 14
  */
15 15
 class UniversalString extends PrimitiveString
16 16
 {
17
-    use UniversalClass;
17
+	use UniversalClass;
18 18
     
19
-    /**
20
-     * Constructor.
21
-     *
22
-     * @param string $string
23
-     */
24
-    public function __construct(string $string)
25
-    {
26
-        $this->_typeTag = self::TYPE_UNIVERSAL_STRING;
27
-        parent::__construct($string);
28
-    }
19
+	/**
20
+	 * Constructor.
21
+	 *
22
+	 * @param string $string
23
+	 */
24
+	public function __construct(string $string)
25
+	{
26
+		$this->_typeTag = self::TYPE_UNIVERSAL_STRING;
27
+		parent::__construct($string);
28
+	}
29 29
     
30
-    /**
31
-     *
32
-     * {@inheritdoc}
33
-     */
34
-    protected function _validateString(string $string): bool
35
-    {
36
-        // UCS-4 has fixed with of 4 octets (32 bits)
37
-        if (strlen($string) % 4 != 0) {
38
-            return false;
39
-        }
40
-        return true;
41
-    }
30
+	/**
31
+	 *
32
+	 * {@inheritdoc}
33
+	 */
34
+	protected function _validateString(string $string): bool
35
+	{
36
+		// UCS-4 has fixed with of 4 octets (32 bits)
37
+		if (strlen($string) % 4 != 0) {
38
+			return false;
39
+		}
40
+		return true;
41
+	}
42 42
 }
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 ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/UTF8String.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@
 block discarded – undo
14 14
  */
15 15
 class UTF8String extends PrimitiveString
16 16
 {
17
-    use UniversalClass;
17
+	use UniversalClass;
18 18
     
19
-    /**
20
-     * Constructor.
21
-     *
22
-     * @param string $string
23
-     */
24
-    public function __construct(string $string)
25
-    {
26
-        $this->_typeTag = self::TYPE_UTF8_STRING;
27
-        parent::__construct($string);
28
-    }
19
+	/**
20
+	 * Constructor.
21
+	 *
22
+	 * @param string $string
23
+	 */
24
+	public function __construct(string $string)
25
+	{
26
+		$this->_typeTag = self::TYPE_UTF8_STRING;
27
+		parent::__construct($string);
28
+	}
29 29
     
30
-    /**
31
-     *
32
-     * {@inheritdoc}
33
-     */
34
-    protected function _validateString(string $string): bool
35
-    {
36
-        return mb_check_encoding($string, "UTF-8");
37
-    }
30
+	/**
31
+	 *
32
+	 * {@inheritdoc}
33
+	 */
34
+	protected function _validateString(string $string): bool
35
+	{
36
+		return mb_check_encoding($string, "UTF-8");
37
+	}
38 38
 }
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 ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/T61String.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -12,27 +12,27 @@
 block discarded – undo
12 12
  */
13 13
 class T61String 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_T61_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_T61_STRING;
25
+		parent::__construct($string);
26
+	}
27 27
     
28
-    /**
29
-     *
30
-     * {@inheritdoc}
31
-     */
32
-    protected function _validateString(string $string): bool
33
-    {
34
-        // allow everything since there's literally
35
-        // thousands of allowed characters (16 bit composed characters)
36
-        return true;
37
-    }
28
+	/**
29
+	 *
30
+	 * {@inheritdoc}
31
+	 */
32
+	protected function _validateString(string $string): bool
33
+	{
34
+		// allow everything since there's literally
35
+		// thousands of allowed characters (16 bit composed characters)
36
+		return true;
37
+	}
38 38
 }
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 ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/VisibleString.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@
 block discarded – undo
12 12
  */
13 13
 class VisibleString 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_VISIBLE_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_VISIBLE_STRING;
25
+		parent::__construct($string);
26
+	}
27 27
     
28
-    /**
29
-     *
30
-     * {@inheritdoc}
31
-     */
32
-    protected function _validateString(string $string): bool
33
-    {
34
-        return preg_match('/[^\x20-\x7e]/', $string) == 0;
35
-    }
28
+	/**
29
+	 *
30
+	 * {@inheritdoc}
31
+	 */
32
+	protected function _validateString(string $string): bool
33
+	{
34
+		return preg_match('/[^\x20-\x7e]/', $string) == 0;
35
+	}
36 36
 }
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 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 ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/Primitive/NumericString.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@
 block discarded – undo
12 12
  */
13 13
 class NumericString 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_NUMERIC_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_NUMERIC_STRING;
25
+		parent::__construct($string);
26
+	}
27 27
     
28
-    /**
29
-     *
30
-     * {@inheritdoc}
31
-     */
32
-    protected function _validateString(string $string): bool
33
-    {
34
-        return preg_match('/[^0-9 ]/', $string) == 0;
35
-    }
28
+	/**
29
+	 *
30
+	 * {@inheritdoc}
31
+	 */
32
+	protected function _validateString(string $string): bool
33
+	{
34
+		return preg_match('/[^0-9 ]/', $string) == 0;
35
+	}
36 36
 }
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 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 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
@@ -16,161 +16,161 @@
 block discarded – undo
16 16
  */
17 17
 class Integer extends Element
18 18
 {
19
-    use UniversalClass;
20
-    use PrimitiveType;
19
+	use UniversalClass;
20
+	use PrimitiveType;
21 21
     
22
-    /**
23
-     * The number.
24
-     *
25
-     * @var BigInt
26
-     */
27
-    private $_number;
22
+	/**
23
+	 * The number.
24
+	 *
25
+	 * @var BigInt
26
+	 */
27
+	private $_number;
28 28
     
29
-    /**
30
-     * Constructor.
31
-     *
32
-     * @param int|string $number Base 10 integer
33
-     */
34
-    public function __construct($number)
35
-    {
36
-        $this->_typeTag = self::TYPE_INTEGER;
37
-        if (!self::_validateNumber($number)) {
38
-            $var = is_scalar($number) ? strval($number) : gettype($number);
39
-            throw new \InvalidArgumentException("'$var' is not a valid number.");
40
-        }
41
-        $this->_number = new BigInt($number);
42
-    }
29
+	/**
30
+	 * Constructor.
31
+	 *
32
+	 * @param int|string $number Base 10 integer
33
+	 */
34
+	public function __construct($number)
35
+	{
36
+		$this->_typeTag = self::TYPE_INTEGER;
37
+		if (!self::_validateNumber($number)) {
38
+			$var = is_scalar($number) ? strval($number) : gettype($number);
39
+			throw new \InvalidArgumentException("'$var' is not a valid number.");
40
+		}
41
+		$this->_number = new BigInt($number);
42
+	}
43 43
     
44
-    /**
45
-     * Get the number as a base 10.
46
-     *
47
-     * @return string Integer as a string
48
-     */
49
-    public function number(): string
50
-    {
51
-        return $this->_number->base10();
52
-    }
44
+	/**
45
+	 * Get the number as a base 10.
46
+	 *
47
+	 * @return string Integer as a string
48
+	 */
49
+	public function number(): string
50
+	{
51
+		return $this->_number->base10();
52
+	}
53 53
     
54
-    /**
55
-     * Get the number as an integer type.
56
-     *
57
-     * @return int
58
-     */
59
-    public function intNumber(): int
60
-    {
61
-        return $this->_number->intVal();
62
-    }
54
+	/**
55
+	 * Get the number as an integer type.
56
+	 *
57
+	 * @return int
58
+	 */
59
+	public function intNumber(): int
60
+	{
61
+		return $this->_number->intVal();
62
+	}
63 63
     
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
-    }
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
+	}
82 82
     
83
-    /**
84
-     * Encode positive integer to DER content.
85
-     *
86
-     * @param \GMP $num
87
-     * @return string
88
-     */
89
-    private static function _encodePositiveInteger(\GMP $num): string
90
-    {
91
-        $bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
92
-        // if first bit is 1, prepend full zero byte
93
-        // to represent positive two's complement
94
-        if (ord($bin[0]) & 0x80) {
95
-            $bin = chr(0x00) . $bin;
96
-        }
97
-        return $bin;
98
-    }
83
+	/**
84
+	 * Encode positive integer to DER content.
85
+	 *
86
+	 * @param \GMP $num
87
+	 * @return string
88
+	 */
89
+	private static function _encodePositiveInteger(\GMP $num): string
90
+	{
91
+		$bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
92
+		// if first bit is 1, prepend full zero byte
93
+		// to represent positive two's complement
94
+		if (ord($bin[0]) & 0x80) {
95
+			$bin = chr(0x00) . $bin;
96
+		}
97
+		return $bin;
98
+	}
99 99
     
100
-    /**
101
-     * Encode negative integer to DER content.
102
-     *
103
-     * @param \GMP $num
104
-     * @return string
105
-     */
106
-    private static function _encodeNegativeInteger(\GMP $num): string
107
-    {
108
-        $num = gmp_abs($num);
109
-        // compute number of bytes required
110
-        $width = 1;
111
-        if ($num > 128) {
112
-            $tmp = $num;
113
-            do {
114
-                $width++;
115
-                $tmp >>= 8;
116
-            } while ($tmp > 128);
117
-        }
118
-        // compute two's complement 2^n - x
119
-        $num = gmp_pow("2", 8 * $width) - $num;
120
-        $bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
121
-        // if first bit is 0, prepend full inverted byte
122
-        // to represent negative two's complement
123
-        if (!(ord($bin[0]) & 0x80)) {
124
-            $bin = chr(0xff) . $bin;
125
-        }
126
-        return $bin;
127
-    }
100
+	/**
101
+	 * Encode negative integer to DER content.
102
+	 *
103
+	 * @param \GMP $num
104
+	 * @return string
105
+	 */
106
+	private static function _encodeNegativeInteger(\GMP $num): string
107
+	{
108
+		$num = gmp_abs($num);
109
+		// compute number of bytes required
110
+		$width = 1;
111
+		if ($num > 128) {
112
+			$tmp = $num;
113
+			do {
114
+				$width++;
115
+				$tmp >>= 8;
116
+			} while ($tmp > 128);
117
+		}
118
+		// compute two's complement 2^n - x
119
+		$num = gmp_pow("2", 8 * $width) - $num;
120
+		$bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
121
+		// if first bit is 0, prepend full inverted byte
122
+		// to represent negative two's complement
123
+		if (!(ord($bin[0]) & 0x80)) {
124
+			$bin = chr(0xff) . $bin;
125
+		}
126
+		return $bin;
127
+	}
128 128
     
129
-    /**
130
-     *
131
-     * {@inheritdoc}
132
-     * @return self
133
-     */
134
-    protected static function _decodeFromDER(Identifier $identifier,
135
-        string $data, int &$offset): ElementBase
136
-    {
137
-        $idx = $offset;
138
-        $length = Length::expectFromDER($data, $idx)->intLength();
139
-        $bytes = substr($data, $idx, $length);
140
-        $idx += $length;
141
-        $neg = ord($bytes[0]) & 0x80;
142
-        // negative, apply inversion of two's complement
143
-        if ($neg) {
144
-            $len = strlen($bytes);
145
-            for ($i = 0; $i < $len; $i++) {
146
-                $bytes[$i] = ~$bytes[$i];
147
-            }
148
-        }
149
-        $num = gmp_init(bin2hex($bytes), 16);
150
-        // negative, apply addition of two's complement
151
-        // and produce negative result
152
-        if ($neg) {
153
-            $num = gmp_neg($num + 1);
154
-        }
155
-        $offset = $idx;
156
-        // late static binding since enumerated extends integer type
157
-        return new static(gmp_strval($num, 10));
158
-    }
129
+	/**
130
+	 *
131
+	 * {@inheritdoc}
132
+	 * @return self
133
+	 */
134
+	protected static function _decodeFromDER(Identifier $identifier,
135
+		string $data, int &$offset): ElementBase
136
+	{
137
+		$idx = $offset;
138
+		$length = Length::expectFromDER($data, $idx)->intLength();
139
+		$bytes = substr($data, $idx, $length);
140
+		$idx += $length;
141
+		$neg = ord($bytes[0]) & 0x80;
142
+		// negative, apply inversion of two's complement
143
+		if ($neg) {
144
+			$len = strlen($bytes);
145
+			for ($i = 0; $i < $len; $i++) {
146
+				$bytes[$i] = ~$bytes[$i];
147
+			}
148
+		}
149
+		$num = gmp_init(bin2hex($bytes), 16);
150
+		// negative, apply addition of two's complement
151
+		// and produce negative result
152
+		if ($neg) {
153
+			$num = gmp_neg($num + 1);
154
+		}
155
+		$offset = $idx;
156
+		// late static binding since enumerated extends integer type
157
+		return new static(gmp_strval($num, 10));
158
+	}
159 159
     
160
-    /**
161
-     * Test that number is valid for this context.
162
-     *
163
-     * @param mixed $num
164
-     * @return bool
165
-     */
166
-    private static function _validateNumber($num): bool
167
-    {
168
-        if (is_int($num)) {
169
-            return true;
170
-        }
171
-        if (is_string($num) && preg_match('/-?\d+/', $num)) {
172
-            return true;
173
-        }
174
-        return false;
175
-    }
160
+	/**
161
+	 * Test that number is valid for this context.
162
+	 *
163
+	 * @param mixed $num
164
+	 * @return bool
165
+	 */
166
+	private static function _validateNumber($num): bool
167
+	{
168
+		if (is_int($num)) {
169
+			return true;
170
+		}
171
+		if (is_string($num) && preg_match('/-?\d+/', $num)) {
172
+			return true;
173
+		}
174
+		return false;
175
+	}
176 176
 }
Please login to merge, or discard this patch.
lib/ASN1/Util/BigInt.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -6,106 +6,106 @@
 block discarded – undo
6 6
 
7 7
 class BigInt
8 8
 {
9
-    /**
10
-     * Number as a base10 integer string.
11
-     *
12
-     * @var string
13
-     */
14
-    private $_num;
9
+	/**
10
+	 * Number as a base10 integer string.
11
+	 *
12
+	 * @var string
13
+	 */
14
+	private $_num;
15 15
     
16
-    /**
17
-     * Number as an integer type.
18
-     *
19
-     * @internal Lazily initialized
20
-     * @var int|null
21
-     */
22
-    private $_intNum;
16
+	/**
17
+	 * Number as an integer type.
18
+	 *
19
+	 * @internal Lazily initialized
20
+	 * @var int|null
21
+	 */
22
+	private $_intNum;
23 23
     
24
-    /**
25
-     * Constructor.
26
-     *
27
-     * @param string|int $num
28
-     */
29
-    public function __construct($num)
30
-    {
31
-        $this->_num = strval($num);
32
-    }
24
+	/**
25
+	 * Constructor.
26
+	 *
27
+	 * @param string|int $num
28
+	 */
29
+	public function __construct($num)
30
+	{
31
+		$this->_num = strval($num);
32
+	}
33 33
     
34
-    /**
35
-     * Get the number as a base10 integer string.
36
-     *
37
-     * @return string
38
-     */
39
-    public function base10(): string
40
-    {
41
-        return $this->_num;
42
-    }
34
+	/**
35
+	 * Get the number as a base10 integer string.
36
+	 *
37
+	 * @return string
38
+	 */
39
+	public function base10(): string
40
+	{
41
+		return $this->_num;
42
+	}
43 43
     
44
-    /**
45
-     * Get the number as an integer.
46
-     *
47
-     * @throws \RuntimeException If number overflows integer size
48
-     * @return int
49
-     */
50
-    public function intVal(): int
51
-    {
52
-        if (!isset($this->_intNum)) {
53
-            $num = gmp_init($this->_num, 10);
54
-            if (gmp_cmp($num, $this->_intMaxGmp()) > 0) {
55
-                throw new \RuntimeException("Integer overflow.");
56
-            }
57
-            if (gmp_cmp($num, $this->_intMinGmp()) < 0) {
58
-                throw new \RuntimeException("Integer underflow.");
59
-            }
60
-            $this->_intNum = gmp_intval($num);
61
-        }
62
-        return $this->_intNum;
63
-    }
44
+	/**
45
+	 * Get the number as an integer.
46
+	 *
47
+	 * @throws \RuntimeException If number overflows integer size
48
+	 * @return int
49
+	 */
50
+	public function intVal(): int
51
+	{
52
+		if (!isset($this->_intNum)) {
53
+			$num = gmp_init($this->_num, 10);
54
+			if (gmp_cmp($num, $this->_intMaxGmp()) > 0) {
55
+				throw new \RuntimeException("Integer overflow.");
56
+			}
57
+			if (gmp_cmp($num, $this->_intMinGmp()) < 0) {
58
+				throw new \RuntimeException("Integer underflow.");
59
+			}
60
+			$this->_intNum = gmp_intval($num);
61
+		}
62
+		return $this->_intNum;
63
+	}
64 64
     
65
-    /**
66
-     * Get the maximum integer value.
67
-     *
68
-     * @return \GMP
69
-     */
70
-    private function _intMaxGmp(): \GMP
71
-    {
72
-        static $gmp;
73
-        if (!isset($gmp)) {
74
-            $gmp = gmp_init(PHP_INT_MAX, 10);
75
-        }
76
-        return $gmp;
77
-    }
65
+	/**
66
+	 * Get the maximum integer value.
67
+	 *
68
+	 * @return \GMP
69
+	 */
70
+	private function _intMaxGmp(): \GMP
71
+	{
72
+		static $gmp;
73
+		if (!isset($gmp)) {
74
+			$gmp = gmp_init(PHP_INT_MAX, 10);
75
+		}
76
+		return $gmp;
77
+	}
78 78
     
79
-    /**
80
-     * Get the minimum integer value.
81
-     *
82
-     * @return \GMP
83
-     */
84
-    private function _intMinGmp(): \GMP
85
-    {
86
-        static $gmp;
87
-        if (!isset($gmp)) {
88
-            $gmp = gmp_init(PHP_INT_MIN, 10);
89
-        }
90
-        return $gmp;
91
-    }
79
+	/**
80
+	 * Get the minimum integer value.
81
+	 *
82
+	 * @return \GMP
83
+	 */
84
+	private function _intMinGmp(): \GMP
85
+	{
86
+		static $gmp;
87
+		if (!isset($gmp)) {
88
+			$gmp = gmp_init(PHP_INT_MIN, 10);
89
+		}
90
+		return $gmp;
91
+	}
92 92
     
93
-    /**
94
-     * Get the number as a GMP object.
95
-     *
96
-     * @return \GMP
97
-     */
98
-    public function gmpObj(): \GMP
99
-    {
100
-        return gmp_init($this->_num, 10);
101
-    }
93
+	/**
94
+	 * Get the number as a GMP object.
95
+	 *
96
+	 * @return \GMP
97
+	 */
98
+	public function gmpObj(): \GMP
99
+	{
100
+		return gmp_init($this->_num, 10);
101
+	}
102 102
     
103
-    /**
104
-     *
105
-     * @return string
106
-     */
107
-    public function __toString()
108
-    {
109
-        return $this->base10();
110
-    }
103
+	/**
104
+	 *
105
+	 * @return string
106
+	 */
107
+	public function __toString()
108
+	{
109
+		return $this->base10();
110
+	}
111 111
 }
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 ASN1\Util;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Util/Flags.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -11,141 +11,141 @@
 block discarded – undo
11 11
  */
12 12
 class Flags
13 13
 {
14
-    /**
15
-     * Flag octets.
16
-     *
17
-     * @var string $_flags
18
-     */
19
-    protected $_flags;
14
+	/**
15
+	 * Flag octets.
16
+	 *
17
+	 * @var string $_flags
18
+	 */
19
+	protected $_flags;
20 20
     
21
-    /**
22
-     * Number of flags.
23
-     *
24
-     * @var int $_width
25
-     */
26
-    protected $_width;
21
+	/**
22
+	 * Number of flags.
23
+	 *
24
+	 * @var int $_width
25
+	 */
26
+	protected $_width;
27 27
     
28
-    /**
29
-     * Constructor.
30
-     *
31
-     * @param int|string $flags Flags
32
-     * @param int $width The number of flags. If width is larger than number of
33
-     *        bits in $flags, zeroes are prepended to flag field.
34
-     */
35
-    public function __construct($flags, int $width)
36
-    {
37
-        if (!$width) {
38
-            $this->_flags = "";
39
-        } else {
40
-            // calculate number of unused bits in last octet
41
-            $last_octet_bits = $width % 8;
42
-            $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
43
-            $num = gmp_init($flags);
44
-            // mask bits outside bitfield width
45
-            $mask = gmp_sub(gmp_init(1) << $width, 1);
46
-            $num &= $mask;
47
-            // shift towards MSB if needed
48
-            $data = gmp_export($num << $unused_bits, 1,
49
-                GMP_MSW_FIRST | GMP_BIG_ENDIAN);
50
-            $octets = unpack("C*", $data);
51
-            $bits = count($octets) * 8;
52
-            // pad with zeroes
53
-            while ($bits < $width) {
54
-                array_unshift($octets, 0);
55
-                $bits += 8;
56
-            }
57
-            $this->_flags = pack("C*", ...$octets);
58
-        }
59
-        $this->_width = $width;
60
-    }
28
+	/**
29
+	 * Constructor.
30
+	 *
31
+	 * @param int|string $flags Flags
32
+	 * @param int $width The number of flags. If width is larger than number of
33
+	 *        bits in $flags, zeroes are prepended to flag field.
34
+	 */
35
+	public function __construct($flags, int $width)
36
+	{
37
+		if (!$width) {
38
+			$this->_flags = "";
39
+		} else {
40
+			// calculate number of unused bits in last octet
41
+			$last_octet_bits = $width % 8;
42
+			$unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
43
+			$num = gmp_init($flags);
44
+			// mask bits outside bitfield width
45
+			$mask = gmp_sub(gmp_init(1) << $width, 1);
46
+			$num &= $mask;
47
+			// shift towards MSB if needed
48
+			$data = gmp_export($num << $unused_bits, 1,
49
+				GMP_MSW_FIRST | GMP_BIG_ENDIAN);
50
+			$octets = unpack("C*", $data);
51
+			$bits = count($octets) * 8;
52
+			// pad with zeroes
53
+			while ($bits < $width) {
54
+				array_unshift($octets, 0);
55
+				$bits += 8;
56
+			}
57
+			$this->_flags = pack("C*", ...$octets);
58
+		}
59
+		$this->_width = $width;
60
+	}
61 61
     
62
-    /**
63
-     * Initialize from BitString.
64
-     *
65
-     * @param BitString $bs
66
-     * @param int $width
67
-     * @return self
68
-     */
69
-    public static function fromBitString(BitString $bs, int $width): self
70
-    {
71
-        $num_bits = $bs->numBits();
72
-        $num = gmp_import($bs->string(), 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
73
-        $num >>= $bs->unusedBits();
74
-        if ($num_bits < $width) {
75
-            $num <<= ($width - $num_bits);
76
-        }
77
-        return new self(gmp_strval($num, 10), $width);
78
-    }
62
+	/**
63
+	 * Initialize from BitString.
64
+	 *
65
+	 * @param BitString $bs
66
+	 * @param int $width
67
+	 * @return self
68
+	 */
69
+	public static function fromBitString(BitString $bs, int $width): self
70
+	{
71
+		$num_bits = $bs->numBits();
72
+		$num = gmp_import($bs->string(), 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
73
+		$num >>= $bs->unusedBits();
74
+		if ($num_bits < $width) {
75
+			$num <<= ($width - $num_bits);
76
+		}
77
+		return new self(gmp_strval($num, 10), $width);
78
+	}
79 79
     
80
-    /**
81
-     * Check whether a bit at given index is set.
82
-     * Index 0 is the leftmost bit.
83
-     *
84
-     * @param int $idx
85
-     * @throws \OutOfBoundsException
86
-     * @return bool
87
-     */
88
-    public function test(int $idx): bool
89
-    {
90
-        if ($idx >= $this->_width) {
91
-            throw new \OutOfBoundsException("Index is out of bounds.");
92
-        }
93
-        // octet index
94
-        $oi = (int) floor($idx / 8);
95
-        $byte = $this->_flags[$oi];
96
-        // bit index
97
-        $bi = $idx % 8;
98
-        // index 0 is the most significant bit in byte
99
-        $mask = 0x01 << (7 - $bi);
100
-        return (ord($byte) & $mask) > 0;
101
-    }
80
+	/**
81
+	 * Check whether a bit at given index is set.
82
+	 * Index 0 is the leftmost bit.
83
+	 *
84
+	 * @param int $idx
85
+	 * @throws \OutOfBoundsException
86
+	 * @return bool
87
+	 */
88
+	public function test(int $idx): bool
89
+	{
90
+		if ($idx >= $this->_width) {
91
+			throw new \OutOfBoundsException("Index is out of bounds.");
92
+		}
93
+		// octet index
94
+		$oi = (int) floor($idx / 8);
95
+		$byte = $this->_flags[$oi];
96
+		// bit index
97
+		$bi = $idx % 8;
98
+		// index 0 is the most significant bit in byte
99
+		$mask = 0x01 << (7 - $bi);
100
+		return (ord($byte) & $mask) > 0;
101
+	}
102 102
     
103
-    /**
104
-     * Get flags as an octet string.
105
-     * Zeroes are appended to the last octet if width is not divisible by 8.
106
-     *
107
-     * @return string
108
-     */
109
-    public function string(): string
110
-    {
111
-        return $this->_flags;
112
-    }
103
+	/**
104
+	 * Get flags as an octet string.
105
+	 * Zeroes are appended to the last octet if width is not divisible by 8.
106
+	 *
107
+	 * @return string
108
+	 */
109
+	public function string(): string
110
+	{
111
+		return $this->_flags;
112
+	}
113 113
     
114
-    /**
115
-     * Get flags as a base 10 integer.
116
-     *
117
-     * @return string Integer as a string
118
-     */
119
-    public function number(): string
120
-    {
121
-        $num = gmp_import($this->_flags, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
122
-        $last_octet_bits = $this->_width % 8;
123
-        $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
124
-        $num >>= $unused_bits;
125
-        return gmp_strval($num, 10);
126
-    }
114
+	/**
115
+	 * Get flags as a base 10 integer.
116
+	 *
117
+	 * @return string Integer as a string
118
+	 */
119
+	public function number(): string
120
+	{
121
+		$num = gmp_import($this->_flags, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
122
+		$last_octet_bits = $this->_width % 8;
123
+		$unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
124
+		$num >>= $unused_bits;
125
+		return gmp_strval($num, 10);
126
+	}
127 127
     
128
-    /**
129
-     * Get flags as an integer.
130
-     *
131
-     * @return int
132
-     */
133
-    public function intNumber(): int
134
-    {
135
-        $num = new BigInt($this->number());
136
-        return $num->intVal();
137
-    }
128
+	/**
129
+	 * Get flags as an integer.
130
+	 *
131
+	 * @return int
132
+	 */
133
+	public function intNumber(): int
134
+	{
135
+		$num = new BigInt($this->number());
136
+		return $num->intVal();
137
+	}
138 138
     
139
-    /**
140
-     * Get flags as a BitString.
141
-     * Unused bits are set accordingly. Trailing zeroes are not stripped.
142
-     *
143
-     * @return BitString
144
-     */
145
-    public function bitString(): BitString
146
-    {
147
-        $last_octet_bits = $this->_width % 8;
148
-        $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
149
-        return new BitString($this->_flags, $unused_bits);
150
-    }
139
+	/**
140
+	 * Get flags as a BitString.
141
+	 * Unused bits are set accordingly. Trailing zeroes are not stripped.
142
+	 *
143
+	 * @return BitString
144
+	 */
145
+	public function bitString(): BitString
146
+	{
147
+		$last_octet_bits = $this->_width % 8;
148
+		$unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
149
+		return new BitString($this->_flags, $unused_bits);
150
+	}
151 151
 }
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 ASN1\Util;
6 6
 
Please login to merge, or discard this patch.