@@ -12,27 +12,27 @@ |
||
12 | 12 | */ |
13 | 13 | class T61String extends PrimitiveString |
14 | 14 | { |
15 | - use UniversalClass; |
|
15 | + use UniversalClass; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Constructor. |
|
19 | - * |
|
20 | - * @param string $string |
|
21 | - */ |
|
22 | - public function __construct(string $string) |
|
23 | - { |
|
24 | - $this->_typeTag = self::TYPE_T61_STRING; |
|
25 | - parent::__construct($string); |
|
26 | - } |
|
17 | + /** |
|
18 | + * Constructor. |
|
19 | + * |
|
20 | + * @param string $string |
|
21 | + */ |
|
22 | + public function __construct(string $string) |
|
23 | + { |
|
24 | + $this->_typeTag = self::TYPE_T61_STRING; |
|
25 | + parent::__construct($string); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * |
|
30 | - * {@inheritdoc} |
|
31 | - */ |
|
32 | - protected function _validateString(string $string): bool |
|
33 | - { |
|
34 | - // allow everything since there's literally |
|
35 | - // thousands of allowed characters (16 bit composed characters) |
|
36 | - return true; |
|
37 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * {@inheritdoc} |
|
31 | + */ |
|
32 | + protected function _validateString(string $string): bool |
|
33 | + { |
|
34 | + // allow everything since there's literally |
|
35 | + // thousands of allowed characters (16 bit composed characters) |
|
36 | + return true; |
|
37 | + } |
|
38 | 38 | } |
@@ -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 |
@@ -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 |
@@ -12,25 +12,25 @@ |
||
12 | 12 | */ |
13 | 13 | class VisibleString extends PrimitiveString |
14 | 14 | { |
15 | - use UniversalClass; |
|
15 | + use UniversalClass; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Constructor. |
|
19 | - * |
|
20 | - * @param string $string |
|
21 | - */ |
|
22 | - public function __construct(string $string) |
|
23 | - { |
|
24 | - $this->_typeTag = self::TYPE_VISIBLE_STRING; |
|
25 | - parent::__construct($string); |
|
26 | - } |
|
17 | + /** |
|
18 | + * Constructor. |
|
19 | + * |
|
20 | + * @param string $string |
|
21 | + */ |
|
22 | + public function __construct(string $string) |
|
23 | + { |
|
24 | + $this->_typeTag = self::TYPE_VISIBLE_STRING; |
|
25 | + parent::__construct($string); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * |
|
30 | - * {@inheritdoc} |
|
31 | - */ |
|
32 | - protected function _validateString(string $string): bool |
|
33 | - { |
|
34 | - return preg_match('/[^\x20-\x7e]/', $string) == 0; |
|
35 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * {@inheritdoc} |
|
31 | + */ |
|
32 | + protected function _validateString(string $string): bool |
|
33 | + { |
|
34 | + return preg_match('/[^\x20-\x7e]/', $string) == 0; |
|
35 | + } |
|
36 | 36 | } |
@@ -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 |
@@ -12,26 +12,26 @@ |
||
12 | 12 | */ |
13 | 13 | class ObjectDescriptor extends PrimitiveString |
14 | 14 | { |
15 | - use UniversalClass; |
|
15 | + use UniversalClass; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Constructor. |
|
19 | - * |
|
20 | - * @param string $descriptor |
|
21 | - */ |
|
22 | - public function __construct(string $descriptor) |
|
23 | - { |
|
24 | - $this->_string = $descriptor; |
|
25 | - $this->_typeTag = self::TYPE_OBJECT_DESCRIPTOR; |
|
26 | - } |
|
17 | + /** |
|
18 | + * Constructor. |
|
19 | + * |
|
20 | + * @param string $descriptor |
|
21 | + */ |
|
22 | + public function __construct(string $descriptor) |
|
23 | + { |
|
24 | + $this->_string = $descriptor; |
|
25 | + $this->_typeTag = self::TYPE_OBJECT_DESCRIPTOR; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Get the object descriptor. |
|
30 | - * |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function descriptor(): string |
|
34 | - { |
|
35 | - return $this->_string; |
|
36 | - } |
|
28 | + /** |
|
29 | + * Get the object descriptor. |
|
30 | + * |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function descriptor(): string |
|
34 | + { |
|
35 | + return $this->_string; |
|
36 | + } |
|
37 | 37 | } |
@@ -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 |
@@ -12,25 +12,25 @@ |
||
12 | 12 | */ |
13 | 13 | class NumericString extends PrimitiveString |
14 | 14 | { |
15 | - use UniversalClass; |
|
15 | + use UniversalClass; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Constructor. |
|
19 | - * |
|
20 | - * @param string $string |
|
21 | - */ |
|
22 | - public function __construct(string $string) |
|
23 | - { |
|
24 | - $this->_typeTag = self::TYPE_NUMERIC_STRING; |
|
25 | - parent::__construct($string); |
|
26 | - } |
|
17 | + /** |
|
18 | + * Constructor. |
|
19 | + * |
|
20 | + * @param string $string |
|
21 | + */ |
|
22 | + public function __construct(string $string) |
|
23 | + { |
|
24 | + $this->_typeTag = self::TYPE_NUMERIC_STRING; |
|
25 | + parent::__construct($string); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * |
|
30 | - * {@inheritdoc} |
|
31 | - */ |
|
32 | - protected function _validateString(string $string): bool |
|
33 | - { |
|
34 | - return preg_match('/[^0-9 ]/', $string) == 0; |
|
35 | - } |
|
28 | + /** |
|
29 | + * |
|
30 | + * {@inheritdoc} |
|
31 | + */ |
|
32 | + protected function _validateString(string $string): bool |
|
33 | + { |
|
34 | + return preg_match('/[^0-9 ]/', $string) == 0; |
|
35 | + } |
|
36 | 36 | } |
@@ -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 |
@@ -12,38 +12,38 @@ |
||
12 | 12 | */ |
13 | 13 | class RelativeOID extends ObjectIdentifier |
14 | 14 | { |
15 | - /** |
|
16 | - * Constructor. |
|
17 | - * |
|
18 | - * @param string $oid OID in dotted format |
|
19 | - */ |
|
20 | - public function __construct(string $oid) |
|
21 | - { |
|
22 | - $this->_oid = $oid; |
|
23 | - $this->_typeTag = self::TYPE_RELATIVE_OID; |
|
24 | - } |
|
15 | + /** |
|
16 | + * Constructor. |
|
17 | + * |
|
18 | + * @param string $oid OID in dotted format |
|
19 | + */ |
|
20 | + public function __construct(string $oid) |
|
21 | + { |
|
22 | + $this->_oid = $oid; |
|
23 | + $this->_typeTag = self::TYPE_RELATIVE_OID; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * |
|
28 | - * {@inheritdoc} |
|
29 | - */ |
|
30 | - protected function _encodedContentDER(): string |
|
31 | - { |
|
32 | - return self::_encodeSubIDs(...self::_explodeDottedOID($this->_oid)); |
|
33 | - } |
|
26 | + /** |
|
27 | + * |
|
28 | + * {@inheritdoc} |
|
29 | + */ |
|
30 | + protected function _encodedContentDER(): string |
|
31 | + { |
|
32 | + return self::_encodeSubIDs(...self::_explodeDottedOID($this->_oid)); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * |
|
37 | - * {@inheritdoc} |
|
38 | - * @return self |
|
39 | - */ |
|
40 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
41 | - int &$offset) |
|
42 | - { |
|
43 | - $idx = $offset; |
|
44 | - $len = Length::expectFromDER($data, $idx)->length(); |
|
45 | - $subids = self::_decodeSubIDs(substr($data, $idx, $len)); |
|
46 | - $offset = $idx + $len; |
|
47 | - return new self(self::_implodeSubIDs(...$subids)); |
|
48 | - } |
|
35 | + /** |
|
36 | + * |
|
37 | + * {@inheritdoc} |
|
38 | + * @return self |
|
39 | + */ |
|
40 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
41 | + int &$offset) |
|
42 | + { |
|
43 | + $idx = $offset; |
|
44 | + $len = Length::expectFromDER($data, $idx)->length(); |
|
45 | + $subids = self::_decodeSubIDs(substr($data, $idx, $len)); |
|
46 | + $offset = $idx + $len; |
|
47 | + return new self(self::_implodeSubIDs(...$subids)); |
|
48 | + } |
|
49 | 49 | } |
@@ -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\Primitive; |
6 | 6 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @return self |
39 | 39 | */ |
40 | 40 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
41 | - int &$offset) |
|
41 | + int & $offset) |
|
42 | 42 | { |
43 | 43 | $idx = $offset; |
44 | 44 | $len = Length::expectFromDER($data, $idx)->length(); |
@@ -16,72 +16,72 @@ |
||
16 | 16 | */ |
17 | 17 | class UTCTime extends TimeType |
18 | 18 | { |
19 | - use UniversalClass; |
|
20 | - use PrimitiveType; |
|
19 | + use UniversalClass; |
|
20 | + use PrimitiveType; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Regular expression to parse date. |
|
24 | - * |
|
25 | - * DER restricts format to UTC timezone (Z suffix). |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - const REGEX = /* @formatter:off */ '#^' . |
|
30 | - '(\d\d)' . /* YY */ |
|
31 | - '(\d\d)' . /* MM */ |
|
32 | - '(\d\d)' . /* DD */ |
|
33 | - '(\d\d)' . /* hh */ |
|
34 | - '(\d\d)' . /* mm */ |
|
35 | - '(\d\d)' . /* ss */ |
|
36 | - 'Z' . /* TZ */ |
|
37 | - '$#' /* @formatter:on */; |
|
22 | + /** |
|
23 | + * Regular expression to parse date. |
|
24 | + * |
|
25 | + * DER restricts format to UTC timezone (Z suffix). |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + const REGEX = /* @formatter:off */ '#^' . |
|
30 | + '(\d\d)' . /* YY */ |
|
31 | + '(\d\d)' . /* MM */ |
|
32 | + '(\d\d)' . /* DD */ |
|
33 | + '(\d\d)' . /* hh */ |
|
34 | + '(\d\d)' . /* mm */ |
|
35 | + '(\d\d)' . /* ss */ |
|
36 | + 'Z' . /* TZ */ |
|
37 | + '$#' /* @formatter:on */; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. |
|
41 | - * |
|
42 | - * @param \DateTimeImmutable $dt |
|
43 | - */ |
|
44 | - public function __construct(\DateTimeImmutable $dt) |
|
45 | - { |
|
46 | - $this->_typeTag = self::TYPE_UTC_TIME; |
|
47 | - parent::__construct($dt); |
|
48 | - } |
|
39 | + /** |
|
40 | + * Constructor. |
|
41 | + * |
|
42 | + * @param \DateTimeImmutable $dt |
|
43 | + */ |
|
44 | + public function __construct(\DateTimeImmutable $dt) |
|
45 | + { |
|
46 | + $this->_typeTag = self::TYPE_UTC_TIME; |
|
47 | + parent::__construct($dt); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * |
|
52 | - * {@inheritdoc} |
|
53 | - */ |
|
54 | - protected function _encodedContentDER(): string |
|
55 | - { |
|
56 | - $dt = $this->_dateTime->setTimezone(self::_createTimeZone(self::TZ_UTC)); |
|
57 | - return $dt->format("ymdHis\Z"); |
|
58 | - } |
|
50 | + /** |
|
51 | + * |
|
52 | + * {@inheritdoc} |
|
53 | + */ |
|
54 | + protected function _encodedContentDER(): string |
|
55 | + { |
|
56 | + $dt = $this->_dateTime->setTimezone(self::_createTimeZone(self::TZ_UTC)); |
|
57 | + return $dt->format("ymdHis\Z"); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * |
|
62 | - * {@inheritdoc} |
|
63 | - * @return self |
|
64 | - */ |
|
65 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
66 | - int &$offset) |
|
67 | - { |
|
68 | - $idx = $offset; |
|
69 | - $length = Length::expectFromDER($data, $idx); |
|
70 | - $str = substr($data, $idx, $length->length()); |
|
71 | - $idx += $length->length(); |
|
72 | - if (!preg_match(self::REGEX, $str, $match)) { |
|
73 | - throw new DecodeException("Invalid UTCTime format."); |
|
74 | - } |
|
75 | - list(, $year, $month, $day, $hour, $minute, $second) = $match; |
|
76 | - $time = $year . $month . $day . $hour . $minute . $second . self::TZ_UTC; |
|
77 | - $dt = \DateTimeImmutable::createFromFormat("!ymdHisT", $time, |
|
78 | - self::_createTimeZone(self::TZ_UTC)); |
|
79 | - if (!$dt) { |
|
80 | - throw new DecodeException( |
|
81 | - "Failed to decode UTCTime: " . |
|
82 | - self::_getLastDateTimeImmutableErrorsStr()); |
|
83 | - } |
|
84 | - $offset = $idx; |
|
85 | - return new self($dt); |
|
86 | - } |
|
60 | + /** |
|
61 | + * |
|
62 | + * {@inheritdoc} |
|
63 | + * @return self |
|
64 | + */ |
|
65 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
66 | + int &$offset) |
|
67 | + { |
|
68 | + $idx = $offset; |
|
69 | + $length = Length::expectFromDER($data, $idx); |
|
70 | + $str = substr($data, $idx, $length->length()); |
|
71 | + $idx += $length->length(); |
|
72 | + if (!preg_match(self::REGEX, $str, $match)) { |
|
73 | + throw new DecodeException("Invalid UTCTime format."); |
|
74 | + } |
|
75 | + list(, $year, $month, $day, $hour, $minute, $second) = $match; |
|
76 | + $time = $year . $month . $day . $hour . $minute . $second . self::TZ_UTC; |
|
77 | + $dt = \DateTimeImmutable::createFromFormat("!ymdHisT", $time, |
|
78 | + self::_createTimeZone(self::TZ_UTC)); |
|
79 | + if (!$dt) { |
|
80 | + throw new DecodeException( |
|
81 | + "Failed to decode UTCTime: " . |
|
82 | + self::_getLastDateTimeImmutableErrorsStr()); |
|
83 | + } |
|
84 | + $offset = $idx; |
|
85 | + return new self($dt); |
|
86 | + } |
|
87 | 87 | } |
@@ -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\Primitive; |
6 | 6 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return self |
179 | 179 | */ |
180 | 180 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
181 | - int &$offset) |
|
181 | + int & $offset) |
|
182 | 182 | { |
183 | 183 | $idx = $offset; |
184 | 184 | $length = Length::expectFromDER($data, $idx); |
@@ -17,613 +17,613 @@ |
||
17 | 17 | */ |
18 | 18 | class UnspecifiedType implements ElementBase |
19 | 19 | { |
20 | - /** |
|
21 | - * The wrapped element. |
|
22 | - * |
|
23 | - * @var Element |
|
24 | - */ |
|
25 | - private $_element; |
|
26 | - |
|
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param Element $el |
|
31 | - */ |
|
32 | - public function __construct(Element $el) |
|
33 | - { |
|
34 | - $this->_element = $el; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Initialize from ElementBase interface. |
|
39 | - * |
|
40 | - * @param ElementBase $el |
|
41 | - * @return self |
|
42 | - */ |
|
43 | - public static function fromElementBase(ElementBase $el) |
|
44 | - { |
|
45 | - // if element is already wrapped |
|
46 | - if ($el instanceof self) { |
|
47 | - return $el; |
|
48 | - } |
|
49 | - return new self($el->asElement()); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Compatibility method to dispatch calls to the wrapped element. |
|
54 | - * |
|
55 | - * @deprecated Use <code>as*</code> accessor methods to ensure strict type |
|
56 | - * @param string $mtd Method name |
|
57 | - * @param array $args Arguments |
|
58 | - * @return mixed |
|
59 | - */ |
|
60 | - public function __call($mtd, array $args) |
|
61 | - { |
|
62 | - return call_user_func_array([$this->_element, $mtd], $args); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Get the wrapped element as a context specific tagged type. |
|
67 | - * |
|
68 | - * @throws \UnexpectedValueException If the element is not tagged |
|
69 | - * @return TaggedType |
|
70 | - */ |
|
71 | - public function asTagged(): TaggedType |
|
72 | - { |
|
73 | - if (!$this->_element instanceof TaggedType) { |
|
74 | - throw new \UnexpectedValueException( |
|
75 | - "Tagged element expected, got " . $this->_typeDescriptorString()); |
|
76 | - } |
|
77 | - return $this->_element; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Get the wrapped element as a boolean type. |
|
82 | - * |
|
83 | - * @throws \UnexpectedValueException If the element is not a boolean |
|
84 | - * @return Primitive\Boolean |
|
85 | - */ |
|
86 | - public function asBoolean(): Primitive\Boolean |
|
87 | - { |
|
88 | - if (!$this->_element instanceof Primitive\Boolean) { |
|
89 | - throw new \UnexpectedValueException( |
|
90 | - $this->_generateExceptionMessage(Element::TYPE_BOOLEAN)); |
|
91 | - } |
|
92 | - return $this->_element; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Get the wrapped element as an integer type. |
|
97 | - * |
|
98 | - * @throws \UnexpectedValueException If the element is not an integer |
|
99 | - * @return Primitive\Integer |
|
100 | - */ |
|
101 | - public function asInteger(): Primitive\Integer |
|
102 | - { |
|
103 | - if (!$this->_element instanceof Primitive\Integer) { |
|
104 | - throw new \UnexpectedValueException( |
|
105 | - $this->_generateExceptionMessage(Element::TYPE_INTEGER)); |
|
106 | - } |
|
107 | - return $this->_element; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Get the wrapped element as a bit string type. |
|
112 | - * |
|
113 | - * @throws \UnexpectedValueException If the element is not a bit string |
|
114 | - * @return Primitive\BitString |
|
115 | - */ |
|
116 | - public function asBitString(): Primitive\BitString |
|
117 | - { |
|
118 | - if (!$this->_element instanceof Primitive\BitString) { |
|
119 | - throw new \UnexpectedValueException( |
|
120 | - $this->_generateExceptionMessage(Element::TYPE_BIT_STRING)); |
|
121 | - } |
|
122 | - return $this->_element; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Get the wrapped element as an octet string type. |
|
127 | - * |
|
128 | - * @throws \UnexpectedValueException If the element is not an octet string |
|
129 | - * @return Primitive\OctetString |
|
130 | - */ |
|
131 | - public function asOctetString(): Primitive\OctetString |
|
132 | - { |
|
133 | - if (!$this->_element instanceof Primitive\OctetString) { |
|
134 | - throw new \UnexpectedValueException( |
|
135 | - $this->_generateExceptionMessage(Element::TYPE_OCTET_STRING)); |
|
136 | - } |
|
137 | - return $this->_element; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Get the wrapped element as a null type. |
|
142 | - * |
|
143 | - * @throws \UnexpectedValueException If the element is not a null |
|
144 | - * @return Primitive\NullType |
|
145 | - */ |
|
146 | - public function asNull(): Primitive\NullType |
|
147 | - { |
|
148 | - if (!$this->_element instanceof Primitive\NullType) { |
|
149 | - throw new \UnexpectedValueException( |
|
150 | - $this->_generateExceptionMessage(Element::TYPE_NULL)); |
|
151 | - } |
|
152 | - return $this->_element; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Get the wrapped element as an object identifier type. |
|
157 | - * |
|
158 | - * @throws \UnexpectedValueException If the element is not an object |
|
159 | - * identifier |
|
160 | - * @return Primitive\ObjectIdentifier |
|
161 | - */ |
|
162 | - public function asObjectIdentifier(): Primitive\ObjectIdentifier |
|
163 | - { |
|
164 | - if (!$this->_element instanceof Primitive\ObjectIdentifier) { |
|
165 | - throw new \UnexpectedValueException( |
|
166 | - $this->_generateExceptionMessage( |
|
167 | - Element::TYPE_OBJECT_IDENTIFIER)); |
|
168 | - } |
|
169 | - return $this->_element; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Get the wrapped element as an object descriptor type. |
|
174 | - * |
|
175 | - * @throws \UnexpectedValueException If the element is not an object |
|
176 | - * descriptor |
|
177 | - * @return Primitive\ObjectDescriptor |
|
178 | - */ |
|
179 | - public function asObjectDescriptor(): Primitive\ObjectDescriptor |
|
180 | - { |
|
181 | - if (!$this->_element instanceof Primitive\ObjectDescriptor) { |
|
182 | - throw new \UnexpectedValueException( |
|
183 | - $this->_generateExceptionMessage( |
|
184 | - Element::TYPE_OBJECT_DESCRIPTOR)); |
|
185 | - } |
|
186 | - return $this->_element; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Get the wrapped element as a real type. |
|
191 | - * |
|
192 | - * @throws \UnexpectedValueException If the element is not a real |
|
193 | - * @return Primitive\Real |
|
194 | - */ |
|
195 | - public function asReal(): Primitive\Real |
|
196 | - { |
|
197 | - if (!$this->_element instanceof Primitive\Real) { |
|
198 | - throw new \UnexpectedValueException( |
|
199 | - $this->_generateExceptionMessage(Element::TYPE_REAL)); |
|
200 | - } |
|
201 | - return $this->_element; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Get the wrapped element as an enumerated type. |
|
206 | - * |
|
207 | - * @throws \UnexpectedValueException If the element is not an enumerated |
|
208 | - * @return Primitive\Enumerated |
|
209 | - */ |
|
210 | - public function asEnumerated(): Primitive\Enumerated |
|
211 | - { |
|
212 | - if (!$this->_element instanceof Primitive\Enumerated) { |
|
213 | - throw new \UnexpectedValueException( |
|
214 | - $this->_generateExceptionMessage(Element::TYPE_ENUMERATED)); |
|
215 | - } |
|
216 | - return $this->_element; |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * Get the wrapped element as a UTF8 string type. |
|
221 | - * |
|
222 | - * @throws \UnexpectedValueException If the element is not a UTF8 string |
|
223 | - * @return Primitive\UTF8String |
|
224 | - */ |
|
225 | - public function asUTF8String(): Primitive\UTF8String |
|
226 | - { |
|
227 | - if (!$this->_element instanceof Primitive\UTF8String) { |
|
228 | - throw new \UnexpectedValueException( |
|
229 | - $this->_generateExceptionMessage(Element::TYPE_UTF8_STRING)); |
|
230 | - } |
|
231 | - return $this->_element; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * Get the wrapped element as a relative OID type. |
|
236 | - * |
|
237 | - * @throws \UnexpectedValueException If the element is not a relative OID |
|
238 | - * @return Primitive\RelativeOID |
|
239 | - */ |
|
240 | - public function asRelativeOID(): Primitive\RelativeOID |
|
241 | - { |
|
242 | - if (!$this->_element instanceof Primitive\RelativeOID) { |
|
243 | - throw new \UnexpectedValueException( |
|
244 | - $this->_generateExceptionMessage(Element::TYPE_RELATIVE_OID)); |
|
245 | - } |
|
246 | - return $this->_element; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Get the wrapped element as a sequence type. |
|
251 | - * |
|
252 | - * @throws \UnexpectedValueException If the element is not a sequence |
|
253 | - * @return Constructed\Sequence |
|
254 | - */ |
|
255 | - public function asSequence(): Constructed\Sequence |
|
256 | - { |
|
257 | - if (!$this->_element instanceof Constructed\Sequence) { |
|
258 | - throw new \UnexpectedValueException( |
|
259 | - $this->_generateExceptionMessage(Element::TYPE_SEQUENCE)); |
|
260 | - } |
|
261 | - return $this->_element; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Get the wrapped element as a set type. |
|
266 | - * |
|
267 | - * @throws \UnexpectedValueException If the element is not a set |
|
268 | - * @return Constructed\Set |
|
269 | - */ |
|
270 | - public function asSet(): Constructed\Set |
|
271 | - { |
|
272 | - if (!$this->_element instanceof Constructed\Set) { |
|
273 | - throw new \UnexpectedValueException( |
|
274 | - $this->_generateExceptionMessage(Element::TYPE_SET)); |
|
275 | - } |
|
276 | - return $this->_element; |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * Get the wrapped element as a numeric string type. |
|
281 | - * |
|
282 | - * @throws \UnexpectedValueException If the element is not a numeric string |
|
283 | - * @return Primitive\NumericString |
|
284 | - */ |
|
285 | - public function asNumericString(): Primitive\NumericString |
|
286 | - { |
|
287 | - if (!$this->_element instanceof Primitive\NumericString) { |
|
288 | - throw new \UnexpectedValueException( |
|
289 | - $this->_generateExceptionMessage(Element::TYPE_NUMERIC_STRING)); |
|
290 | - } |
|
291 | - return $this->_element; |
|
292 | - } |
|
293 | - |
|
294 | - /** |
|
295 | - * Get the wrapped element as a printable string type. |
|
296 | - * |
|
297 | - * @throws \UnexpectedValueException If the element is not a printable |
|
298 | - * string |
|
299 | - * @return Primitive\PrintableString |
|
300 | - */ |
|
301 | - public function asPrintableString(): Primitive\PrintableString |
|
302 | - { |
|
303 | - if (!$this->_element instanceof Primitive\PrintableString) { |
|
304 | - throw new \UnexpectedValueException( |
|
305 | - $this->_generateExceptionMessage(Element::TYPE_PRINTABLE_STRING)); |
|
306 | - } |
|
307 | - return $this->_element; |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * Get the wrapped element as a T61 string type. |
|
312 | - * |
|
313 | - * @throws \UnexpectedValueException If the element is not a T61 string |
|
314 | - * @return Primitive\T61String |
|
315 | - */ |
|
316 | - public function asT61String(): Primitive\T61String |
|
317 | - { |
|
318 | - if (!$this->_element instanceof Primitive\T61String) { |
|
319 | - throw new \UnexpectedValueException( |
|
320 | - $this->_generateExceptionMessage(Element::TYPE_T61_STRING)); |
|
321 | - } |
|
322 | - return $this->_element; |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * Get the wrapped element as a videotex string type. |
|
327 | - * |
|
328 | - * @throws \UnexpectedValueException If the element is not a videotex string |
|
329 | - * @return Primitive\VideotexString |
|
330 | - */ |
|
331 | - public function asVideotexString(): Primitive\VideotexString |
|
332 | - { |
|
333 | - if (!$this->_element instanceof Primitive\VideotexString) { |
|
334 | - throw new \UnexpectedValueException( |
|
335 | - $this->_generateExceptionMessage(Element::TYPE_VIDEOTEX_STRING)); |
|
336 | - } |
|
337 | - return $this->_element; |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * Get the wrapped element as a IA5 string type. |
|
342 | - * |
|
343 | - * @throws \UnexpectedValueException If the element is not a IA5 string |
|
344 | - * @return Primitive\IA5String |
|
345 | - */ |
|
346 | - public function asIA5String(): Primitive\IA5String |
|
347 | - { |
|
348 | - if (!$this->_element instanceof Primitive\IA5String) { |
|
349 | - throw new \UnexpectedValueException( |
|
350 | - $this->_generateExceptionMessage(Element::TYPE_IA5_STRING)); |
|
351 | - } |
|
352 | - return $this->_element; |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * Get the wrapped element as an UTC time type. |
|
357 | - * |
|
358 | - * @throws \UnexpectedValueException If the element is not a UTC time |
|
359 | - * @return Primitive\UTCTime |
|
360 | - */ |
|
361 | - public function asUTCTime(): Primitive\UTCTime |
|
362 | - { |
|
363 | - if (!$this->_element instanceof Primitive\UTCTime) { |
|
364 | - throw new \UnexpectedValueException( |
|
365 | - $this->_generateExceptionMessage(Element::TYPE_UTC_TIME)); |
|
366 | - } |
|
367 | - return $this->_element; |
|
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * Get the wrapped element as a generalized time type. |
|
372 | - * |
|
373 | - * @throws \UnexpectedValueException If the element is not a generalized |
|
374 | - * time |
|
375 | - * @return Primitive\GeneralizedTime |
|
376 | - */ |
|
377 | - public function asGeneralizedTime(): Primitive\GeneralizedTime |
|
378 | - { |
|
379 | - if (!$this->_element instanceof Primitive\GeneralizedTime) { |
|
380 | - throw new \UnexpectedValueException( |
|
381 | - $this->_generateExceptionMessage(Element::TYPE_GENERALIZED_TIME)); |
|
382 | - } |
|
383 | - return $this->_element; |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * Get the wrapped element as a graphic string type. |
|
388 | - * |
|
389 | - * @throws \UnexpectedValueException If the element is not a graphic string |
|
390 | - * @return Primitive\GraphicString |
|
391 | - */ |
|
392 | - public function asGraphicString(): Primitive\GraphicString |
|
393 | - { |
|
394 | - if (!$this->_element instanceof Primitive\GraphicString) { |
|
395 | - throw new \UnexpectedValueException( |
|
396 | - $this->_generateExceptionMessage(Element::TYPE_GRAPHIC_STRING)); |
|
397 | - } |
|
398 | - return $this->_element; |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * Get the wrapped element as a visible string type. |
|
403 | - * |
|
404 | - * @throws \UnexpectedValueException If the element is not a visible string |
|
405 | - * @return Primitive\VisibleString |
|
406 | - */ |
|
407 | - public function asVisibleString(): Primitive\VisibleString |
|
408 | - { |
|
409 | - if (!$this->_element instanceof Primitive\VisibleString) { |
|
410 | - throw new \UnexpectedValueException( |
|
411 | - $this->_generateExceptionMessage(Element::TYPE_VISIBLE_STRING)); |
|
412 | - } |
|
413 | - return $this->_element; |
|
414 | - } |
|
415 | - |
|
416 | - /** |
|
417 | - * Get the wrapped element as a general string type. |
|
418 | - * |
|
419 | - * @throws \UnexpectedValueException If the element is not general string |
|
420 | - * @return Primitive\GeneralString |
|
421 | - */ |
|
422 | - public function asGeneralString(): Primitive\GeneralString |
|
423 | - { |
|
424 | - if (!$this->_element instanceof Primitive\GeneralString) { |
|
425 | - throw new \UnexpectedValueException( |
|
426 | - $this->_generateExceptionMessage(Element::TYPE_GENERAL_STRING)); |
|
427 | - } |
|
428 | - return $this->_element; |
|
429 | - } |
|
430 | - |
|
431 | - /** |
|
432 | - * Get the wrapped element as a universal string type. |
|
433 | - * |
|
434 | - * @throws \UnexpectedValueException If the element is not a universal |
|
435 | - * string |
|
436 | - * @return Primitive\UniversalString |
|
437 | - */ |
|
438 | - public function asUniversalString(): Primitive\UniversalString |
|
439 | - { |
|
440 | - if (!$this->_element instanceof Primitive\UniversalString) { |
|
441 | - throw new \UnexpectedValueException( |
|
442 | - $this->_generateExceptionMessage(Element::TYPE_UNIVERSAL_STRING)); |
|
443 | - } |
|
444 | - return $this->_element; |
|
445 | - } |
|
446 | - |
|
447 | - /** |
|
448 | - * Get the wrapped element as a character string type. |
|
449 | - * |
|
450 | - * @throws \UnexpectedValueException If the element is not a character |
|
451 | - * string |
|
452 | - * @return Primitive\CharacterString |
|
453 | - */ |
|
454 | - public function asCharacterString(): Primitive\CharacterString |
|
455 | - { |
|
456 | - if (!$this->_element instanceof Primitive\CharacterString) { |
|
457 | - throw new \UnexpectedValueException( |
|
458 | - $this->_generateExceptionMessage(Element::TYPE_CHARACTER_STRING)); |
|
459 | - } |
|
460 | - return $this->_element; |
|
461 | - } |
|
462 | - |
|
463 | - /** |
|
464 | - * Get the wrapped element as a BMP string type. |
|
465 | - * |
|
466 | - * @throws \UnexpectedValueException If the element is not a bmp string |
|
467 | - * @return Primitive\BMPString |
|
468 | - */ |
|
469 | - public function asBMPString(): Primitive\BMPString |
|
470 | - { |
|
471 | - if (!$this->_element instanceof Primitive\BMPString) { |
|
472 | - throw new \UnexpectedValueException( |
|
473 | - $this->_generateExceptionMessage(Element::TYPE_BMP_STRING)); |
|
474 | - } |
|
475 | - return $this->_element; |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * Get the wrapped element as any string type. |
|
480 | - * |
|
481 | - * @throws \UnexpectedValueException If the element is not a string |
|
482 | - * @return StringType |
|
483 | - */ |
|
484 | - public function asString(): StringType |
|
485 | - { |
|
486 | - if (!$this->_element instanceof StringType) { |
|
487 | - throw new \UnexpectedValueException( |
|
488 | - $this->_generateExceptionMessage(Element::TYPE_STRING)); |
|
489 | - } |
|
490 | - return $this->_element; |
|
491 | - } |
|
492 | - |
|
493 | - /** |
|
494 | - * Get the wrapped element as any time type. |
|
495 | - * |
|
496 | - * @throws \UnexpectedValueException If the element is not a time |
|
497 | - * @return TimeType |
|
498 | - */ |
|
499 | - public function asTime(): TimeType |
|
500 | - { |
|
501 | - if (!$this->_element instanceof TimeType) { |
|
502 | - throw new \UnexpectedValueException( |
|
503 | - $this->_generateExceptionMessage(Element::TYPE_TIME)); |
|
504 | - } |
|
505 | - return $this->_element; |
|
506 | - } |
|
507 | - |
|
508 | - /** |
|
509 | - * Generate message for exceptions thrown by <code>as*</code> methods. |
|
510 | - * |
|
511 | - * @param int $tag Type tag of the expected element |
|
512 | - * @return string |
|
513 | - */ |
|
514 | - private function _generateExceptionMessage($tag): string |
|
515 | - { |
|
516 | - return sprintf("%s expected, got %s.", Element::tagToName($tag), |
|
517 | - $this->_typeDescriptorString()); |
|
518 | - } |
|
519 | - |
|
520 | - /** |
|
521 | - * Get textual description of the wrapped element for debugging purposes. |
|
522 | - * |
|
523 | - * @return string |
|
524 | - */ |
|
525 | - private function _typeDescriptorString() |
|
526 | - { |
|
527 | - $type_cls = $this->_element->typeClass(); |
|
528 | - $tag = $this->_element->tag(); |
|
529 | - if ($type_cls == Identifier::CLASS_UNIVERSAL) { |
|
530 | - return Element::tagToName($tag); |
|
531 | - } |
|
532 | - return Identifier::classToName($type_cls) . " TAG $tag"; |
|
533 | - } |
|
534 | - |
|
535 | - /** |
|
536 | - * |
|
537 | - * @see \ASN1\Feature\Encodable::toDER() |
|
538 | - * @return string |
|
539 | - */ |
|
540 | - public function toDER(): string |
|
541 | - { |
|
542 | - return $this->_element->toDER(); |
|
543 | - } |
|
544 | - |
|
545 | - /** |
|
546 | - * |
|
547 | - * @see \ASN1\Feature\ElementBase::typeClass() |
|
548 | - * @return int |
|
549 | - */ |
|
550 | - public function typeClass(): int |
|
551 | - { |
|
552 | - return $this->_element->typeClass(); |
|
553 | - } |
|
554 | - |
|
555 | - /** |
|
556 | - * |
|
557 | - * @see \ASN1\Feature\ElementBase::isConstructed() |
|
558 | - * @return bool |
|
559 | - */ |
|
560 | - public function isConstructed(): bool |
|
561 | - { |
|
562 | - return $this->_element->isConstructed(); |
|
563 | - } |
|
564 | - |
|
565 | - /** |
|
566 | - * |
|
567 | - * @see \ASN1\Feature\ElementBase::tag() |
|
568 | - * @return int |
|
569 | - */ |
|
570 | - public function tag() |
|
571 | - { |
|
572 | - return $this->_element->tag(); |
|
573 | - } |
|
574 | - |
|
575 | - /** |
|
576 | - * |
|
577 | - * {@inheritdoc} |
|
578 | - * @see \ASN1\Feature\ElementBase::isType() |
|
579 | - * @return bool |
|
580 | - */ |
|
581 | - public function isType($tag): bool |
|
582 | - { |
|
583 | - return $this->_element->isType($tag); |
|
584 | - } |
|
585 | - |
|
586 | - /** |
|
587 | - * |
|
588 | - * @deprecated Use any <code>as*</code> accessor method first to ensure |
|
589 | - * type strictness. |
|
590 | - * @see \ASN1\Feature\ElementBase::expectType() |
|
591 | - * @return ElementBase |
|
592 | - */ |
|
593 | - public function expectType($tag): ElementBase |
|
594 | - { |
|
595 | - return $this->_element->expectType($tag); |
|
596 | - } |
|
597 | - |
|
598 | - /** |
|
599 | - * |
|
600 | - * @see \ASN1\Feature\ElementBase::isTagged() |
|
601 | - * @return bool |
|
602 | - */ |
|
603 | - public function isTagged(): bool |
|
604 | - { |
|
605 | - return $this->_element->isTagged(); |
|
606 | - } |
|
607 | - |
|
608 | - /** |
|
609 | - * |
|
610 | - * @deprecated Use any <code>as*</code> accessor method first to ensure |
|
611 | - * type strictness. |
|
612 | - * @see \ASN1\Feature\ElementBase::expectTagged() |
|
613 | - * @return TaggedType |
|
614 | - */ |
|
615 | - public function expectTagged($tag = null): TaggedType |
|
616 | - { |
|
617 | - return $this->_element->expectTagged($tag); |
|
618 | - } |
|
619 | - |
|
620 | - /** |
|
621 | - * |
|
622 | - * @see \ASN1\Feature\ElementBase::asElement() |
|
623 | - * @return Element |
|
624 | - */ |
|
625 | - public function asElement(): Element |
|
626 | - { |
|
627 | - return $this->_element; |
|
628 | - } |
|
20 | + /** |
|
21 | + * The wrapped element. |
|
22 | + * |
|
23 | + * @var Element |
|
24 | + */ |
|
25 | + private $_element; |
|
26 | + |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param Element $el |
|
31 | + */ |
|
32 | + public function __construct(Element $el) |
|
33 | + { |
|
34 | + $this->_element = $el; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Initialize from ElementBase interface. |
|
39 | + * |
|
40 | + * @param ElementBase $el |
|
41 | + * @return self |
|
42 | + */ |
|
43 | + public static function fromElementBase(ElementBase $el) |
|
44 | + { |
|
45 | + // if element is already wrapped |
|
46 | + if ($el instanceof self) { |
|
47 | + return $el; |
|
48 | + } |
|
49 | + return new self($el->asElement()); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Compatibility method to dispatch calls to the wrapped element. |
|
54 | + * |
|
55 | + * @deprecated Use <code>as*</code> accessor methods to ensure strict type |
|
56 | + * @param string $mtd Method name |
|
57 | + * @param array $args Arguments |
|
58 | + * @return mixed |
|
59 | + */ |
|
60 | + public function __call($mtd, array $args) |
|
61 | + { |
|
62 | + return call_user_func_array([$this->_element, $mtd], $args); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Get the wrapped element as a context specific tagged type. |
|
67 | + * |
|
68 | + * @throws \UnexpectedValueException If the element is not tagged |
|
69 | + * @return TaggedType |
|
70 | + */ |
|
71 | + public function asTagged(): TaggedType |
|
72 | + { |
|
73 | + if (!$this->_element instanceof TaggedType) { |
|
74 | + throw new \UnexpectedValueException( |
|
75 | + "Tagged element expected, got " . $this->_typeDescriptorString()); |
|
76 | + } |
|
77 | + return $this->_element; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Get the wrapped element as a boolean type. |
|
82 | + * |
|
83 | + * @throws \UnexpectedValueException If the element is not a boolean |
|
84 | + * @return Primitive\Boolean |
|
85 | + */ |
|
86 | + public function asBoolean(): Primitive\Boolean |
|
87 | + { |
|
88 | + if (!$this->_element instanceof Primitive\Boolean) { |
|
89 | + throw new \UnexpectedValueException( |
|
90 | + $this->_generateExceptionMessage(Element::TYPE_BOOLEAN)); |
|
91 | + } |
|
92 | + return $this->_element; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Get the wrapped element as an integer type. |
|
97 | + * |
|
98 | + * @throws \UnexpectedValueException If the element is not an integer |
|
99 | + * @return Primitive\Integer |
|
100 | + */ |
|
101 | + public function asInteger(): Primitive\Integer |
|
102 | + { |
|
103 | + if (!$this->_element instanceof Primitive\Integer) { |
|
104 | + throw new \UnexpectedValueException( |
|
105 | + $this->_generateExceptionMessage(Element::TYPE_INTEGER)); |
|
106 | + } |
|
107 | + return $this->_element; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Get the wrapped element as a bit string type. |
|
112 | + * |
|
113 | + * @throws \UnexpectedValueException If the element is not a bit string |
|
114 | + * @return Primitive\BitString |
|
115 | + */ |
|
116 | + public function asBitString(): Primitive\BitString |
|
117 | + { |
|
118 | + if (!$this->_element instanceof Primitive\BitString) { |
|
119 | + throw new \UnexpectedValueException( |
|
120 | + $this->_generateExceptionMessage(Element::TYPE_BIT_STRING)); |
|
121 | + } |
|
122 | + return $this->_element; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Get the wrapped element as an octet string type. |
|
127 | + * |
|
128 | + * @throws \UnexpectedValueException If the element is not an octet string |
|
129 | + * @return Primitive\OctetString |
|
130 | + */ |
|
131 | + public function asOctetString(): Primitive\OctetString |
|
132 | + { |
|
133 | + if (!$this->_element instanceof Primitive\OctetString) { |
|
134 | + throw new \UnexpectedValueException( |
|
135 | + $this->_generateExceptionMessage(Element::TYPE_OCTET_STRING)); |
|
136 | + } |
|
137 | + return $this->_element; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Get the wrapped element as a null type. |
|
142 | + * |
|
143 | + * @throws \UnexpectedValueException If the element is not a null |
|
144 | + * @return Primitive\NullType |
|
145 | + */ |
|
146 | + public function asNull(): Primitive\NullType |
|
147 | + { |
|
148 | + if (!$this->_element instanceof Primitive\NullType) { |
|
149 | + throw new \UnexpectedValueException( |
|
150 | + $this->_generateExceptionMessage(Element::TYPE_NULL)); |
|
151 | + } |
|
152 | + return $this->_element; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Get the wrapped element as an object identifier type. |
|
157 | + * |
|
158 | + * @throws \UnexpectedValueException If the element is not an object |
|
159 | + * identifier |
|
160 | + * @return Primitive\ObjectIdentifier |
|
161 | + */ |
|
162 | + public function asObjectIdentifier(): Primitive\ObjectIdentifier |
|
163 | + { |
|
164 | + if (!$this->_element instanceof Primitive\ObjectIdentifier) { |
|
165 | + throw new \UnexpectedValueException( |
|
166 | + $this->_generateExceptionMessage( |
|
167 | + Element::TYPE_OBJECT_IDENTIFIER)); |
|
168 | + } |
|
169 | + return $this->_element; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Get the wrapped element as an object descriptor type. |
|
174 | + * |
|
175 | + * @throws \UnexpectedValueException If the element is not an object |
|
176 | + * descriptor |
|
177 | + * @return Primitive\ObjectDescriptor |
|
178 | + */ |
|
179 | + public function asObjectDescriptor(): Primitive\ObjectDescriptor |
|
180 | + { |
|
181 | + if (!$this->_element instanceof Primitive\ObjectDescriptor) { |
|
182 | + throw new \UnexpectedValueException( |
|
183 | + $this->_generateExceptionMessage( |
|
184 | + Element::TYPE_OBJECT_DESCRIPTOR)); |
|
185 | + } |
|
186 | + return $this->_element; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Get the wrapped element as a real type. |
|
191 | + * |
|
192 | + * @throws \UnexpectedValueException If the element is not a real |
|
193 | + * @return Primitive\Real |
|
194 | + */ |
|
195 | + public function asReal(): Primitive\Real |
|
196 | + { |
|
197 | + if (!$this->_element instanceof Primitive\Real) { |
|
198 | + throw new \UnexpectedValueException( |
|
199 | + $this->_generateExceptionMessage(Element::TYPE_REAL)); |
|
200 | + } |
|
201 | + return $this->_element; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Get the wrapped element as an enumerated type. |
|
206 | + * |
|
207 | + * @throws \UnexpectedValueException If the element is not an enumerated |
|
208 | + * @return Primitive\Enumerated |
|
209 | + */ |
|
210 | + public function asEnumerated(): Primitive\Enumerated |
|
211 | + { |
|
212 | + if (!$this->_element instanceof Primitive\Enumerated) { |
|
213 | + throw new \UnexpectedValueException( |
|
214 | + $this->_generateExceptionMessage(Element::TYPE_ENUMERATED)); |
|
215 | + } |
|
216 | + return $this->_element; |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Get the wrapped element as a UTF8 string type. |
|
221 | + * |
|
222 | + * @throws \UnexpectedValueException If the element is not a UTF8 string |
|
223 | + * @return Primitive\UTF8String |
|
224 | + */ |
|
225 | + public function asUTF8String(): Primitive\UTF8String |
|
226 | + { |
|
227 | + if (!$this->_element instanceof Primitive\UTF8String) { |
|
228 | + throw new \UnexpectedValueException( |
|
229 | + $this->_generateExceptionMessage(Element::TYPE_UTF8_STRING)); |
|
230 | + } |
|
231 | + return $this->_element; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * Get the wrapped element as a relative OID type. |
|
236 | + * |
|
237 | + * @throws \UnexpectedValueException If the element is not a relative OID |
|
238 | + * @return Primitive\RelativeOID |
|
239 | + */ |
|
240 | + public function asRelativeOID(): Primitive\RelativeOID |
|
241 | + { |
|
242 | + if (!$this->_element instanceof Primitive\RelativeOID) { |
|
243 | + throw new \UnexpectedValueException( |
|
244 | + $this->_generateExceptionMessage(Element::TYPE_RELATIVE_OID)); |
|
245 | + } |
|
246 | + return $this->_element; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Get the wrapped element as a sequence type. |
|
251 | + * |
|
252 | + * @throws \UnexpectedValueException If the element is not a sequence |
|
253 | + * @return Constructed\Sequence |
|
254 | + */ |
|
255 | + public function asSequence(): Constructed\Sequence |
|
256 | + { |
|
257 | + if (!$this->_element instanceof Constructed\Sequence) { |
|
258 | + throw new \UnexpectedValueException( |
|
259 | + $this->_generateExceptionMessage(Element::TYPE_SEQUENCE)); |
|
260 | + } |
|
261 | + return $this->_element; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Get the wrapped element as a set type. |
|
266 | + * |
|
267 | + * @throws \UnexpectedValueException If the element is not a set |
|
268 | + * @return Constructed\Set |
|
269 | + */ |
|
270 | + public function asSet(): Constructed\Set |
|
271 | + { |
|
272 | + if (!$this->_element instanceof Constructed\Set) { |
|
273 | + throw new \UnexpectedValueException( |
|
274 | + $this->_generateExceptionMessage(Element::TYPE_SET)); |
|
275 | + } |
|
276 | + return $this->_element; |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * Get the wrapped element as a numeric string type. |
|
281 | + * |
|
282 | + * @throws \UnexpectedValueException If the element is not a numeric string |
|
283 | + * @return Primitive\NumericString |
|
284 | + */ |
|
285 | + public function asNumericString(): Primitive\NumericString |
|
286 | + { |
|
287 | + if (!$this->_element instanceof Primitive\NumericString) { |
|
288 | + throw new \UnexpectedValueException( |
|
289 | + $this->_generateExceptionMessage(Element::TYPE_NUMERIC_STRING)); |
|
290 | + } |
|
291 | + return $this->_element; |
|
292 | + } |
|
293 | + |
|
294 | + /** |
|
295 | + * Get the wrapped element as a printable string type. |
|
296 | + * |
|
297 | + * @throws \UnexpectedValueException If the element is not a printable |
|
298 | + * string |
|
299 | + * @return Primitive\PrintableString |
|
300 | + */ |
|
301 | + public function asPrintableString(): Primitive\PrintableString |
|
302 | + { |
|
303 | + if (!$this->_element instanceof Primitive\PrintableString) { |
|
304 | + throw new \UnexpectedValueException( |
|
305 | + $this->_generateExceptionMessage(Element::TYPE_PRINTABLE_STRING)); |
|
306 | + } |
|
307 | + return $this->_element; |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * Get the wrapped element as a T61 string type. |
|
312 | + * |
|
313 | + * @throws \UnexpectedValueException If the element is not a T61 string |
|
314 | + * @return Primitive\T61String |
|
315 | + */ |
|
316 | + public function asT61String(): Primitive\T61String |
|
317 | + { |
|
318 | + if (!$this->_element instanceof Primitive\T61String) { |
|
319 | + throw new \UnexpectedValueException( |
|
320 | + $this->_generateExceptionMessage(Element::TYPE_T61_STRING)); |
|
321 | + } |
|
322 | + return $this->_element; |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * Get the wrapped element as a videotex string type. |
|
327 | + * |
|
328 | + * @throws \UnexpectedValueException If the element is not a videotex string |
|
329 | + * @return Primitive\VideotexString |
|
330 | + */ |
|
331 | + public function asVideotexString(): Primitive\VideotexString |
|
332 | + { |
|
333 | + if (!$this->_element instanceof Primitive\VideotexString) { |
|
334 | + throw new \UnexpectedValueException( |
|
335 | + $this->_generateExceptionMessage(Element::TYPE_VIDEOTEX_STRING)); |
|
336 | + } |
|
337 | + return $this->_element; |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Get the wrapped element as a IA5 string type. |
|
342 | + * |
|
343 | + * @throws \UnexpectedValueException If the element is not a IA5 string |
|
344 | + * @return Primitive\IA5String |
|
345 | + */ |
|
346 | + public function asIA5String(): Primitive\IA5String |
|
347 | + { |
|
348 | + if (!$this->_element instanceof Primitive\IA5String) { |
|
349 | + throw new \UnexpectedValueException( |
|
350 | + $this->_generateExceptionMessage(Element::TYPE_IA5_STRING)); |
|
351 | + } |
|
352 | + return $this->_element; |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * Get the wrapped element as an UTC time type. |
|
357 | + * |
|
358 | + * @throws \UnexpectedValueException If the element is not a UTC time |
|
359 | + * @return Primitive\UTCTime |
|
360 | + */ |
|
361 | + public function asUTCTime(): Primitive\UTCTime |
|
362 | + { |
|
363 | + if (!$this->_element instanceof Primitive\UTCTime) { |
|
364 | + throw new \UnexpectedValueException( |
|
365 | + $this->_generateExceptionMessage(Element::TYPE_UTC_TIME)); |
|
366 | + } |
|
367 | + return $this->_element; |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * Get the wrapped element as a generalized time type. |
|
372 | + * |
|
373 | + * @throws \UnexpectedValueException If the element is not a generalized |
|
374 | + * time |
|
375 | + * @return Primitive\GeneralizedTime |
|
376 | + */ |
|
377 | + public function asGeneralizedTime(): Primitive\GeneralizedTime |
|
378 | + { |
|
379 | + if (!$this->_element instanceof Primitive\GeneralizedTime) { |
|
380 | + throw new \UnexpectedValueException( |
|
381 | + $this->_generateExceptionMessage(Element::TYPE_GENERALIZED_TIME)); |
|
382 | + } |
|
383 | + return $this->_element; |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * Get the wrapped element as a graphic string type. |
|
388 | + * |
|
389 | + * @throws \UnexpectedValueException If the element is not a graphic string |
|
390 | + * @return Primitive\GraphicString |
|
391 | + */ |
|
392 | + public function asGraphicString(): Primitive\GraphicString |
|
393 | + { |
|
394 | + if (!$this->_element instanceof Primitive\GraphicString) { |
|
395 | + throw new \UnexpectedValueException( |
|
396 | + $this->_generateExceptionMessage(Element::TYPE_GRAPHIC_STRING)); |
|
397 | + } |
|
398 | + return $this->_element; |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * Get the wrapped element as a visible string type. |
|
403 | + * |
|
404 | + * @throws \UnexpectedValueException If the element is not a visible string |
|
405 | + * @return Primitive\VisibleString |
|
406 | + */ |
|
407 | + public function asVisibleString(): Primitive\VisibleString |
|
408 | + { |
|
409 | + if (!$this->_element instanceof Primitive\VisibleString) { |
|
410 | + throw new \UnexpectedValueException( |
|
411 | + $this->_generateExceptionMessage(Element::TYPE_VISIBLE_STRING)); |
|
412 | + } |
|
413 | + return $this->_element; |
|
414 | + } |
|
415 | + |
|
416 | + /** |
|
417 | + * Get the wrapped element as a general string type. |
|
418 | + * |
|
419 | + * @throws \UnexpectedValueException If the element is not general string |
|
420 | + * @return Primitive\GeneralString |
|
421 | + */ |
|
422 | + public function asGeneralString(): Primitive\GeneralString |
|
423 | + { |
|
424 | + if (!$this->_element instanceof Primitive\GeneralString) { |
|
425 | + throw new \UnexpectedValueException( |
|
426 | + $this->_generateExceptionMessage(Element::TYPE_GENERAL_STRING)); |
|
427 | + } |
|
428 | + return $this->_element; |
|
429 | + } |
|
430 | + |
|
431 | + /** |
|
432 | + * Get the wrapped element as a universal string type. |
|
433 | + * |
|
434 | + * @throws \UnexpectedValueException If the element is not a universal |
|
435 | + * string |
|
436 | + * @return Primitive\UniversalString |
|
437 | + */ |
|
438 | + public function asUniversalString(): Primitive\UniversalString |
|
439 | + { |
|
440 | + if (!$this->_element instanceof Primitive\UniversalString) { |
|
441 | + throw new \UnexpectedValueException( |
|
442 | + $this->_generateExceptionMessage(Element::TYPE_UNIVERSAL_STRING)); |
|
443 | + } |
|
444 | + return $this->_element; |
|
445 | + } |
|
446 | + |
|
447 | + /** |
|
448 | + * Get the wrapped element as a character string type. |
|
449 | + * |
|
450 | + * @throws \UnexpectedValueException If the element is not a character |
|
451 | + * string |
|
452 | + * @return Primitive\CharacterString |
|
453 | + */ |
|
454 | + public function asCharacterString(): Primitive\CharacterString |
|
455 | + { |
|
456 | + if (!$this->_element instanceof Primitive\CharacterString) { |
|
457 | + throw new \UnexpectedValueException( |
|
458 | + $this->_generateExceptionMessage(Element::TYPE_CHARACTER_STRING)); |
|
459 | + } |
|
460 | + return $this->_element; |
|
461 | + } |
|
462 | + |
|
463 | + /** |
|
464 | + * Get the wrapped element as a BMP string type. |
|
465 | + * |
|
466 | + * @throws \UnexpectedValueException If the element is not a bmp string |
|
467 | + * @return Primitive\BMPString |
|
468 | + */ |
|
469 | + public function asBMPString(): Primitive\BMPString |
|
470 | + { |
|
471 | + if (!$this->_element instanceof Primitive\BMPString) { |
|
472 | + throw new \UnexpectedValueException( |
|
473 | + $this->_generateExceptionMessage(Element::TYPE_BMP_STRING)); |
|
474 | + } |
|
475 | + return $this->_element; |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * Get the wrapped element as any string type. |
|
480 | + * |
|
481 | + * @throws \UnexpectedValueException If the element is not a string |
|
482 | + * @return StringType |
|
483 | + */ |
|
484 | + public function asString(): StringType |
|
485 | + { |
|
486 | + if (!$this->_element instanceof StringType) { |
|
487 | + throw new \UnexpectedValueException( |
|
488 | + $this->_generateExceptionMessage(Element::TYPE_STRING)); |
|
489 | + } |
|
490 | + return $this->_element; |
|
491 | + } |
|
492 | + |
|
493 | + /** |
|
494 | + * Get the wrapped element as any time type. |
|
495 | + * |
|
496 | + * @throws \UnexpectedValueException If the element is not a time |
|
497 | + * @return TimeType |
|
498 | + */ |
|
499 | + public function asTime(): TimeType |
|
500 | + { |
|
501 | + if (!$this->_element instanceof TimeType) { |
|
502 | + throw new \UnexpectedValueException( |
|
503 | + $this->_generateExceptionMessage(Element::TYPE_TIME)); |
|
504 | + } |
|
505 | + return $this->_element; |
|
506 | + } |
|
507 | + |
|
508 | + /** |
|
509 | + * Generate message for exceptions thrown by <code>as*</code> methods. |
|
510 | + * |
|
511 | + * @param int $tag Type tag of the expected element |
|
512 | + * @return string |
|
513 | + */ |
|
514 | + private function _generateExceptionMessage($tag): string |
|
515 | + { |
|
516 | + return sprintf("%s expected, got %s.", Element::tagToName($tag), |
|
517 | + $this->_typeDescriptorString()); |
|
518 | + } |
|
519 | + |
|
520 | + /** |
|
521 | + * Get textual description of the wrapped element for debugging purposes. |
|
522 | + * |
|
523 | + * @return string |
|
524 | + */ |
|
525 | + private function _typeDescriptorString() |
|
526 | + { |
|
527 | + $type_cls = $this->_element->typeClass(); |
|
528 | + $tag = $this->_element->tag(); |
|
529 | + if ($type_cls == Identifier::CLASS_UNIVERSAL) { |
|
530 | + return Element::tagToName($tag); |
|
531 | + } |
|
532 | + return Identifier::classToName($type_cls) . " TAG $tag"; |
|
533 | + } |
|
534 | + |
|
535 | + /** |
|
536 | + * |
|
537 | + * @see \ASN1\Feature\Encodable::toDER() |
|
538 | + * @return string |
|
539 | + */ |
|
540 | + public function toDER(): string |
|
541 | + { |
|
542 | + return $this->_element->toDER(); |
|
543 | + } |
|
544 | + |
|
545 | + /** |
|
546 | + * |
|
547 | + * @see \ASN1\Feature\ElementBase::typeClass() |
|
548 | + * @return int |
|
549 | + */ |
|
550 | + public function typeClass(): int |
|
551 | + { |
|
552 | + return $this->_element->typeClass(); |
|
553 | + } |
|
554 | + |
|
555 | + /** |
|
556 | + * |
|
557 | + * @see \ASN1\Feature\ElementBase::isConstructed() |
|
558 | + * @return bool |
|
559 | + */ |
|
560 | + public function isConstructed(): bool |
|
561 | + { |
|
562 | + return $this->_element->isConstructed(); |
|
563 | + } |
|
564 | + |
|
565 | + /** |
|
566 | + * |
|
567 | + * @see \ASN1\Feature\ElementBase::tag() |
|
568 | + * @return int |
|
569 | + */ |
|
570 | + public function tag() |
|
571 | + { |
|
572 | + return $this->_element->tag(); |
|
573 | + } |
|
574 | + |
|
575 | + /** |
|
576 | + * |
|
577 | + * {@inheritdoc} |
|
578 | + * @see \ASN1\Feature\ElementBase::isType() |
|
579 | + * @return bool |
|
580 | + */ |
|
581 | + public function isType($tag): bool |
|
582 | + { |
|
583 | + return $this->_element->isType($tag); |
|
584 | + } |
|
585 | + |
|
586 | + /** |
|
587 | + * |
|
588 | + * @deprecated Use any <code>as*</code> accessor method first to ensure |
|
589 | + * type strictness. |
|
590 | + * @see \ASN1\Feature\ElementBase::expectType() |
|
591 | + * @return ElementBase |
|
592 | + */ |
|
593 | + public function expectType($tag): ElementBase |
|
594 | + { |
|
595 | + return $this->_element->expectType($tag); |
|
596 | + } |
|
597 | + |
|
598 | + /** |
|
599 | + * |
|
600 | + * @see \ASN1\Feature\ElementBase::isTagged() |
|
601 | + * @return bool |
|
602 | + */ |
|
603 | + public function isTagged(): bool |
|
604 | + { |
|
605 | + return $this->_element->isTagged(); |
|
606 | + } |
|
607 | + |
|
608 | + /** |
|
609 | + * |
|
610 | + * @deprecated Use any <code>as*</code> accessor method first to ensure |
|
611 | + * type strictness. |
|
612 | + * @see \ASN1\Feature\ElementBase::expectTagged() |
|
613 | + * @return TaggedType |
|
614 | + */ |
|
615 | + public function expectTagged($tag = null): TaggedType |
|
616 | + { |
|
617 | + return $this->_element->expectTagged($tag); |
|
618 | + } |
|
619 | + |
|
620 | + /** |
|
621 | + * |
|
622 | + * @see \ASN1\Feature\ElementBase::asElement() |
|
623 | + * @return Element |
|
624 | + */ |
|
625 | + public function asElement(): Element |
|
626 | + { |
|
627 | + return $this->_element; |
|
628 | + } |
|
629 | 629 | } |
@@ -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 |
@@ -13,40 +13,40 @@ |
||
13 | 13 | */ |
14 | 14 | abstract class PrimitiveString extends StringType |
15 | 15 | { |
16 | - use PrimitiveType; |
|
16 | + use PrimitiveType; |
|
17 | 17 | |
18 | - /** |
|
19 | - * |
|
20 | - * @see \ASN1\Element::_encodedContentDER() |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - protected function _encodedContentDER(): string |
|
24 | - { |
|
25 | - return $this->_string; |
|
26 | - } |
|
18 | + /** |
|
19 | + * |
|
20 | + * @see \ASN1\Element::_encodedContentDER() |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + protected function _encodedContentDER(): string |
|
24 | + { |
|
25 | + return $this->_string; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * {@inheritdoc} |
|
30 | - * @see \ASN1\Element::_decodeFromDER() |
|
31 | - * @return self |
|
32 | - */ |
|
33 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
34 | - int &$offset) |
|
35 | - { |
|
36 | - $idx = $offset; |
|
37 | - if (!$identifier->isPrimitive()) { |
|
38 | - throw new DecodeException("DER encoded string must be primitive."); |
|
39 | - } |
|
40 | - $length = Length::expectFromDER($data, $idx); |
|
41 | - $str = $length->length() ? substr($data, $idx, $length->length()) : ""; |
|
42 | - // substr should never return false, since length is |
|
43 | - // checked by Length::expectFromDER. |
|
44 | - assert(is_string($str), "substr"); |
|
45 | - $offset = $idx + $length->length(); |
|
46 | - try { |
|
47 | - return new static($str); |
|
48 | - } catch (\InvalidArgumentException $e) { |
|
49 | - throw new DecodeException($e->getMessage(), 0, $e); |
|
50 | - } |
|
51 | - } |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + * @see \ASN1\Element::_decodeFromDER() |
|
31 | + * @return self |
|
32 | + */ |
|
33 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
34 | + int &$offset) |
|
35 | + { |
|
36 | + $idx = $offset; |
|
37 | + if (!$identifier->isPrimitive()) { |
|
38 | + throw new DecodeException("DER encoded string must be primitive."); |
|
39 | + } |
|
40 | + $length = Length::expectFromDER($data, $idx); |
|
41 | + $str = $length->length() ? substr($data, $idx, $length->length()) : ""; |
|
42 | + // substr should never return false, since length is |
|
43 | + // checked by Length::expectFromDER. |
|
44 | + assert(is_string($str), "substr"); |
|
45 | + $offset = $idx + $length->length(); |
|
46 | + try { |
|
47 | + return new static($str); |
|
48 | + } catch (\InvalidArgumentException $e) { |
|
49 | + throw new DecodeException($e->getMessage(), 0, $e); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
@@ -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; |
6 | 6 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return self |
32 | 32 | */ |
33 | 33 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
34 | - int &$offset) |
|
34 | + int & $offset) |
|
35 | 35 | { |
36 | 36 | $idx = $offset; |
37 | 37 | if (!$identifier->isPrimitive()) { |