@@ -7,14 +7,14 @@ |
||
7 | 7 | */ |
8 | 8 | class Enumerated extends Integer |
9 | 9 | { |
10 | - /** |
|
11 | - * Constructor. |
|
12 | - * |
|
13 | - * @param int|string $number |
|
14 | - */ |
|
15 | - public function __construct($number) |
|
16 | - { |
|
17 | - parent::__construct($number); |
|
18 | - $this->_typeTag = self::TYPE_ENUMERATED; |
|
19 | - } |
|
10 | + /** |
|
11 | + * Constructor. |
|
12 | + * |
|
13 | + * @param int|string $number |
|
14 | + */ |
|
15 | + public function __construct($number) |
|
16 | + { |
|
17 | + parent::__construct($number); |
|
18 | + $this->_typeTag = self::TYPE_ENUMERATED; |
|
19 | + } |
|
20 | 20 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $obj = clone $this; |
33 | 33 | usort($obj->_elements, |
34 | - function (Element $a, Element $b) { |
|
34 | + function(Element $a, Element $b) { |
|
35 | 35 | if ($a->typeClass() != $b->typeClass()) { |
36 | 36 | return $a->typeClass() < $b->typeClass() ? -1 : 1; |
37 | 37 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $obj = clone $this; |
55 | 55 | usort($obj->_elements, |
56 | - function (Element $a, Element $b) { |
|
56 | + function(Element $a, Element $b) { |
|
57 | 57 | $a_der = $a->toDER(); |
58 | 58 | $b_der = $b->toDER(); |
59 | 59 | return strcmp($a_der, $b_der); |
@@ -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 | } |
@@ -9,10 +9,10 @@ |
||
9 | 9 | */ |
10 | 10 | interface Encodable |
11 | 11 | { |
12 | - /** |
|
13 | - * Encode object to DER. |
|
14 | - * |
|
15 | - * @return string |
|
16 | - */ |
|
17 | - public function toDER(): string; |
|
12 | + /** |
|
13 | + * Encode object to DER. |
|
14 | + * |
|
15 | + * @return string |
|
16 | + */ |
|
17 | + public function toDER(): string; |
|
18 | 18 | } |
@@ -11,13 +11,13 @@ |
||
11 | 11 | */ |
12 | 12 | trait UniversalClass |
13 | 13 | { |
14 | - /** |
|
15 | - * |
|
16 | - * @see \ASN1\Element::typeClass() |
|
17 | - * @return int |
|
18 | - */ |
|
19 | - public function typeClass(): int |
|
20 | - { |
|
21 | - return Identifier::CLASS_UNIVERSAL; |
|
22 | - } |
|
14 | + /** |
|
15 | + * |
|
16 | + * @see \ASN1\Element::typeClass() |
|
17 | + * @return int |
|
18 | + */ |
|
19 | + public function typeClass(): int |
|
20 | + { |
|
21 | + return Identifier::CLASS_UNIVERSAL; |
|
22 | + } |
|
23 | 23 | } |
@@ -12,26 +12,26 @@ |
||
12 | 12 | */ |
13 | 13 | class GeneralString 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_GENERAL_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_GENERAL_STRING; |
|
25 | + parent::__construct($string); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * |
|
30 | - * {@inheritdoc} |
|
31 | - */ |
|
32 | - protected function _validateString(string $string): bool |
|
33 | - { |
|
34 | - // allow everything |
|
35 | - return true; |
|
36 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * {@inheritdoc} |
|
31 | + */ |
|
32 | + protected function _validateString(string $string): bool |
|
33 | + { |
|
34 | + // allow everything |
|
35 | + return true; |
|
36 | + } |
|
37 | 37 | } |
@@ -12,16 +12,16 @@ |
||
12 | 12 | */ |
13 | 13 | class OctetString extends PrimitiveString |
14 | 14 | { |
15 | - use UniversalClass; |
|
15 | + use UniversalClass; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Constructor. |
|
19 | - * |
|
20 | - * @param string $string |
|
21 | - */ |
|
22 | - public function __construct(string $string) |
|
23 | - { |
|
24 | - $this->_typeTag = self::TYPE_OCTET_STRING; |
|
25 | - parent::__construct($string); |
|
26 | - } |
|
17 | + /** |
|
18 | + * Constructor. |
|
19 | + * |
|
20 | + * @param string $string |
|
21 | + */ |
|
22 | + public function __construct(string $string) |
|
23 | + { |
|
24 | + $this->_typeTag = self::TYPE_OCTET_STRING; |
|
25 | + parent::__construct($string); |
|
26 | + } |
|
27 | 27 | } |
@@ -12,26 +12,26 @@ |
||
12 | 12 | */ |
13 | 13 | class PrintableString 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_PRINTABLE_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_PRINTABLE_STRING; |
|
25 | + parent::__construct($string); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * |
|
30 | - * {@inheritdoc} |
|
31 | - */ |
|
32 | - protected function _validateString(string $string): bool |
|
33 | - { |
|
34 | - $chars = preg_quote(" '()+,-./:=?]", "/"); |
|
35 | - return preg_match('/[^A-Za-z0-9' . $chars . ']/', $string) == 0; |
|
36 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * {@inheritdoc} |
|
31 | + */ |
|
32 | + protected function _validateString(string $string): bool |
|
33 | + { |
|
34 | + $chars = preg_quote(" '()+,-./:=?]", "/"); |
|
35 | + return preg_match('/[^A-Za-z0-9' . $chars . ']/', $string) == 0; |
|
36 | + } |
|
37 | 37 | } |
@@ -12,26 +12,26 @@ |
||
12 | 12 | */ |
13 | 13 | class VideotexString 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_VIDEOTEX_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_VIDEOTEX_STRING; |
|
25 | + parent::__construct($string); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * |
|
30 | - * {@inheritdoc} |
|
31 | - */ |
|
32 | - protected function _validateString(string $string): bool |
|
33 | - { |
|
34 | - // allow everything |
|
35 | - return true; |
|
36 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * {@inheritdoc} |
|
31 | + */ |
|
32 | + protected function _validateString(string $string): bool |
|
33 | + { |
|
34 | + // allow everything |
|
35 | + return true; |
|
36 | + } |
|
37 | 37 | } |
@@ -9,16 +9,16 @@ |
||
9 | 9 | |
10 | 10 | class CharacterString extends PrimitiveString |
11 | 11 | { |
12 | - use UniversalClass; |
|
12 | + use UniversalClass; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Constructor. |
|
16 | - * |
|
17 | - * @param string $string |
|
18 | - */ |
|
19 | - public function __construct(string $string) |
|
20 | - { |
|
21 | - $this->_typeTag = self::TYPE_CHARACTER_STRING; |
|
22 | - parent::__construct($string); |
|
23 | - } |
|
14 | + /** |
|
15 | + * Constructor. |
|
16 | + * |
|
17 | + * @param string $string |
|
18 | + */ |
|
19 | + public function __construct(string $string) |
|
20 | + { |
|
21 | + $this->_typeTag = self::TYPE_CHARACTER_STRING; |
|
22 | + parent::__construct($string); |
|
23 | + } |
|
24 | 24 | } |