@@ -12,24 +12,24 @@ |
||
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 | - * {@inheritdoc} |
|
30 | - */ |
|
31 | - protected function _validateString(string $string): bool |
|
32 | - { |
|
33 | - return 0 == preg_match('/[^0-9 ]/', $string); |
|
34 | - } |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | + protected function _validateString(string $string): bool |
|
32 | + { |
|
33 | + return 0 == preg_match('/[^0-9 ]/', $string); |
|
34 | + } |
|
35 | 35 | } |
@@ -1,6 +1,6 @@ |
||
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 |
@@ -12,24 +12,24 @@ |
||
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 | - * {@inheritdoc} |
|
30 | - */ |
|
31 | - protected function _validateString(string $string): bool |
|
32 | - { |
|
33 | - return 0 == preg_match('/[^\x01-\x7f]/', $string); |
|
34 | - } |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | + protected function _validateString(string $string): bool |
|
32 | + { |
|
33 | + return 0 == preg_match('/[^\x01-\x7f]/', $string); |
|
34 | + } |
|
35 | 35 | } |
@@ -1,6 +1,6 @@ |
||
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 |
@@ -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 Sop\ASN1\Type\Primitive; |
6 | 6 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | protected static function _implodeSubIDs(\GMP ...$subids): string |
146 | 146 | { |
147 | 147 | return implode('.', |
148 | - array_map(function ($num) { |
|
148 | + array_map(function($num) { |
|
149 | 149 | return gmp_strval($num, 10); |
150 | 150 | }, $subids)); |
151 | 151 | } |
@@ -17,199 +17,199 @@ |
||
17 | 17 | */ |
18 | 18 | class ObjectIdentifier extends Element |
19 | 19 | { |
20 | - use UniversalClass; |
|
21 | - use PrimitiveType; |
|
20 | + use UniversalClass; |
|
21 | + use PrimitiveType; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Object identifier in dotted format. |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $_oid; |
|
23 | + /** |
|
24 | + * Object identifier in dotted format. |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $_oid; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Object identifier split to sub ID's. |
|
32 | - * |
|
33 | - * @var \GMP[] |
|
34 | - */ |
|
35 | - protected $_subids; |
|
30 | + /** |
|
31 | + * Object identifier split to sub ID's. |
|
32 | + * |
|
33 | + * @var \GMP[] |
|
34 | + */ |
|
35 | + protected $_subids; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor. |
|
39 | - * |
|
40 | - * @param string $oid OID in dotted format |
|
41 | - */ |
|
42 | - public function __construct(string $oid) |
|
43 | - { |
|
44 | - $this->_oid = $oid; |
|
45 | - $this->_subids = self::_explodeDottedOID($oid); |
|
46 | - // if OID is non-empty |
|
47 | - if (count($this->_subids) > 0) { |
|
48 | - // check that at least two nodes are set |
|
49 | - if (count($this->_subids) < 2) { |
|
50 | - throw new \UnexpectedValueException( |
|
51 | - 'OID must have at least two nodes.'); |
|
52 | - } |
|
53 | - // check that root arc is in 0..2 range |
|
54 | - if ($this->_subids[0] > 2) { |
|
55 | - throw new \UnexpectedValueException( |
|
56 | - 'Root arc must be in range of 0..2.'); |
|
57 | - } |
|
58 | - // if root arc is 0 or 1, second node must be in 0..39 range |
|
59 | - if ($this->_subids[0] < 2 && $this->_subids[1] >= 40) { |
|
60 | - throw new \UnexpectedValueException( |
|
61 | - 'Second node must be in 0..39 range for root arcs 0 and 1.'); |
|
62 | - } |
|
63 | - } |
|
64 | - $this->_typeTag = self::TYPE_OBJECT_IDENTIFIER; |
|
65 | - } |
|
37 | + /** |
|
38 | + * Constructor. |
|
39 | + * |
|
40 | + * @param string $oid OID in dotted format |
|
41 | + */ |
|
42 | + public function __construct(string $oid) |
|
43 | + { |
|
44 | + $this->_oid = $oid; |
|
45 | + $this->_subids = self::_explodeDottedOID($oid); |
|
46 | + // if OID is non-empty |
|
47 | + if (count($this->_subids) > 0) { |
|
48 | + // check that at least two nodes are set |
|
49 | + if (count($this->_subids) < 2) { |
|
50 | + throw new \UnexpectedValueException( |
|
51 | + 'OID must have at least two nodes.'); |
|
52 | + } |
|
53 | + // check that root arc is in 0..2 range |
|
54 | + if ($this->_subids[0] > 2) { |
|
55 | + throw new \UnexpectedValueException( |
|
56 | + 'Root arc must be in range of 0..2.'); |
|
57 | + } |
|
58 | + // if root arc is 0 or 1, second node must be in 0..39 range |
|
59 | + if ($this->_subids[0] < 2 && $this->_subids[1] >= 40) { |
|
60 | + throw new \UnexpectedValueException( |
|
61 | + 'Second node must be in 0..39 range for root arcs 0 and 1.'); |
|
62 | + } |
|
63 | + } |
|
64 | + $this->_typeTag = self::TYPE_OBJECT_IDENTIFIER; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Get OID in dotted format. |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function oid(): string |
|
73 | - { |
|
74 | - return $this->_oid; |
|
75 | - } |
|
67 | + /** |
|
68 | + * Get OID in dotted format. |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function oid(): string |
|
73 | + { |
|
74 | + return $this->_oid; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * {@inheritdoc} |
|
79 | - */ |
|
80 | - protected function _encodedContentDER(): string |
|
81 | - { |
|
82 | - $subids = $this->_subids; |
|
83 | - // encode first two subids to one according to spec section 8.19.4 |
|
84 | - if (count($subids) >= 2) { |
|
85 | - $num = ($subids[0] * 40) + $subids[1]; |
|
86 | - array_splice($subids, 0, 2, [$num]); |
|
87 | - } |
|
88 | - return self::_encodeSubIDs(...$subids); |
|
89 | - } |
|
77 | + /** |
|
78 | + * {@inheritdoc} |
|
79 | + */ |
|
80 | + protected function _encodedContentDER(): string |
|
81 | + { |
|
82 | + $subids = $this->_subids; |
|
83 | + // encode first two subids to one according to spec section 8.19.4 |
|
84 | + if (count($subids) >= 2) { |
|
85 | + $num = ($subids[0] * 40) + $subids[1]; |
|
86 | + array_splice($subids, 0, 2, [$num]); |
|
87 | + } |
|
88 | + return self::_encodeSubIDs(...$subids); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * {@inheritdoc} |
|
93 | - */ |
|
94 | - protected static function _decodeFromDER(Identifier $identifier, |
|
95 | - string $data, int &$offset): ElementBase |
|
96 | - { |
|
97 | - $idx = $offset; |
|
98 | - $len = Length::expectFromDER($data, $idx)->intLength(); |
|
99 | - $subids = self::_decodeSubIDs(substr($data, $idx, $len)); |
|
100 | - $idx += $len; |
|
101 | - // decode first subidentifier according to spec section 8.19.4 |
|
102 | - if (isset($subids[0])) { |
|
103 | - if ($subids[0] < 80) { |
|
104 | - [$x, $y] = gmp_div_qr($subids[0], '40'); |
|
105 | - } else { |
|
106 | - $x = gmp_init(2, 10); |
|
107 | - $y = $subids[0] - 80; |
|
108 | - } |
|
109 | - array_splice($subids, 0, 1, [$x, $y]); |
|
110 | - } |
|
111 | - $offset = $idx; |
|
112 | - return new self(self::_implodeSubIDs(...$subids)); |
|
113 | - } |
|
91 | + /** |
|
92 | + * {@inheritdoc} |
|
93 | + */ |
|
94 | + protected static function _decodeFromDER(Identifier $identifier, |
|
95 | + string $data, int &$offset): ElementBase |
|
96 | + { |
|
97 | + $idx = $offset; |
|
98 | + $len = Length::expectFromDER($data, $idx)->intLength(); |
|
99 | + $subids = self::_decodeSubIDs(substr($data, $idx, $len)); |
|
100 | + $idx += $len; |
|
101 | + // decode first subidentifier according to spec section 8.19.4 |
|
102 | + if (isset($subids[0])) { |
|
103 | + if ($subids[0] < 80) { |
|
104 | + [$x, $y] = gmp_div_qr($subids[0], '40'); |
|
105 | + } else { |
|
106 | + $x = gmp_init(2, 10); |
|
107 | + $y = $subids[0] - 80; |
|
108 | + } |
|
109 | + array_splice($subids, 0, 1, [$x, $y]); |
|
110 | + } |
|
111 | + $offset = $idx; |
|
112 | + return new self(self::_implodeSubIDs(...$subids)); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Explode dotted OID to an array of sub ID's. |
|
117 | - * |
|
118 | - * @param string $oid OID in dotted format |
|
119 | - * |
|
120 | - * @return \GMP[] Array of GMP numbers |
|
121 | - */ |
|
122 | - protected static function _explodeDottedOID(string $oid): array |
|
123 | - { |
|
124 | - $subids = []; |
|
125 | - if (strlen($oid)) { |
|
126 | - foreach (explode('.', $oid) as $subid) { |
|
127 | - $n = @gmp_init($subid, 10); |
|
128 | - if (false === $n) { |
|
129 | - throw new \UnexpectedValueException( |
|
130 | - "'{$subid}' is not a number."); |
|
131 | - } |
|
132 | - $subids[] = $n; |
|
133 | - } |
|
134 | - } |
|
135 | - return $subids; |
|
136 | - } |
|
115 | + /** |
|
116 | + * Explode dotted OID to an array of sub ID's. |
|
117 | + * |
|
118 | + * @param string $oid OID in dotted format |
|
119 | + * |
|
120 | + * @return \GMP[] Array of GMP numbers |
|
121 | + */ |
|
122 | + protected static function _explodeDottedOID(string $oid): array |
|
123 | + { |
|
124 | + $subids = []; |
|
125 | + if (strlen($oid)) { |
|
126 | + foreach (explode('.', $oid) as $subid) { |
|
127 | + $n = @gmp_init($subid, 10); |
|
128 | + if (false === $n) { |
|
129 | + throw new \UnexpectedValueException( |
|
130 | + "'{$subid}' is not a number."); |
|
131 | + } |
|
132 | + $subids[] = $n; |
|
133 | + } |
|
134 | + } |
|
135 | + return $subids; |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Implode an array of sub IDs to dotted OID format. |
|
140 | - * |
|
141 | - * @param \GMP ...$subids |
|
142 | - * |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - protected static function _implodeSubIDs(\GMP ...$subids): string |
|
146 | - { |
|
147 | - return implode('.', |
|
148 | - array_map(function ($num) { |
|
149 | - return gmp_strval($num, 10); |
|
150 | - }, $subids)); |
|
151 | - } |
|
138 | + /** |
|
139 | + * Implode an array of sub IDs to dotted OID format. |
|
140 | + * |
|
141 | + * @param \GMP ...$subids |
|
142 | + * |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + protected static function _implodeSubIDs(\GMP ...$subids): string |
|
146 | + { |
|
147 | + return implode('.', |
|
148 | + array_map(function ($num) { |
|
149 | + return gmp_strval($num, 10); |
|
150 | + }, $subids)); |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * Encode sub ID's to DER. |
|
155 | - * |
|
156 | - * @param \GMP ...$subids |
|
157 | - * |
|
158 | - * @return string |
|
159 | - */ |
|
160 | - protected static function _encodeSubIDs(\GMP ...$subids): string |
|
161 | - { |
|
162 | - $data = ''; |
|
163 | - foreach ($subids as $subid) { |
|
164 | - // if number fits to one base 128 byte |
|
165 | - if ($subid < 128) { |
|
166 | - $data .= chr(intval($subid)); |
|
167 | - } else { // encode to multiple bytes |
|
168 | - $bytes = []; |
|
169 | - do { |
|
170 | - array_unshift($bytes, 0x7f & gmp_intval($subid)); |
|
171 | - $subid >>= 7; |
|
172 | - } while ($subid > 0); |
|
173 | - // all bytes except last must have bit 8 set to one |
|
174 | - foreach (array_splice($bytes, 0, -1) as $byte) { |
|
175 | - $data .= chr(0x80 | $byte); |
|
176 | - } |
|
177 | - $data .= chr(reset($bytes)); |
|
178 | - } |
|
179 | - } |
|
180 | - return $data; |
|
181 | - } |
|
153 | + /** |
|
154 | + * Encode sub ID's to DER. |
|
155 | + * |
|
156 | + * @param \GMP ...$subids |
|
157 | + * |
|
158 | + * @return string |
|
159 | + */ |
|
160 | + protected static function _encodeSubIDs(\GMP ...$subids): string |
|
161 | + { |
|
162 | + $data = ''; |
|
163 | + foreach ($subids as $subid) { |
|
164 | + // if number fits to one base 128 byte |
|
165 | + if ($subid < 128) { |
|
166 | + $data .= chr(intval($subid)); |
|
167 | + } else { // encode to multiple bytes |
|
168 | + $bytes = []; |
|
169 | + do { |
|
170 | + array_unshift($bytes, 0x7f & gmp_intval($subid)); |
|
171 | + $subid >>= 7; |
|
172 | + } while ($subid > 0); |
|
173 | + // all bytes except last must have bit 8 set to one |
|
174 | + foreach (array_splice($bytes, 0, -1) as $byte) { |
|
175 | + $data .= chr(0x80 | $byte); |
|
176 | + } |
|
177 | + $data .= chr(reset($bytes)); |
|
178 | + } |
|
179 | + } |
|
180 | + return $data; |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Decode sub ID's from DER data. |
|
185 | - * |
|
186 | - * @param string $data |
|
187 | - * |
|
188 | - * @throws DecodeException |
|
189 | - * |
|
190 | - * @return \GMP[] Array of GMP numbers |
|
191 | - */ |
|
192 | - protected static function _decodeSubIDs(string $data): array |
|
193 | - { |
|
194 | - $subids = []; |
|
195 | - $idx = 0; |
|
196 | - $end = strlen($data); |
|
197 | - while ($idx < $end) { |
|
198 | - $num = gmp_init('0', 10); |
|
199 | - while (true) { |
|
200 | - if ($idx >= $end) { |
|
201 | - throw new DecodeException('Unexpected end of data.'); |
|
202 | - } |
|
203 | - $byte = ord($data[$idx++]); |
|
204 | - $num |= $byte & 0x7f; |
|
205 | - // bit 8 of the last octet is zero |
|
206 | - if (!($byte & 0x80)) { |
|
207 | - break; |
|
208 | - } |
|
209 | - $num <<= 7; |
|
210 | - } |
|
211 | - $subids[] = $num; |
|
212 | - } |
|
213 | - return $subids; |
|
214 | - } |
|
183 | + /** |
|
184 | + * Decode sub ID's from DER data. |
|
185 | + * |
|
186 | + * @param string $data |
|
187 | + * |
|
188 | + * @throws DecodeException |
|
189 | + * |
|
190 | + * @return \GMP[] Array of GMP numbers |
|
191 | + */ |
|
192 | + protected static function _decodeSubIDs(string $data): array |
|
193 | + { |
|
194 | + $subids = []; |
|
195 | + $idx = 0; |
|
196 | + $end = strlen($data); |
|
197 | + while ($idx < $end) { |
|
198 | + $num = gmp_init('0', 10); |
|
199 | + while (true) { |
|
200 | + if ($idx >= $end) { |
|
201 | + throw new DecodeException('Unexpected end of data.'); |
|
202 | + } |
|
203 | + $byte = ord($data[$idx++]); |
|
204 | + $num |= $byte & 0x7f; |
|
205 | + // bit 8 of the last octet is zero |
|
206 | + if (!($byte & 0x80)) { |
|
207 | + break; |
|
208 | + } |
|
209 | + $num <<= 7; |
|
210 | + } |
|
211 | + $subids[] = $num; |
|
212 | + } |
|
213 | + return $subids; |
|
214 | + } |
|
215 | 215 | } |
@@ -12,25 +12,25 @@ |
||
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 | - * {@inheritdoc} |
|
30 | - */ |
|
31 | - protected function _validateString(string $string): bool |
|
32 | - { |
|
33 | - $chars = preg_quote(" '()+,-./:=?]", '/'); |
|
34 | - return 0 == preg_match('/[^A-Za-z0-9' . $chars . ']/', $string); |
|
35 | - } |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | + protected function _validateString(string $string): bool |
|
32 | + { |
|
33 | + $chars = preg_quote(" '()+,-./:=?]", '/'); |
|
34 | + return 0 == preg_match('/[^A-Za-z0-9' . $chars . ']/', $string); |
|
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 Sop\ASN1\Type\Primitive; |
6 | 6 |
@@ -12,24 +12,24 @@ |
||
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 | - * {@inheritdoc} |
|
30 | - */ |
|
31 | - protected function _validateString(string $string): bool |
|
32 | - { |
|
33 | - return 0 == preg_match('/[^\x20-\x7e]/', $string); |
|
34 | - } |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | + protected function _validateString(string $string): bool |
|
32 | + { |
|
33 | + return 0 == preg_match('/[^\x20-\x7e]/', $string); |
|
34 | + } |
|
35 | 35 | } |
@@ -1,6 +1,6 @@ |
||
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 |
@@ -17,38 +17,38 @@ |
||
17 | 17 | */ |
18 | 18 | class EOC extends Element |
19 | 19 | { |
20 | - use UniversalClass; |
|
21 | - use PrimitiveType; |
|
20 | + use UniversalClass; |
|
21 | + use PrimitiveType; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Constructor. |
|
25 | - */ |
|
26 | - public function __construct() |
|
27 | - { |
|
28 | - $this->_typeTag = self::TYPE_EOC; |
|
29 | - } |
|
23 | + /** |
|
24 | + * Constructor. |
|
25 | + */ |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + $this->_typeTag = self::TYPE_EOC; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * {@inheritdoc} |
|
33 | - */ |
|
34 | - protected function _encodedContentDER(): string |
|
35 | - { |
|
36 | - return ''; |
|
37 | - } |
|
31 | + /** |
|
32 | + * {@inheritdoc} |
|
33 | + */ |
|
34 | + protected function _encodedContentDER(): string |
|
35 | + { |
|
36 | + return ''; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * {@inheritdoc} |
|
41 | - */ |
|
42 | - protected static function _decodeFromDER(Identifier $identifier, |
|
43 | - string $data, int &$offset): ElementBase |
|
44 | - { |
|
45 | - $idx = $offset; |
|
46 | - if (!$identifier->isPrimitive()) { |
|
47 | - throw new DecodeException('EOC value must be primitive.'); |
|
48 | - } |
|
49 | - // EOC type has always zero length |
|
50 | - Length::expectFromDER($data, $idx, 0); |
|
51 | - $offset = $idx; |
|
52 | - return new self(); |
|
53 | - } |
|
39 | + /** |
|
40 | + * {@inheritdoc} |
|
41 | + */ |
|
42 | + protected static function _decodeFromDER(Identifier $identifier, |
|
43 | + string $data, int &$offset): ElementBase |
|
44 | + { |
|
45 | + $idx = $offset; |
|
46 | + if (!$identifier->isPrimitive()) { |
|
47 | + throw new DecodeException('EOC value must be primitive.'); |
|
48 | + } |
|
49 | + // EOC type has always zero length |
|
50 | + Length::expectFromDER($data, $idx, 0); |
|
51 | + $offset = $idx; |
|
52 | + return new self(); |
|
53 | + } |
|
54 | 54 | } |
@@ -1,6 +1,6 @@ |
||
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 |
@@ -12,25 +12,25 @@ |
||
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 | - * {@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 | } |
@@ -1,6 +1,6 @@ |
||
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 |
@@ -15,28 +15,28 @@ |
||
15 | 15 | */ |
16 | 16 | class BMPString extends PrimitiveString |
17 | 17 | { |
18 | - use UniversalClass; |
|
18 | + use UniversalClass; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Constructor. |
|
22 | - * |
|
23 | - * @param string $string |
|
24 | - */ |
|
25 | - public function __construct(string $string) |
|
26 | - { |
|
27 | - $this->_typeTag = self::TYPE_BMP_STRING; |
|
28 | - parent::__construct($string); |
|
29 | - } |
|
20 | + /** |
|
21 | + * Constructor. |
|
22 | + * |
|
23 | + * @param string $string |
|
24 | + */ |
|
25 | + public function __construct(string $string) |
|
26 | + { |
|
27 | + $this->_typeTag = self::TYPE_BMP_STRING; |
|
28 | + parent::__construct($string); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * {@inheritdoc} |
|
33 | - */ |
|
34 | - protected function _validateString(string $string): bool |
|
35 | - { |
|
36 | - // UCS-2 has fixed with of 2 octets (16 bits) |
|
37 | - if (0 !== strlen($string) % 2) { |
|
38 | - return false; |
|
39 | - } |
|
40 | - return true; |
|
41 | - } |
|
31 | + /** |
|
32 | + * {@inheritdoc} |
|
33 | + */ |
|
34 | + protected function _validateString(string $string): bool |
|
35 | + { |
|
36 | + // UCS-2 has fixed with of 2 octets (16 bits) |
|
37 | + if (0 !== strlen($string) % 2) { |
|
38 | + return false; |
|
39 | + } |
|
40 | + return true; |
|
41 | + } |
|
42 | 42 | } |
@@ -1,6 +1,6 @@ |
||
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 |
@@ -13,36 +13,36 @@ |
||
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 | } |
@@ -1,6 +1,6 @@ |
||
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 |