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
Branch php72 (57c34e)
by Joni
05:01
created
lib/ASN1/Type/Primitive/RelativeOID.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,36 +13,36 @@
 block discarded – undo
13 13
  */
14 14
 class RelativeOID extends ObjectIdentifier
15 15
 {
16
-    /**
17
-     * Constructor.
18
-     *
19
-     * @param string $oid OID in dotted format
20
-     */
21
-    public function __construct(string $oid)
22
-    {
23
-        $this->_oid = $oid;
24
-        $this->_subids = self::_explodeDottedOID($oid);
25
-        $this->_typeTag = self::TYPE_RELATIVE_OID;
26
-    }
16
+	/**
17
+	 * Constructor.
18
+	 *
19
+	 * @param string $oid OID in dotted format
20
+	 */
21
+	public function __construct(string $oid)
22
+	{
23
+		$this->_oid = $oid;
24
+		$this->_subids = self::_explodeDottedOID($oid);
25
+		$this->_typeTag = self::TYPE_RELATIVE_OID;
26
+	}
27 27
 
28
-    /**
29
-     * {@inheritdoc}
30
-     */
31
-    protected function _encodedContentDER(): string
32
-    {
33
-        return self::_encodeSubIDs(...$this->_subids);
34
-    }
28
+	/**
29
+	 * {@inheritdoc}
30
+	 */
31
+	protected function _encodedContentDER(): string
32
+	{
33
+		return self::_encodeSubIDs(...$this->_subids);
34
+	}
35 35
 
36
-    /**
37
-     * {@inheritdoc}
38
-     */
39
-    protected static function _decodeFromDER(Identifier $identifier,
40
-        string $data, int &$offset): ElementBase
41
-    {
42
-        $idx = $offset;
43
-        $len = Length::expectFromDER($data, $idx)->intLength();
44
-        $subids = self::_decodeSubIDs(substr($data, $idx, $len));
45
-        $offset = $idx + $len;
46
-        return new self(self::_implodeSubIDs(...$subids));
47
-    }
36
+	/**
37
+	 * {@inheritdoc}
38
+	 */
39
+	protected static function _decodeFromDER(Identifier $identifier,
40
+		string $data, int &$offset): ElementBase
41
+	{
42
+		$idx = $offset;
43
+		$len = Length::expectFromDER($data, $idx)->intLength();
44
+		$subids = self::_decodeSubIDs(substr($data, $idx, $len));
45
+		$offset = $idx + $len;
46
+		return new self(self::_implodeSubIDs(...$subids));
47
+	}
48 48
 }
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/GraphicString.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 GraphicString 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_GRAPHIC_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_GRAPHIC_STRING;
25
+		parent::__construct($string);
26
+	}
27 27
 
28
-    /**
29
-     * {@inheritdoc}
30
-     */
31
-    protected function _validateString(string $string): bool
32
-    {
33
-        // allow everything
34
-        return true;
35
-    }
28
+	/**
29
+	 * {@inheritdoc}
30
+	 */
31
+	protected function _validateString(string $string): bool
32
+	{
33
+		// allow everything
34
+		return true;
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 Sop\ASN1\Type\Primitive;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/PrimitiveType.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@
 block discarded – undo
9 9
  */
10 10
 trait PrimitiveType
11 11
 {
12
-    /**
13
-     * @see \Sop\ASN1\Feature\ElementBase::isConstructed()
14
-     *
15
-     * @return bool
16
-     */
17
-    public function isConstructed(): bool
18
-    {
19
-        return false;
20
-    }
12
+	/**
13
+	 * @see \Sop\ASN1\Feature\ElementBase::isConstructed()
14
+	 *
15
+	 * @return bool
16
+	 */
17
+	public function isConstructed(): bool
18
+	{
19
+		return false;
20
+	}
21 21
 }
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;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/TaggedType.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -14,79 +14,79 @@
 block discarded – undo
14 14
  */
15 15
 abstract class TaggedType extends Element
16 16
 {
17
-    /**
18
-     * Check whether element supports explicit tagging.
19
-     *
20
-     * @param null|int $expectedTag Optional outer tag expectation
21
-     *
22
-     * @throws \UnexpectedValueException If expectation fails
23
-     *
24
-     * @return ExplicitTagging
25
-     */
26
-    public function expectExplicit(?int $expectedTag = null): ExplicitTagging
27
-    {
28
-        $el = $this;
29
-        if (!$el instanceof ExplicitTagging) {
30
-            throw new \UnexpectedValueException(
31
-                "Element doesn't implement explicit tagging.");
32
-        }
33
-        if (isset($expectedTag)) {
34
-            $el->expectTagged($expectedTag);
35
-        }
36
-        return $el;
37
-    }
17
+	/**
18
+	 * Check whether element supports explicit tagging.
19
+	 *
20
+	 * @param null|int $expectedTag Optional outer tag expectation
21
+	 *
22
+	 * @throws \UnexpectedValueException If expectation fails
23
+	 *
24
+	 * @return ExplicitTagging
25
+	 */
26
+	public function expectExplicit(?int $expectedTag = null): ExplicitTagging
27
+	{
28
+		$el = $this;
29
+		if (!$el instanceof ExplicitTagging) {
30
+			throw new \UnexpectedValueException(
31
+				"Element doesn't implement explicit tagging.");
32
+		}
33
+		if (isset($expectedTag)) {
34
+			$el->expectTagged($expectedTag);
35
+		}
36
+		return $el;
37
+	}
38 38
 
39
-    /**
40
-     * Get the wrapped inner element employing explicit tagging.
41
-     *
42
-     * @param null|int $expectedTag Optional outer tag expectation
43
-     *
44
-     * @throws \UnexpectedValueException If expectation fails
45
-     *
46
-     * @return UnspecifiedType
47
-     */
48
-    public function asExplicit(?int $expectedTag = null): UnspecifiedType
49
-    {
50
-        return $this->expectExplicit($expectedTag)->explicit();
51
-    }
39
+	/**
40
+	 * Get the wrapped inner element employing explicit tagging.
41
+	 *
42
+	 * @param null|int $expectedTag Optional outer tag expectation
43
+	 *
44
+	 * @throws \UnexpectedValueException If expectation fails
45
+	 *
46
+	 * @return UnspecifiedType
47
+	 */
48
+	public function asExplicit(?int $expectedTag = null): UnspecifiedType
49
+	{
50
+		return $this->expectExplicit($expectedTag)->explicit();
51
+	}
52 52
 
53
-    /**
54
-     * Check whether element supports implicit tagging.
55
-     *
56
-     * @param null|int $expectedTag Optional outer tag expectation
57
-     *
58
-     * @throws \UnexpectedValueException If expectation fails
59
-     *
60
-     * @return ImplicitTagging
61
-     */
62
-    public function expectImplicit(?int $expectedTag = null): ImplicitTagging
63
-    {
64
-        $el = $this;
65
-        if (!$el instanceof ImplicitTagging) {
66
-            throw new \UnexpectedValueException(
67
-                "Element doesn't implement implicit tagging.");
68
-        }
69
-        if (isset($expectedTag)) {
70
-            $el->expectTagged($expectedTag);
71
-        }
72
-        return $el;
73
-    }
53
+	/**
54
+	 * Check whether element supports implicit tagging.
55
+	 *
56
+	 * @param null|int $expectedTag Optional outer tag expectation
57
+	 *
58
+	 * @throws \UnexpectedValueException If expectation fails
59
+	 *
60
+	 * @return ImplicitTagging
61
+	 */
62
+	public function expectImplicit(?int $expectedTag = null): ImplicitTagging
63
+	{
64
+		$el = $this;
65
+		if (!$el instanceof ImplicitTagging) {
66
+			throw new \UnexpectedValueException(
67
+				"Element doesn't implement implicit tagging.");
68
+		}
69
+		if (isset($expectedTag)) {
70
+			$el->expectTagged($expectedTag);
71
+		}
72
+		return $el;
73
+	}
74 74
 
75
-    /**
76
-     * Get the wrapped inner element employing implicit tagging.
77
-     *
78
-     * @param int      $tag           Type tag of the inner element
79
-     * @param null|int $expectedTag   Optional outer tag expectation
80
-     * @param int      $expectedClass Optional inner type class expectation
81
-     *
82
-     * @throws \UnexpectedValueException If expectation fails
83
-     *
84
-     * @return UnspecifiedType
85
-     */
86
-    public function asImplicit(int $tag, ?int $expectedTag = null,
87
-        int $expectedClass = Identifier::CLASS_UNIVERSAL): UnspecifiedType
88
-    {
89
-        return $this->expectImplicit($expectedTag)->implicit($tag,
90
-            $expectedClass);
91
-    }
75
+	/**
76
+	 * Get the wrapped inner element employing implicit tagging.
77
+	 *
78
+	 * @param int      $tag           Type tag of the inner element
79
+	 * @param null|int $expectedTag   Optional outer tag expectation
80
+	 * @param int      $expectedClass Optional inner type class expectation
81
+	 *
82
+	 * @throws \UnexpectedValueException If expectation fails
83
+	 *
84
+	 * @return UnspecifiedType
85
+	 */
86
+	public function asImplicit(int $tag, ?int $expectedTag = null,
87
+		int $expectedClass = Identifier::CLASS_UNIVERSAL): UnspecifiedType
88
+	{
89
+		return $this->expectImplicit($expectedTag)->implicit($tag,
90
+			$expectedClass);
91
+	}
92 92
 }
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;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Type/StringType.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -11,50 +11,50 @@
 block discarded – undo
11 11
  */
12 12
 abstract class StringType extends Element
13 13
 {
14
-    /**
15
-     * String value.
16
-     *
17
-     * @var string
18
-     */
19
-    protected $_string;
14
+	/**
15
+	 * String value.
16
+	 *
17
+	 * @var string
18
+	 */
19
+	protected $_string;
20 20
 
21
-    /**
22
-     * Constructor.
23
-     *
24
-     * @param string $string
25
-     *
26
-     * @throws \InvalidArgumentException
27
-     */
28
-    public function __construct(string $string)
29
-    {
30
-        if (!$this->_validateString($string)) {
31
-            throw new \InvalidArgumentException(
32
-                sprintf('Not a valid %s string.',
33
-                    self::tagToName($this->_typeTag)));
34
-        }
35
-        $this->_string = $string;
36
-    }
21
+	/**
22
+	 * Constructor.
23
+	 *
24
+	 * @param string $string
25
+	 *
26
+	 * @throws \InvalidArgumentException
27
+	 */
28
+	public function __construct(string $string)
29
+	{
30
+		if (!$this->_validateString($string)) {
31
+			throw new \InvalidArgumentException(
32
+				sprintf('Not a valid %s string.',
33
+					self::tagToName($this->_typeTag)));
34
+		}
35
+		$this->_string = $string;
36
+	}
37 37
 
38
-    /**
39
-     * Get the string value.
40
-     *
41
-     * @return string
42
-     */
43
-    public function string(): string
44
-    {
45
-        return $this->_string;
46
-    }
38
+	/**
39
+	 * Get the string value.
40
+	 *
41
+	 * @return string
42
+	 */
43
+	public function string(): string
44
+	{
45
+		return $this->_string;
46
+	}
47 47
 
48
-    /**
49
-     * Check whether string is valid for the concrete type.
50
-     *
51
-     * @param string $string
52
-     *
53
-     * @return bool
54
-     */
55
-    protected function _validateString(string $string): bool
56
-    {
57
-        // Override in derived classes
58
-        return true;
59
-    }
48
+	/**
49
+	 * Check whether string is valid for the concrete type.
50
+	 *
51
+	 * @param string $string
52
+	 *
53
+	 * @return bool
54
+	 */
55
+	protected function _validateString(string $string): bool
56
+	{
57
+		// Override in derived classes
58
+		return true;
59
+	}
60 60
 }
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;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/DERData.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -14,76 +14,76 @@
 block discarded – undo
14 14
  */
15 15
 class DERData extends Element
16 16
 {
17
-    /**
18
-     * DER encoded data.
19
-     *
20
-     * @var string
21
-     */
22
-    protected $_der;
17
+	/**
18
+	 * DER encoded data.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $_der;
23 23
 
24
-    /**
25
-     * Identifier of the underlying type.
26
-     *
27
-     * @var Identifier
28
-     */
29
-    protected $_identifier;
24
+	/**
25
+	 * Identifier of the underlying type.
26
+	 *
27
+	 * @var Identifier
28
+	 */
29
+	protected $_identifier;
30 30
 
31
-    /**
32
-     * Offset to the content in DER data.
33
-     *
34
-     * @var int
35
-     */
36
-    protected $_contentOffset = 0;
31
+	/**
32
+	 * Offset to the content in DER data.
33
+	 *
34
+	 * @var int
35
+	 */
36
+	protected $_contentOffset = 0;
37 37
 
38
-    /**
39
-     * Constructor.
40
-     *
41
-     * @param string $data DER encoded data
42
-     *
43
-     * @throws \Sop\ASN1\Exception\DecodeException If data does not adhere to DER
44
-     */
45
-    public function __construct(string $data)
46
-    {
47
-        $this->_identifier = Identifier::fromDER($data, $this->_contentOffset);
48
-        // check that length encoding is valid
49
-        Length::expectFromDER($data, $this->_contentOffset);
50
-        $this->_der = $data;
51
-        $this->_typeTag = $this->_identifier->intTag();
52
-    }
38
+	/**
39
+	 * Constructor.
40
+	 *
41
+	 * @param string $data DER encoded data
42
+	 *
43
+	 * @throws \Sop\ASN1\Exception\DecodeException If data does not adhere to DER
44
+	 */
45
+	public function __construct(string $data)
46
+	{
47
+		$this->_identifier = Identifier::fromDER($data, $this->_contentOffset);
48
+		// check that length encoding is valid
49
+		Length::expectFromDER($data, $this->_contentOffset);
50
+		$this->_der = $data;
51
+		$this->_typeTag = $this->_identifier->intTag();
52
+	}
53 53
 
54
-    /**
55
-     * {@inheritdoc}
56
-     */
57
-    public function typeClass(): int
58
-    {
59
-        return $this->_identifier->typeClass();
60
-    }
54
+	/**
55
+	 * {@inheritdoc}
56
+	 */
57
+	public function typeClass(): int
58
+	{
59
+		return $this->_identifier->typeClass();
60
+	}
61 61
 
62
-    /**
63
-     * {@inheritdoc}
64
-     */
65
-    public function isConstructed(): bool
66
-    {
67
-        return $this->_identifier->isConstructed();
68
-    }
62
+	/**
63
+	 * {@inheritdoc}
64
+	 */
65
+	public function isConstructed(): bool
66
+	{
67
+		return $this->_identifier->isConstructed();
68
+	}
69 69
 
70
-    /**
71
-     * {@inheritdoc}
72
-     */
73
-    public function toDER(): string
74
-    {
75
-        return $this->_der;
76
-    }
70
+	/**
71
+	 * {@inheritdoc}
72
+	 */
73
+	public function toDER(): string
74
+	{
75
+		return $this->_der;
76
+	}
77 77
 
78
-    /**
79
-     * {@inheritdoc}
80
-     */
81
-    protected function _encodedContentDER(): string
82
-    {
83
-        // if there's no content payload
84
-        if (strlen($this->_der) == $this->_contentOffset) {
85
-            return '';
86
-        }
87
-        return substr($this->_der, $this->_contentOffset);
88
-    }
78
+	/**
79
+	 * {@inheritdoc}
80
+	 */
81
+	protected function _encodedContentDER(): string
82
+	{
83
+		// if there's no content payload
84
+		if (strlen($this->_der) == $this->_contentOffset) {
85
+			return '';
86
+		}
87
+		return substr($this->_der, $this->_contentOffset);
88
+	}
89 89
 }
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;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Util/BigInt.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -6,107 +6,107 @@
 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
-     *
21
-     * @var null|int
22
-     */
23
-    private $_intNum;
16
+	/**
17
+	 * Number as an integer type.
18
+	 *
19
+	 * @internal Lazily initialized
20
+	 *
21
+	 * @var null|int
22
+	 */
23
+	private $_intNum;
24 24
 
25
-    /**
26
-     * Constructor.
27
-     *
28
-     * @param int|string $num
29
-     */
30
-    public function __construct($num)
31
-    {
32
-        $this->_num = strval($num);
33
-    }
25
+	/**
26
+	 * Constructor.
27
+	 *
28
+	 * @param int|string $num
29
+	 */
30
+	public function __construct($num)
31
+	{
32
+		$this->_num = strval($num);
33
+	}
34 34
 
35
-    /**
36
-     * @return string
37
-     */
38
-    public function __toString()
39
-    {
40
-        return $this->base10();
41
-    }
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function __toString()
39
+	{
40
+		return $this->base10();
41
+	}
42 42
 
43
-    /**
44
-     * Get the number as a base10 integer string.
45
-     *
46
-     * @return string
47
-     */
48
-    public function base10(): string
49
-    {
50
-        return $this->_num;
51
-    }
43
+	/**
44
+	 * Get the number as a base10 integer string.
45
+	 *
46
+	 * @return string
47
+	 */
48
+	public function base10(): string
49
+	{
50
+		return $this->_num;
51
+	}
52 52
 
53
-    /**
54
-     * Get the number as an integer.
55
-     *
56
-     * @throws \RuntimeException If number overflows integer size
57
-     *
58
-     * @return int
59
-     */
60
-    public function intVal(): int
61
-    {
62
-        if (!isset($this->_intNum)) {
63
-            $num = gmp_init($this->_num, 10);
64
-            if (gmp_cmp($num, $this->_intMaxGmp()) > 0) {
65
-                throw new \RuntimeException('Integer overflow.');
66
-            }
67
-            if (gmp_cmp($num, $this->_intMinGmp()) < 0) {
68
-                throw new \RuntimeException('Integer underflow.');
69
-            }
70
-            $this->_intNum = gmp_intval($num);
71
-        }
72
-        return $this->_intNum;
73
-    }
53
+	/**
54
+	 * Get the number as an integer.
55
+	 *
56
+	 * @throws \RuntimeException If number overflows integer size
57
+	 *
58
+	 * @return int
59
+	 */
60
+	public function intVal(): int
61
+	{
62
+		if (!isset($this->_intNum)) {
63
+			$num = gmp_init($this->_num, 10);
64
+			if (gmp_cmp($num, $this->_intMaxGmp()) > 0) {
65
+				throw new \RuntimeException('Integer overflow.');
66
+			}
67
+			if (gmp_cmp($num, $this->_intMinGmp()) < 0) {
68
+				throw new \RuntimeException('Integer underflow.');
69
+			}
70
+			$this->_intNum = gmp_intval($num);
71
+		}
72
+		return $this->_intNum;
73
+	}
74 74
 
75
-    /**
76
-     * Get the number as a GMP object.
77
-     *
78
-     * @return \GMP
79
-     */
80
-    public function gmpObj(): \GMP
81
-    {
82
-        return gmp_init($this->_num, 10);
83
-    }
75
+	/**
76
+	 * Get the number as a GMP object.
77
+	 *
78
+	 * @return \GMP
79
+	 */
80
+	public function gmpObj(): \GMP
81
+	{
82
+		return gmp_init($this->_num, 10);
83
+	}
84 84
 
85
-    /**
86
-     * Get the maximum integer value.
87
-     *
88
-     * @return \GMP
89
-     */
90
-    private function _intMaxGmp(): \GMP
91
-    {
92
-        static $gmp;
93
-        if (!isset($gmp)) {
94
-            $gmp = gmp_init(PHP_INT_MAX, 10);
95
-        }
96
-        return $gmp;
97
-    }
85
+	/**
86
+	 * Get the maximum integer value.
87
+	 *
88
+	 * @return \GMP
89
+	 */
90
+	private function _intMaxGmp(): \GMP
91
+	{
92
+		static $gmp;
93
+		if (!isset($gmp)) {
94
+			$gmp = gmp_init(PHP_INT_MAX, 10);
95
+		}
96
+		return $gmp;
97
+	}
98 98
 
99
-    /**
100
-     * Get the minimum integer value.
101
-     *
102
-     * @return \GMP
103
-     */
104
-    private function _intMinGmp(): \GMP
105
-    {
106
-        static $gmp;
107
-        if (!isset($gmp)) {
108
-            $gmp = gmp_init(PHP_INT_MIN, 10);
109
-        }
110
-        return $gmp;
111
-    }
99
+	/**
100
+	 * Get the minimum integer value.
101
+	 *
102
+	 * @return \GMP
103
+	 */
104
+	private function _intMinGmp(): \GMP
105
+	{
106
+		static $gmp;
107
+		if (!isset($gmp)) {
108
+			$gmp = gmp_init(PHP_INT_MIN, 10);
109
+		}
110
+		return $gmp;
111
+	}
112 112
 }
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\Util;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Util/Flags.php 2 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -11,148 +11,148 @@
 block discarded – undo
11 11
  */
12 12
 class Flags
13 13
 {
14
-    /**
15
-     * Flag octets.
16
-     *
17
-     * @var string
18
-     */
19
-    protected $_flags;
14
+	/**
15
+	 * Flag octets.
16
+	 *
17
+	 * @var string
18
+	 */
19
+	protected $_flags;
20 20
 
21
-    /**
22
-     * Number of flags.
23
-     *
24
-     * @var int
25
-     */
26
-    protected $_width;
21
+	/**
22
+	 * Number of flags.
23
+	 *
24
+	 * @var int
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
33
-     *                          number of bits in $flags, zeroes are prepended
34
-     *                          to flag field.
35
-     */
36
-    public function __construct($flags, int $width)
37
-    {
38
-        if (!$width) {
39
-            $this->_flags = '';
40
-        } else {
41
-            // calculate number of unused bits in last octet
42
-            $last_octet_bits = $width % 8;
43
-            $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
44
-            $num = gmp_init($flags);
45
-            // mask bits outside bitfield width
46
-            $mask = gmp_sub(gmp_init(1) << $width, 1);
47
-            $num &= $mask;
48
-            // shift towards MSB if needed
49
-            $data = gmp_export($num << $unused_bits, 1,
50
-                GMP_MSW_FIRST | GMP_BIG_ENDIAN);
51
-            $octets = unpack('C*', $data);
52
-            $bits = count($octets) * 8;
53
-            // pad with zeroes
54
-            while ($bits < $width) {
55
-                array_unshift($octets, 0);
56
-                $bits += 8;
57
-            }
58
-            $this->_flags = pack('C*', ...$octets);
59
-        }
60
-        $this->_width = $width;
61
-    }
28
+	/**
29
+	 * Constructor.
30
+	 *
31
+	 * @param int|string $flags Flags
32
+	 * @param int        $width The number of flags. If width is larger than
33
+	 *                          number of bits in $flags, zeroes are prepended
34
+	 *                          to flag field.
35
+	 */
36
+	public function __construct($flags, int $width)
37
+	{
38
+		if (!$width) {
39
+			$this->_flags = '';
40
+		} else {
41
+			// calculate number of unused bits in last octet
42
+			$last_octet_bits = $width % 8;
43
+			$unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
44
+			$num = gmp_init($flags);
45
+			// mask bits outside bitfield width
46
+			$mask = gmp_sub(gmp_init(1) << $width, 1);
47
+			$num &= $mask;
48
+			// shift towards MSB if needed
49
+			$data = gmp_export($num << $unused_bits, 1,
50
+				GMP_MSW_FIRST | GMP_BIG_ENDIAN);
51
+			$octets = unpack('C*', $data);
52
+			$bits = count($octets) * 8;
53
+			// pad with zeroes
54
+			while ($bits < $width) {
55
+				array_unshift($octets, 0);
56
+				$bits += 8;
57
+			}
58
+			$this->_flags = pack('C*', ...$octets);
59
+		}
60
+		$this->_width = $width;
61
+	}
62 62
 
63
-    /**
64
-     * Initialize from BitString.
65
-     *
66
-     * @param BitString $bs
67
-     * @param int       $width
68
-     *
69
-     * @return self
70
-     */
71
-    public static function fromBitString(BitString $bs, int $width): self
72
-    {
73
-        $num_bits = $bs->numBits();
74
-        $num = gmp_import($bs->string(), 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
75
-        $num >>= $bs->unusedBits();
76
-        if ($num_bits < $width) {
77
-            $num <<= ($width - $num_bits);
78
-        }
79
-        return new self(gmp_strval($num, 10), $width);
80
-    }
63
+	/**
64
+	 * Initialize from BitString.
65
+	 *
66
+	 * @param BitString $bs
67
+	 * @param int       $width
68
+	 *
69
+	 * @return self
70
+	 */
71
+	public static function fromBitString(BitString $bs, int $width): self
72
+	{
73
+		$num_bits = $bs->numBits();
74
+		$num = gmp_import($bs->string(), 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
75
+		$num >>= $bs->unusedBits();
76
+		if ($num_bits < $width) {
77
+			$num <<= ($width - $num_bits);
78
+		}
79
+		return new self(gmp_strval($num, 10), $width);
80
+	}
81 81
 
82
-    /**
83
-     * Check whether a bit at given index is set.
84
-     *
85
-     * Index 0 is the leftmost bit.
86
-     *
87
-     * @param int $idx
88
-     *
89
-     * @throws \OutOfBoundsException
90
-     *
91
-     * @return bool
92
-     */
93
-    public function test(int $idx): bool
94
-    {
95
-        if ($idx >= $this->_width) {
96
-            throw new \OutOfBoundsException('Index is out of bounds.');
97
-        }
98
-        // octet index
99
-        $oi = (int) floor($idx / 8);
100
-        $byte = $this->_flags[$oi];
101
-        // bit index
102
-        $bi = $idx % 8;
103
-        // index 0 is the most significant bit in byte
104
-        $mask = 0x01 << (7 - $bi);
105
-        return (ord($byte) & $mask) > 0;
106
-    }
82
+	/**
83
+	 * Check whether a bit at given index is set.
84
+	 *
85
+	 * Index 0 is the leftmost bit.
86
+	 *
87
+	 * @param int $idx
88
+	 *
89
+	 * @throws \OutOfBoundsException
90
+	 *
91
+	 * @return bool
92
+	 */
93
+	public function test(int $idx): bool
94
+	{
95
+		if ($idx >= $this->_width) {
96
+			throw new \OutOfBoundsException('Index is out of bounds.');
97
+		}
98
+		// octet index
99
+		$oi = (int) floor($idx / 8);
100
+		$byte = $this->_flags[$oi];
101
+		// bit index
102
+		$bi = $idx % 8;
103
+		// index 0 is the most significant bit in byte
104
+		$mask = 0x01 << (7 - $bi);
105
+		return (ord($byte) & $mask) > 0;
106
+	}
107 107
 
108
-    /**
109
-     * Get flags as an octet string.
110
-     *
111
-     * Zeroes are appended to the last octet if width is not divisible by 8.
112
-     *
113
-     * @return string
114
-     */
115
-    public function string(): string
116
-    {
117
-        return $this->_flags;
118
-    }
108
+	/**
109
+	 * Get flags as an octet string.
110
+	 *
111
+	 * Zeroes are appended to the last octet if width is not divisible by 8.
112
+	 *
113
+	 * @return string
114
+	 */
115
+	public function string(): string
116
+	{
117
+		return $this->_flags;
118
+	}
119 119
 
120
-    /**
121
-     * Get flags as a base 10 integer.
122
-     *
123
-     * @return string Integer as a string
124
-     */
125
-    public function number(): string
126
-    {
127
-        $num = gmp_import($this->_flags, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
128
-        $last_octet_bits = $this->_width % 8;
129
-        $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
130
-        $num >>= $unused_bits;
131
-        return gmp_strval($num, 10);
132
-    }
120
+	/**
121
+	 * Get flags as a base 10 integer.
122
+	 *
123
+	 * @return string Integer as a string
124
+	 */
125
+	public function number(): string
126
+	{
127
+		$num = gmp_import($this->_flags, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
128
+		$last_octet_bits = $this->_width % 8;
129
+		$unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
130
+		$num >>= $unused_bits;
131
+		return gmp_strval($num, 10);
132
+	}
133 133
 
134
-    /**
135
-     * Get flags as an integer.
136
-     *
137
-     * @return int
138
-     */
139
-    public function intNumber(): int
140
-    {
141
-        $num = new BigInt($this->number());
142
-        return $num->intVal();
143
-    }
134
+	/**
135
+	 * Get flags as an integer.
136
+	 *
137
+	 * @return int
138
+	 */
139
+	public function intNumber(): int
140
+	{
141
+		$num = new BigInt($this->number());
142
+		return $num->intVal();
143
+	}
144 144
 
145
-    /**
146
-     * Get flags as a BitString.
147
-     *
148
-     * Unused bits are set accordingly. Trailing zeroes are not stripped.
149
-     *
150
-     * @return BitString
151
-     */
152
-    public function bitString(): BitString
153
-    {
154
-        $last_octet_bits = $this->_width % 8;
155
-        $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
156
-        return new BitString($this->_flags, $unused_bits);
157
-    }
145
+	/**
146
+	 * Get flags as a BitString.
147
+	 *
148
+	 * Unused bits are set accordingly. Trailing zeroes are not stripped.
149
+	 *
150
+	 * @return BitString
151
+	 */
152
+	public function bitString(): BitString
153
+	{
154
+		$last_octet_bits = $this->_width % 8;
155
+		$unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0;
156
+		return new BitString($this->_flags, $unused_bits);
157
+	}
158 158
 }
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\Util;
6 6
 
Please login to merge, or discard this patch.
lib/ASN1/Component/Identifier.php 2 patches
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -13,301 +13,301 @@
 block discarded – undo
13 13
  */
14 14
 class Identifier implements Encodable
15 15
 {
16
-    // Type class enumerations
17
-    const CLASS_UNIVERSAL = 0b00;
18
-    const CLASS_APPLICATION = 0b01;
19
-    const CLASS_CONTEXT_SPECIFIC = 0b10;
20
-    const CLASS_PRIVATE = 0b11;
16
+	// Type class enumerations
17
+	const CLASS_UNIVERSAL = 0b00;
18
+	const CLASS_APPLICATION = 0b01;
19
+	const CLASS_CONTEXT_SPECIFIC = 0b10;
20
+	const CLASS_PRIVATE = 0b11;
21 21
 
22
-    /**
23
-     * Mapping from type class to human readable name.
24
-     *
25
-     * @internal
26
-     *
27
-     * @var array
28
-     */
29
-    const MAP_CLASS_TO_NAME = [
30
-        self::CLASS_UNIVERSAL => 'UNIVERSAL',
31
-        self::CLASS_APPLICATION => 'APPLICATION',
32
-        self::CLASS_CONTEXT_SPECIFIC => 'CONTEXT SPECIFIC',
33
-        self::CLASS_PRIVATE => 'PRIVATE',
34
-    ];
22
+	/**
23
+	 * Mapping from type class to human readable name.
24
+	 *
25
+	 * @internal
26
+	 *
27
+	 * @var array
28
+	 */
29
+	const MAP_CLASS_TO_NAME = [
30
+		self::CLASS_UNIVERSAL => 'UNIVERSAL',
31
+		self::CLASS_APPLICATION => 'APPLICATION',
32
+		self::CLASS_CONTEXT_SPECIFIC => 'CONTEXT SPECIFIC',
33
+		self::CLASS_PRIVATE => 'PRIVATE',
34
+	];
35 35
 
36
-    // P/C enumerations
37
-    const PRIMITIVE = 0b0;
38
-    const CONSTRUCTED = 0b1;
36
+	// P/C enumerations
37
+	const PRIMITIVE = 0b0;
38
+	const CONSTRUCTED = 0b1;
39 39
 
40
-    /**
41
-     * Type class.
42
-     *
43
-     * @var int
44
-     */
45
-    private $_class;
40
+	/**
41
+	 * Type class.
42
+	 *
43
+	 * @var int
44
+	 */
45
+	private $_class;
46 46
 
47
-    /**
48
-     * Primitive or Constructed.
49
-     *
50
-     * @var int
51
-     */
52
-    private $_pc;
47
+	/**
48
+	 * Primitive or Constructed.
49
+	 *
50
+	 * @var int
51
+	 */
52
+	private $_pc;
53 53
 
54
-    /**
55
-     * Content type tag.
56
-     *
57
-     * @var BigInt
58
-     */
59
-    private $_tag;
54
+	/**
55
+	 * Content type tag.
56
+	 *
57
+	 * @var BigInt
58
+	 */
59
+	private $_tag;
60 60
 
61
-    /**
62
-     * Constructor.
63
-     *
64
-     * @param int        $class Type class
65
-     * @param int        $pc    Primitive / Constructed
66
-     * @param int|string $tag   Type tag number
67
-     */
68
-    public function __construct(int $class, int $pc, $tag)
69
-    {
70
-        $this->_class = 0b11 & $class;
71
-        $this->_pc = 0b1 & $pc;
72
-        $this->_tag = new BigInt($tag);
73
-    }
61
+	/**
62
+	 * Constructor.
63
+	 *
64
+	 * @param int        $class Type class
65
+	 * @param int        $pc    Primitive / Constructed
66
+	 * @param int|string $tag   Type tag number
67
+	 */
68
+	public function __construct(int $class, int $pc, $tag)
69
+	{
70
+		$this->_class = 0b11 & $class;
71
+		$this->_pc = 0b1 & $pc;
72
+		$this->_tag = new BigInt($tag);
73
+	}
74 74
 
75
-    /**
76
-     * Decode identifier component from DER data.
77
-     *
78
-     * @param string   $data   DER encoded data
79
-     * @param null|int $offset Reference to the variable that contains offset
80
-     *                         into the data where to start parsing.
81
-     *                         Variable is updated to the offset next to the
82
-     *                         parsed identifier. If null, start from offset 0.
83
-     *
84
-     * @throws DecodeException If decoding fails
85
-     *
86
-     * @return self
87
-     */
88
-    public static function fromDER(string $data, int &$offset = null): Identifier
89
-    {
90
-        $idx = $offset ?? 0;
91
-        $datalen = strlen($data);
92
-        if ($idx >= $datalen) {
93
-            throw new DecodeException('Invalid offset.');
94
-        }
95
-        $byte = ord($data[$idx++]);
96
-        // bits 8 and 7 (class)
97
-        // 0 = universal, 1 = application, 2 = context-specific, 3 = private
98
-        $class = (0b11000000 & $byte) >> 6;
99
-        // bit 6 (0 = primitive / 1 = constructed)
100
-        $pc = (0b00100000 & $byte) >> 5;
101
-        // bits 5 to 1 (tag number)
102
-        $tag = (0b00011111 & $byte);
103
-        // long-form identifier
104
-        if (0x1f == $tag) {
105
-            $tag = self::_decodeLongFormTag($data, $idx);
106
-        }
107
-        if (isset($offset)) {
108
-            $offset = $idx;
109
-        }
110
-        return new self($class, $pc, $tag);
111
-    }
75
+	/**
76
+	 * Decode identifier component from DER data.
77
+	 *
78
+	 * @param string   $data   DER encoded data
79
+	 * @param null|int $offset Reference to the variable that contains offset
80
+	 *                         into the data where to start parsing.
81
+	 *                         Variable is updated to the offset next to the
82
+	 *                         parsed identifier. If null, start from offset 0.
83
+	 *
84
+	 * @throws DecodeException If decoding fails
85
+	 *
86
+	 * @return self
87
+	 */
88
+	public static function fromDER(string $data, int &$offset = null): Identifier
89
+	{
90
+		$idx = $offset ?? 0;
91
+		$datalen = strlen($data);
92
+		if ($idx >= $datalen) {
93
+			throw new DecodeException('Invalid offset.');
94
+		}
95
+		$byte = ord($data[$idx++]);
96
+		// bits 8 and 7 (class)
97
+		// 0 = universal, 1 = application, 2 = context-specific, 3 = private
98
+		$class = (0b11000000 & $byte) >> 6;
99
+		// bit 6 (0 = primitive / 1 = constructed)
100
+		$pc = (0b00100000 & $byte) >> 5;
101
+		// bits 5 to 1 (tag number)
102
+		$tag = (0b00011111 & $byte);
103
+		// long-form identifier
104
+		if (0x1f == $tag) {
105
+			$tag = self::_decodeLongFormTag($data, $idx);
106
+		}
107
+		if (isset($offset)) {
108
+			$offset = $idx;
109
+		}
110
+		return new self($class, $pc, $tag);
111
+	}
112 112
 
113
-    /**
114
-     * {@inheritdoc}
115
-     */
116
-    public function toDER(): string
117
-    {
118
-        $bytes = [];
119
-        $byte = $this->_class << 6 | $this->_pc << 5;
120
-        $tag = $this->_tag->gmpObj();
121
-        if ($tag < 0x1f) {
122
-            $bytes[] = $byte | $tag;
123
-        }
124
-        // long-form identifier
125
-        else {
126
-            $bytes[] = $byte | 0x1f;
127
-            $octets = [];
128
-            for (; $tag > 0; $tag >>= 7) {
129
-                array_push($octets, gmp_intval(0x80 | ($tag & 0x7f)));
130
-            }
131
-            // last octet has bit 8 set to zero
132
-            $octets[0] &= 0x7f;
133
-            foreach (array_reverse($octets) as $octet) {
134
-                $bytes[] = $octet;
135
-            }
136
-        }
137
-        return pack('C*', ...$bytes);
138
-    }
113
+	/**
114
+	 * {@inheritdoc}
115
+	 */
116
+	public function toDER(): string
117
+	{
118
+		$bytes = [];
119
+		$byte = $this->_class << 6 | $this->_pc << 5;
120
+		$tag = $this->_tag->gmpObj();
121
+		if ($tag < 0x1f) {
122
+			$bytes[] = $byte | $tag;
123
+		}
124
+		// long-form identifier
125
+		else {
126
+			$bytes[] = $byte | 0x1f;
127
+			$octets = [];
128
+			for (; $tag > 0; $tag >>= 7) {
129
+				array_push($octets, gmp_intval(0x80 | ($tag & 0x7f)));
130
+			}
131
+			// last octet has bit 8 set to zero
132
+			$octets[0] &= 0x7f;
133
+			foreach (array_reverse($octets) as $octet) {
134
+				$bytes[] = $octet;
135
+			}
136
+		}
137
+		return pack('C*', ...$bytes);
138
+	}
139 139
 
140
-    /**
141
-     * Get class of the type.
142
-     *
143
-     * @return int
144
-     */
145
-    public function typeClass(): int
146
-    {
147
-        return $this->_class;
148
-    }
140
+	/**
141
+	 * Get class of the type.
142
+	 *
143
+	 * @return int
144
+	 */
145
+	public function typeClass(): int
146
+	{
147
+		return $this->_class;
148
+	}
149 149
 
150
-    /**
151
-     * Get P/C.
152
-     *
153
-     * @return int
154
-     */
155
-    public function pc(): int
156
-    {
157
-        return $this->_pc;
158
-    }
150
+	/**
151
+	 * Get P/C.
152
+	 *
153
+	 * @return int
154
+	 */
155
+	public function pc(): int
156
+	{
157
+		return $this->_pc;
158
+	}
159 159
 
160
-    /**
161
-     * Get the tag number.
162
-     *
163
-     * @return string Base 10 integer string
164
-     */
165
-    public function tag(): string
166
-    {
167
-        return $this->_tag->base10();
168
-    }
160
+	/**
161
+	 * Get the tag number.
162
+	 *
163
+	 * @return string Base 10 integer string
164
+	 */
165
+	public function tag(): string
166
+	{
167
+		return $this->_tag->base10();
168
+	}
169 169
 
170
-    /**
171
-     * Get the tag as an integer.
172
-     *
173
-     * @return int
174
-     */
175
-    public function intTag(): int
176
-    {
177
-        return $this->_tag->intVal();
178
-    }
170
+	/**
171
+	 * Get the tag as an integer.
172
+	 *
173
+	 * @return int
174
+	 */
175
+	public function intTag(): int
176
+	{
177
+		return $this->_tag->intVal();
178
+	}
179 179
 
180
-    /**
181
-     * Check whether type is of an universal class.
182
-     *
183
-     * @return bool
184
-     */
185
-    public function isUniversal(): bool
186
-    {
187
-        return self::CLASS_UNIVERSAL === $this->_class;
188
-    }
180
+	/**
181
+	 * Check whether type is of an universal class.
182
+	 *
183
+	 * @return bool
184
+	 */
185
+	public function isUniversal(): bool
186
+	{
187
+		return self::CLASS_UNIVERSAL === $this->_class;
188
+	}
189 189
 
190
-    /**
191
-     * Check whether type is of an application class.
192
-     *
193
-     * @return bool
194
-     */
195
-    public function isApplication(): bool
196
-    {
197
-        return self::CLASS_APPLICATION === $this->_class;
198
-    }
190
+	/**
191
+	 * Check whether type is of an application class.
192
+	 *
193
+	 * @return bool
194
+	 */
195
+	public function isApplication(): bool
196
+	{
197
+		return self::CLASS_APPLICATION === $this->_class;
198
+	}
199 199
 
200
-    /**
201
-     * Check whether type is of a context specific class.
202
-     *
203
-     * @return bool
204
-     */
205
-    public function isContextSpecific(): bool
206
-    {
207
-        return self::CLASS_CONTEXT_SPECIFIC === $this->_class;
208
-    }
200
+	/**
201
+	 * Check whether type is of a context specific class.
202
+	 *
203
+	 * @return bool
204
+	 */
205
+	public function isContextSpecific(): bool
206
+	{
207
+		return self::CLASS_CONTEXT_SPECIFIC === $this->_class;
208
+	}
209 209
 
210
-    /**
211
-     * Check whether type is of a private class.
212
-     *
213
-     * @return bool
214
-     */
215
-    public function isPrivate(): bool
216
-    {
217
-        return self::CLASS_PRIVATE === $this->_class;
218
-    }
210
+	/**
211
+	 * Check whether type is of a private class.
212
+	 *
213
+	 * @return bool
214
+	 */
215
+	public function isPrivate(): bool
216
+	{
217
+		return self::CLASS_PRIVATE === $this->_class;
218
+	}
219 219
 
220
-    /**
221
-     * Check whether content is primitive type.
222
-     *
223
-     * @return bool
224
-     */
225
-    public function isPrimitive(): bool
226
-    {
227
-        return self::PRIMITIVE === $this->_pc;
228
-    }
220
+	/**
221
+	 * Check whether content is primitive type.
222
+	 *
223
+	 * @return bool
224
+	 */
225
+	public function isPrimitive(): bool
226
+	{
227
+		return self::PRIMITIVE === $this->_pc;
228
+	}
229 229
 
230
-    /**
231
-     * Check hether content is constructed type.
232
-     *
233
-     * @return bool
234
-     */
235
-    public function isConstructed(): bool
236
-    {
237
-        return self::CONSTRUCTED === $this->_pc;
238
-    }
230
+	/**
231
+	 * Check hether content is constructed type.
232
+	 *
233
+	 * @return bool
234
+	 */
235
+	public function isConstructed(): bool
236
+	{
237
+		return self::CONSTRUCTED === $this->_pc;
238
+	}
239 239
 
240
-    /**
241
-     * Get self with given type class.
242
-     *
243
-     * @param int $class One of <code>CLASS_*</code> enumerations
244
-     *
245
-     * @return self
246
-     */
247
-    public function withClass(int $class): Identifier
248
-    {
249
-        $obj = clone $this;
250
-        $obj->_class = 0b11 & $class;
251
-        return $obj;
252
-    }
240
+	/**
241
+	 * Get self with given type class.
242
+	 *
243
+	 * @param int $class One of <code>CLASS_*</code> enumerations
244
+	 *
245
+	 * @return self
246
+	 */
247
+	public function withClass(int $class): Identifier
248
+	{
249
+		$obj = clone $this;
250
+		$obj->_class = 0b11 & $class;
251
+		return $obj;
252
+	}
253 253
 
254
-    /**
255
-     * Get self with given type tag.
256
-     *
257
-     * @param int|string $tag Tag number
258
-     *
259
-     * @return self
260
-     */
261
-    public function withTag($tag): Identifier
262
-    {
263
-        $obj = clone $this;
264
-        $obj->_tag = new BigInt($tag);
265
-        return $obj;
266
-    }
254
+	/**
255
+	 * Get self with given type tag.
256
+	 *
257
+	 * @param int|string $tag Tag number
258
+	 *
259
+	 * @return self
260
+	 */
261
+	public function withTag($tag): Identifier
262
+	{
263
+		$obj = clone $this;
264
+		$obj->_tag = new BigInt($tag);
265
+		return $obj;
266
+	}
267 267
 
268
-    /**
269
-     * Get human readable name of the type class.
270
-     *
271
-     * @param int $class
272
-     *
273
-     * @return string
274
-     */
275
-    public static function classToName(int $class): string
276
-    {
277
-        if (!array_key_exists($class, self::MAP_CLASS_TO_NAME)) {
278
-            return "CLASS ${class}";
279
-        }
280
-        return self::MAP_CLASS_TO_NAME[$class];
281
-    }
268
+	/**
269
+	 * Get human readable name of the type class.
270
+	 *
271
+	 * @param int $class
272
+	 *
273
+	 * @return string
274
+	 */
275
+	public static function classToName(int $class): string
276
+	{
277
+		if (!array_key_exists($class, self::MAP_CLASS_TO_NAME)) {
278
+			return "CLASS ${class}";
279
+		}
280
+		return self::MAP_CLASS_TO_NAME[$class];
281
+	}
282 282
 
283
-    /**
284
-     * Parse long form tag.
285
-     *
286
-     * @param string $data   DER data
287
-     * @param int    $offset Reference to the variable containing offset to data
288
-     *
289
-     * @throws DecodeException If decoding fails
290
-     *
291
-     * @return string Tag number
292
-     */
293
-    private static function _decodeLongFormTag(string $data, int &$offset): string
294
-    {
295
-        $datalen = strlen($data);
296
-        $tag = gmp_init(0, 10);
297
-        while (true) {
298
-            if ($offset >= $datalen) {
299
-                throw new DecodeException(
300
-                    'Unexpected end of data while decoding' .
301
-                    ' long form identifier.');
302
-            }
303
-            $byte = ord($data[$offset++]);
304
-            $tag <<= 7;
305
-            $tag |= 0x7f & $byte;
306
-            // last byte has bit 8 set to zero
307
-            if (!(0x80 & $byte)) {
308
-                break;
309
-            }
310
-        }
311
-        return gmp_strval($tag, 10);
312
-    }
283
+	/**
284
+	 * Parse long form tag.
285
+	 *
286
+	 * @param string $data   DER data
287
+	 * @param int    $offset Reference to the variable containing offset to data
288
+	 *
289
+	 * @throws DecodeException If decoding fails
290
+	 *
291
+	 * @return string Tag number
292
+	 */
293
+	private static function _decodeLongFormTag(string $data, int &$offset): string
294
+	{
295
+		$datalen = strlen($data);
296
+		$tag = gmp_init(0, 10);
297
+		while (true) {
298
+			if ($offset >= $datalen) {
299
+				throw new DecodeException(
300
+					'Unexpected end of data while decoding' .
301
+					' long form identifier.');
302
+			}
303
+			$byte = ord($data[$offset++]);
304
+			$tag <<= 7;
305
+			$tag |= 0x7f & $byte;
306
+			// last byte has bit 8 set to zero
307
+			if (!(0x80 & $byte)) {
308
+				break;
309
+			}
310
+		}
311
+		return gmp_strval($tag, 10);
312
+	}
313 313
 }
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\Component;
6 6
 
Please login to merge, or discard this patch.