@@ -13,13 +13,13 @@ |
||
13 | 13 | */ |
14 | 14 | interface ImplicitTagging extends ElementBase |
15 | 15 | { |
16 | - /** |
|
17 | - * Get implicitly tagged wrapped element. |
|
18 | - * |
|
19 | - * @param int $tag Tag of the element |
|
20 | - * @param int $class Expected type class of the element |
|
21 | - * @throws \UnexpectedValueException If expectation fails |
|
22 | - * @return \ASN1\Type\UnspecifiedType |
|
23 | - */ |
|
24 | - public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType; |
|
16 | + /** |
|
17 | + * Get implicitly tagged wrapped element. |
|
18 | + * |
|
19 | + * @param int $tag Tag of the element |
|
20 | + * @param int $class Expected type class of the element |
|
21 | + * @throws \UnexpectedValueException If expectation fails |
|
22 | + * @return \ASN1\Type\UnspecifiedType |
|
23 | + */ |
|
24 | + public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType; |
|
25 | 25 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -17,58 +17,58 @@ |
||
17 | 17 | */ |
18 | 18 | class ImplicitlyTaggedType extends TaggedTypeWrap implements ImplicitTagging |
19 | 19 | { |
20 | - /** |
|
21 | - * Constructor. |
|
22 | - * |
|
23 | - * @param int $tag Tag number |
|
24 | - * @param Element $element Wrapped element |
|
25 | - * @param int $class Type class |
|
26 | - */ |
|
27 | - public function __construct(int $tag, Element $element, |
|
28 | - int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
29 | - { |
|
30 | - $this->_typeTag = $tag; |
|
31 | - $this->_element = $element; |
|
32 | - $this->_class = $class; |
|
33 | - } |
|
20 | + /** |
|
21 | + * Constructor. |
|
22 | + * |
|
23 | + * @param int $tag Tag number |
|
24 | + * @param Element $element Wrapped element |
|
25 | + * @param int $class Type class |
|
26 | + */ |
|
27 | + public function __construct(int $tag, Element $element, |
|
28 | + int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
29 | + { |
|
30 | + $this->_typeTag = $tag; |
|
31 | + $this->_element = $element; |
|
32 | + $this->_class = $class; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * |
|
37 | - * @see \ASN1\Element::isConstructed() |
|
38 | - * @return bool |
|
39 | - */ |
|
40 | - public function isConstructed(): bool |
|
41 | - { |
|
42 | - // depends on the underlying type |
|
43 | - return $this->_element->isConstructed(); |
|
44 | - } |
|
35 | + /** |
|
36 | + * |
|
37 | + * @see \ASN1\Element::isConstructed() |
|
38 | + * @return bool |
|
39 | + */ |
|
40 | + public function isConstructed(): bool |
|
41 | + { |
|
42 | + // depends on the underlying type |
|
43 | + return $this->_element->isConstructed(); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * |
|
48 | - * @see \ASN1\Element::_encodedContentDER() |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - protected function _encodedContentDER(): string |
|
52 | - { |
|
53 | - // get only the content of the wrapped element. |
|
54 | - return $this->_element->_encodedContentDER(); |
|
55 | - } |
|
46 | + /** |
|
47 | + * |
|
48 | + * @see \ASN1\Element::_encodedContentDER() |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + protected function _encodedContentDER(): string |
|
52 | + { |
|
53 | + // get only the content of the wrapped element. |
|
54 | + return $this->_element->_encodedContentDER(); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * |
|
59 | - * {@inheritdoc} |
|
60 | - * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
61 | - * @return UnspecifiedType |
|
62 | - */ |
|
63 | - public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
64 | - { |
|
65 | - $this->_element->expectType($tag); |
|
66 | - if ($this->_element->typeClass() != $class) { |
|
67 | - throw new \UnexpectedValueException( |
|
68 | - sprintf("Type class %s expected, got %s.", |
|
69 | - Identifier::classToName($class), |
|
70 | - Identifier::classToName($this->_element->typeClass()))); |
|
71 | - } |
|
72 | - return $this->_element->asUnspecified(); |
|
73 | - } |
|
57 | + /** |
|
58 | + * |
|
59 | + * {@inheritdoc} |
|
60 | + * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
61 | + * @return UnspecifiedType |
|
62 | + */ |
|
63 | + public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
64 | + { |
|
65 | + $this->_element->expectType($tag); |
|
66 | + if ($this->_element->typeClass() != $class) { |
|
67 | + throw new \UnexpectedValueException( |
|
68 | + sprintf("Type class %s expected, got %s.", |
|
69 | + Identifier::classToName($class), |
|
70 | + Identifier::classToName($this->_element->typeClass()))); |
|
71 | + } |
|
72 | + return $this->_element->asUnspecified(); |
|
73 | + } |
|
74 | 74 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -16,53 +16,53 @@ |
||
16 | 16 | */ |
17 | 17 | class ExplicitlyTaggedType extends TaggedTypeWrap implements ExplicitTagging |
18 | 18 | { |
19 | - /** |
|
20 | - * Constructor. |
|
21 | - * |
|
22 | - * @param int $tag Tag number |
|
23 | - * @param Element $element Wrapped element |
|
24 | - * @param int $class Type class |
|
25 | - */ |
|
26 | - public function __construct(int $tag, Element $element, |
|
27 | - int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
28 | - { |
|
29 | - $this->_typeTag = $tag; |
|
30 | - $this->_element = $element; |
|
31 | - $this->_class = $class; |
|
32 | - } |
|
19 | + /** |
|
20 | + * Constructor. |
|
21 | + * |
|
22 | + * @param int $tag Tag number |
|
23 | + * @param Element $element Wrapped element |
|
24 | + * @param int $class Type class |
|
25 | + */ |
|
26 | + public function __construct(int $tag, Element $element, |
|
27 | + int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
28 | + { |
|
29 | + $this->_typeTag = $tag; |
|
30 | + $this->_element = $element; |
|
31 | + $this->_class = $class; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * |
|
36 | - * @see \ASN1\Element::isConstructed() |
|
37 | - * @return bool |
|
38 | - */ |
|
39 | - public function isConstructed(): bool |
|
40 | - { |
|
41 | - return true; |
|
42 | - } |
|
34 | + /** |
|
35 | + * |
|
36 | + * @see \ASN1\Element::isConstructed() |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | + public function isConstructed(): bool |
|
40 | + { |
|
41 | + return true; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * |
|
46 | - * @see \ASN1\Element::_encodedContentDER() |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - protected function _encodedContentDER(): string |
|
50 | - { |
|
51 | - // get the full encoding of the wrapped element |
|
52 | - return $this->_element->toDER(); |
|
53 | - } |
|
44 | + /** |
|
45 | + * |
|
46 | + * @see \ASN1\Element::_encodedContentDER() |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + protected function _encodedContentDER(): string |
|
50 | + { |
|
51 | + // get the full encoding of the wrapped element |
|
52 | + return $this->_element->toDER(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * |
|
57 | - * {@inheritdoc} |
|
58 | - * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
59 | - * @return UnspecifiedType |
|
60 | - */ |
|
61 | - public function explicit($expectedTag = null): UnspecifiedType |
|
62 | - { |
|
63 | - if (isset($expectedTag)) { |
|
64 | - $this->_element->expectType($expectedTag); |
|
65 | - } |
|
66 | - return $this->_element->asUnspecified(); |
|
67 | - } |
|
55 | + /** |
|
56 | + * |
|
57 | + * {@inheritdoc} |
|
58 | + * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
59 | + * @return UnspecifiedType |
|
60 | + */ |
|
61 | + public function explicit($expectedTag = null): UnspecifiedType |
|
62 | + { |
|
63 | + if (isset($expectedTag)) { |
|
64 | + $this->_element->expectType($expectedTag); |
|
65 | + } |
|
66 | + return $this->_element->asUnspecified(); |
|
67 | + } |
|
68 | 68 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -11,27 +11,27 @@ |
||
11 | 11 | */ |
12 | 12 | abstract class TaggedTypeWrap extends TaggedType |
13 | 13 | { |
14 | - /** |
|
15 | - * Wrapped element. |
|
16 | - * |
|
17 | - * @var \ASN1\Element $_element |
|
18 | - */ |
|
19 | - protected $_element; |
|
14 | + /** |
|
15 | + * Wrapped element. |
|
16 | + * |
|
17 | + * @var \ASN1\Element $_element |
|
18 | + */ |
|
19 | + protected $_element; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Type class. |
|
23 | - * |
|
24 | - * @var int |
|
25 | - */ |
|
26 | - protected $_class; |
|
21 | + /** |
|
22 | + * Type class. |
|
23 | + * |
|
24 | + * @var int |
|
25 | + */ |
|
26 | + protected $_class; |
|
27 | 27 | |
28 | - /** |
|
29 | - * |
|
30 | - * @see \ASN1\Element::typeClass() |
|
31 | - * @return int |
|
32 | - */ |
|
33 | - public function typeClass(): int |
|
34 | - { |
|
35 | - return $this->_class; |
|
36 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * @see \ASN1\Element::typeClass() |
|
31 | + * @return int |
|
32 | + */ |
|
33 | + public function typeClass(): int |
|
34 | + { |
|
35 | + return $this->_class; |
|
36 | + } |
|
37 | 37 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -12,15 +12,15 @@ |
||
12 | 12 | */ |
13 | 13 | interface ExplicitTagging extends ElementBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Get explicitly tagged wrapped element. |
|
17 | - * |
|
18 | - * <strong>NOTE!</strong> Expectation checking is deprecated and shall be |
|
19 | - * done with <code>UnspecifiedType</code>. |
|
20 | - * |
|
21 | - * @param int|null $expectedTag Expected tag of the underlying type |
|
22 | - * @throws \UnexpectedValueException If expectation fails |
|
23 | - * @return \ASN1\Type\UnspecifiedType |
|
24 | - */ |
|
25 | - public function explicit($expectedTag = null): UnspecifiedType; |
|
15 | + /** |
|
16 | + * Get explicitly tagged wrapped element. |
|
17 | + * |
|
18 | + * <strong>NOTE!</strong> Expectation checking is deprecated and shall be |
|
19 | + * done with <code>UnspecifiedType</code>. |
|
20 | + * |
|
21 | + * @param int|null $expectedTag Expected tag of the underlying type |
|
22 | + * @throws \UnexpectedValueException If expectation fails |
|
23 | + * @return \ASN1\Type\UnspecifiedType |
|
24 | + */ |
|
25 | + public function explicit($expectedTag = null): UnspecifiedType; |
|
26 | 26 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -12,25 +12,25 @@ |
||
12 | 12 | */ |
13 | 13 | class IA5String 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_IA5_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_IA5_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('/[^\x01-\x7f]/', $string) == 0; |
|
35 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * {@inheritdoc} |
|
31 | + */ |
|
32 | + protected function _validateString(string $string): bool |
|
33 | + { |
|
34 | + return preg_match('/[^\x01-\x7f]/', $string) == 0; |
|
35 | + } |
|
36 | 36 | } |
@@ -1,6 +1,6 @@ |
||
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 |
@@ -9,13 +9,13 @@ |
||
9 | 9 | */ |
10 | 10 | trait PrimitiveType |
11 | 11 | { |
12 | - /** |
|
13 | - * |
|
14 | - * @see \ASN1\Element::isConstructed() |
|
15 | - * @return bool |
|
16 | - */ |
|
17 | - public function isConstructed(): bool |
|
18 | - { |
|
19 | - return false; |
|
20 | - } |
|
12 | + /** |
|
13 | + * |
|
14 | + * @see \ASN1\Element::isConstructed() |
|
15 | + * @return bool |
|
16 | + */ |
|
17 | + public function isConstructed(): bool |
|
18 | + { |
|
19 | + return false; |
|
20 | + } |
|
21 | 21 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type; |
6 | 6 |
@@ -12,14 +12,14 @@ |
||
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 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Constructed; |
6 | 6 |
@@ -12,54 +12,54 @@ |
||
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 | - * Used for DER encoding of SET type. |
|
29 | - * |
|
30 | - * @return self |
|
31 | - */ |
|
32 | - public function sortedSet(): self |
|
33 | - { |
|
34 | - $obj = clone $this; |
|
35 | - usort($obj->_elements, |
|
36 | - function (Element $a, Element $b) { |
|
37 | - if ($a->typeClass() != $b->typeClass()) { |
|
38 | - return $a->typeClass() < $b->typeClass() ? -1 : 1; |
|
39 | - } |
|
40 | - if ($a->tag() == $b->tag()) { |
|
41 | - return 0; |
|
42 | - } |
|
43 | - return $a->tag() < $b->tag() ? -1 : 1; |
|
44 | - }); |
|
45 | - return $obj; |
|
46 | - } |
|
26 | + /** |
|
27 | + * Sort by canonical ascending order. |
|
28 | + * Used for DER encoding of SET type. |
|
29 | + * |
|
30 | + * @return self |
|
31 | + */ |
|
32 | + public function sortedSet(): self |
|
33 | + { |
|
34 | + $obj = clone $this; |
|
35 | + usort($obj->_elements, |
|
36 | + function (Element $a, Element $b) { |
|
37 | + if ($a->typeClass() != $b->typeClass()) { |
|
38 | + return $a->typeClass() < $b->typeClass() ? -1 : 1; |
|
39 | + } |
|
40 | + if ($a->tag() == $b->tag()) { |
|
41 | + return 0; |
|
42 | + } |
|
43 | + return $a->tag() < $b->tag() ? -1 : 1; |
|
44 | + }); |
|
45 | + return $obj; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Sort by encoding ascending order. |
|
50 | - * Used for DER encoding of SET OF type. |
|
51 | - * |
|
52 | - * @return self |
|
53 | - */ |
|
54 | - public function sortedSetOf(): self |
|
55 | - { |
|
56 | - $obj = clone $this; |
|
57 | - usort($obj->_elements, |
|
58 | - function (Element $a, Element $b) { |
|
59 | - $a_der = $a->toDER(); |
|
60 | - $b_der = $b->toDER(); |
|
61 | - return strcmp($a_der, $b_der); |
|
62 | - }); |
|
63 | - return $obj; |
|
64 | - } |
|
48 | + /** |
|
49 | + * Sort by encoding ascending order. |
|
50 | + * Used for DER encoding of SET OF type. |
|
51 | + * |
|
52 | + * @return self |
|
53 | + */ |
|
54 | + public function sortedSetOf(): self |
|
55 | + { |
|
56 | + $obj = clone $this; |
|
57 | + usort($obj->_elements, |
|
58 | + function (Element $a, Element $b) { |
|
59 | + $a_der = $a->toDER(); |
|
60 | + $b_der = $b->toDER(); |
|
61 | + return strcmp($a_der, $b_der); |
|
62 | + }); |
|
63 | + return $obj; |
|
64 | + } |
|
65 | 65 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Constructed; |
6 | 6 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | $obj = clone $this; |
35 | 35 | usort($obj->_elements, |
36 | - function (Element $a, Element $b) { |
|
36 | + function(Element $a, Element $b) { |
|
37 | 37 | if ($a->typeClass() != $b->typeClass()) { |
38 | 38 | return $a->typeClass() < $b->typeClass() ? -1 : 1; |
39 | 39 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $obj = clone $this; |
57 | 57 | usort($obj->_elements, |
58 | - function (Element $a, Element $b) { |
|
58 | + function(Element $a, Element $b) { |
|
59 | 59 | $a_der = $a->toDER(); |
60 | 60 | $b_der = $b->toDER(); |
61 | 61 | return strcmp($a_der, $b_der); |