@@ -9,49 +9,49 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | abstract class StringType extends Element |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * String value. |
|
| 14 | - * |
|
| 15 | - * @var string $_string |
|
| 16 | - */ |
|
| 17 | - protected $_string; |
|
| 12 | + /** |
|
| 13 | + * String value. |
|
| 14 | + * |
|
| 15 | + * @var string $_string |
|
| 16 | + */ |
|
| 17 | + protected $_string; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string $string |
|
| 23 | - * @throws \InvalidArgumentException |
|
| 24 | - */ |
|
| 25 | - public function __construct($string) |
|
| 26 | - { |
|
| 27 | - assert('is_string($string)', "got " . gettype($string)); |
|
| 28 | - if (!$this->_validateString($string)) { |
|
| 29 | - throw new \InvalidArgumentException( |
|
| 30 | - sprintf("Not a valid %s string.", |
|
| 31 | - self::tagToName($this->_typeTag))); |
|
| 32 | - } |
|
| 33 | - $this->_string = $string; |
|
| 34 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string $string |
|
| 23 | + * @throws \InvalidArgumentException |
|
| 24 | + */ |
|
| 25 | + public function __construct($string) |
|
| 26 | + { |
|
| 27 | + assert('is_string($string)', "got " . gettype($string)); |
|
| 28 | + if (!$this->_validateString($string)) { |
|
| 29 | + throw new \InvalidArgumentException( |
|
| 30 | + sprintf("Not a valid %s string.", |
|
| 31 | + self::tagToName($this->_typeTag))); |
|
| 32 | + } |
|
| 33 | + $this->_string = $string; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Get the string value. |
|
| 38 | - * |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 41 | - public function string() |
|
| 42 | - { |
|
| 43 | - return $this->_string; |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * Get the string value. |
|
| 38 | + * |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | + public function string() |
|
| 42 | + { |
|
| 43 | + return $this->_string; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Check whether string is valid for the concrete type. |
|
| 48 | - * |
|
| 49 | - * @param string $string |
|
| 50 | - * @return bool |
|
| 51 | - */ |
|
| 52 | - protected function _validateString($string) |
|
| 53 | - { |
|
| 54 | - // Override in derived classes |
|
| 55 | - return true; |
|
| 56 | - } |
|
| 46 | + /** |
|
| 47 | + * Check whether string is valid for the concrete type. |
|
| 48 | + * |
|
| 49 | + * @param string $string |
|
| 50 | + * @return bool |
|
| 51 | + */ |
|
| 52 | + protected function _validateString($string) |
|
| 53 | + { |
|
| 54 | + // Override in derived classes |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -9,87 +9,87 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | abstract class TimeType extends Element |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * UTC timezone. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - const TZ_UTC = "UTC"; |
|
| 12 | + /** |
|
| 13 | + * UTC timezone. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + const TZ_UTC = "UTC"; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Date and time. |
|
| 21 | - * |
|
| 22 | - * @var \DateTimeImmutable $_dateTime |
|
| 23 | - */ |
|
| 24 | - protected $_dateTime; |
|
| 19 | + /** |
|
| 20 | + * Date and time. |
|
| 21 | + * |
|
| 22 | + * @var \DateTimeImmutable $_dateTime |
|
| 23 | + */ |
|
| 24 | + protected $_dateTime; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Constructor. |
|
| 28 | - * |
|
| 29 | - * @param \DateTimeImmutable $dt |
|
| 30 | - */ |
|
| 31 | - public function __construct(\DateTimeImmutable $dt) |
|
| 32 | - { |
|
| 33 | - $this->_dateTime = $dt; |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Constructor. |
|
| 28 | + * |
|
| 29 | + * @param \DateTimeImmutable $dt |
|
| 30 | + */ |
|
| 31 | + public function __construct(\DateTimeImmutable $dt) |
|
| 32 | + { |
|
| 33 | + $this->_dateTime = $dt; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Initialize from datetime string. |
|
| 38 | - * |
|
| 39 | - * @param string $time Time string |
|
| 40 | - * @param string|null $tz Timezone, if null use default. |
|
| 41 | - * @throws \RuntimeException |
|
| 42 | - * @return self |
|
| 43 | - */ |
|
| 44 | - public static function fromString($time, $tz = null) |
|
| 45 | - { |
|
| 46 | - try { |
|
| 47 | - if (!isset($tz)) { |
|
| 48 | - $tz = date_default_timezone_get(); |
|
| 49 | - } |
|
| 50 | - return new static( |
|
| 51 | - new \DateTimeImmutable($time, self::_createTimeZone($tz))); |
|
| 52 | - } catch (\Exception $e) { |
|
| 53 | - throw new \RuntimeException( |
|
| 54 | - "Failed to create DateTime: " . |
|
| 55 | - self::_getLastDateTimeImmutableErrorsStr(), 0, $e); |
|
| 56 | - } |
|
| 57 | - } |
|
| 36 | + /** |
|
| 37 | + * Initialize from datetime string. |
|
| 38 | + * |
|
| 39 | + * @param string $time Time string |
|
| 40 | + * @param string|null $tz Timezone, if null use default. |
|
| 41 | + * @throws \RuntimeException |
|
| 42 | + * @return self |
|
| 43 | + */ |
|
| 44 | + public static function fromString($time, $tz = null) |
|
| 45 | + { |
|
| 46 | + try { |
|
| 47 | + if (!isset($tz)) { |
|
| 48 | + $tz = date_default_timezone_get(); |
|
| 49 | + } |
|
| 50 | + return new static( |
|
| 51 | + new \DateTimeImmutable($time, self::_createTimeZone($tz))); |
|
| 52 | + } catch (\Exception $e) { |
|
| 53 | + throw new \RuntimeException( |
|
| 54 | + "Failed to create DateTime: " . |
|
| 55 | + self::_getLastDateTimeImmutableErrorsStr(), 0, $e); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Get the date and time. |
|
| 61 | - * |
|
| 62 | - * @return \DateTimeImmutable |
|
| 63 | - */ |
|
| 64 | - public function dateTime() |
|
| 65 | - { |
|
| 66 | - return $this->_dateTime; |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * Get the date and time. |
|
| 61 | + * |
|
| 62 | + * @return \DateTimeImmutable |
|
| 63 | + */ |
|
| 64 | + public function dateTime() |
|
| 65 | + { |
|
| 66 | + return $this->_dateTime; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Create DateTimeZone object from string. |
|
| 71 | - * |
|
| 72 | - * @param string $tz |
|
| 73 | - * @throws \UnexpectedValueException If timezone is invalid |
|
| 74 | - * @return \DateTimeZone |
|
| 75 | - */ |
|
| 76 | - protected static function _createTimeZone($tz) |
|
| 77 | - { |
|
| 78 | - try { |
|
| 79 | - return new \DateTimeZone($tz); |
|
| 80 | - } catch (\Exception $e) { |
|
| 81 | - throw new \UnexpectedValueException("Invalid timezone.", 0, $e); |
|
| 82 | - } |
|
| 83 | - } |
|
| 69 | + /** |
|
| 70 | + * Create DateTimeZone object from string. |
|
| 71 | + * |
|
| 72 | + * @param string $tz |
|
| 73 | + * @throws \UnexpectedValueException If timezone is invalid |
|
| 74 | + * @return \DateTimeZone |
|
| 75 | + */ |
|
| 76 | + protected static function _createTimeZone($tz) |
|
| 77 | + { |
|
| 78 | + try { |
|
| 79 | + return new \DateTimeZone($tz); |
|
| 80 | + } catch (\Exception $e) { |
|
| 81 | + throw new \UnexpectedValueException("Invalid timezone.", 0, $e); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Get last error caused by DateTimeImmutable. |
|
| 87 | - * |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - protected static function _getLastDateTimeImmutableErrorsStr() |
|
| 91 | - { |
|
| 92 | - $errors = \DateTimeImmutable::getLastErrors()["errors"]; |
|
| 93 | - return implode(", ", $errors); |
|
| 94 | - } |
|
| 85 | + /** |
|
| 86 | + * Get last error caused by DateTimeImmutable. |
|
| 87 | + * |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + protected static function _getLastDateTimeImmutableErrorsStr() |
|
| 91 | + { |
|
| 92 | + $errors = \DateTimeImmutable::getLastErrors()["errors"]; |
|
| 93 | + return implode(", ", $errors); |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -10,14 +10,14 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Sequence extends Structure |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Constructor |
|
| 15 | - * |
|
| 16 | - * @param Element ...$elements Any number of elements |
|
| 17 | - */ |
|
| 18 | - public function __construct(Element ...$elements) |
|
| 19 | - { |
|
| 20 | - $this->_typeTag = self::TYPE_SEQUENCE; |
|
| 21 | - parent::__construct(...$elements); |
|
| 22 | - } |
|
| 13 | + /** |
|
| 14 | + * Constructor |
|
| 15 | + * |
|
| 16 | + * @param Element ...$elements Any number of elements |
|
| 17 | + */ |
|
| 18 | + public function __construct(Element ...$elements) |
|
| 19 | + { |
|
| 20 | + $this->_typeTag = self::TYPE_SEQUENCE; |
|
| 21 | + parent::__construct(...$elements); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -10,54 +10,54 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Set extends Structure |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Constructor |
|
| 15 | - * |
|
| 16 | - * @param Element ...$elements Any number of elements |
|
| 17 | - */ |
|
| 18 | - public function __construct(Element ...$elements) |
|
| 19 | - { |
|
| 20 | - $this->_typeTag = self::TYPE_SET; |
|
| 21 | - parent::__construct(...$elements); |
|
| 22 | - } |
|
| 13 | + /** |
|
| 14 | + * Constructor |
|
| 15 | + * |
|
| 16 | + * @param Element ...$elements Any number of elements |
|
| 17 | + */ |
|
| 18 | + public function __construct(Element ...$elements) |
|
| 19 | + { |
|
| 20 | + $this->_typeTag = self::TYPE_SET; |
|
| 21 | + parent::__construct(...$elements); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Sort by canonical ascending order. |
|
| 26 | - * Used for DER encoding of SET type. |
|
| 27 | - * |
|
| 28 | - * @return self |
|
| 29 | - */ |
|
| 30 | - public function sortedSet() |
|
| 31 | - { |
|
| 32 | - $obj = clone $this; |
|
| 33 | - usort($obj->_elements, |
|
| 34 | - function (Element $a, Element $b) { |
|
| 35 | - if ($a->typeClass() != $b->typeClass()) { |
|
| 36 | - return $a->typeClass() < $b->typeClass() ? -1 : 1; |
|
| 37 | - } |
|
| 38 | - if ($a->tag() == $b->tag()) { |
|
| 39 | - return 0; |
|
| 40 | - } |
|
| 41 | - return $a->tag() < $b->tag() ? -1 : 1; |
|
| 42 | - }); |
|
| 43 | - return $obj; |
|
| 44 | - } |
|
| 24 | + /** |
|
| 25 | + * Sort by canonical ascending order. |
|
| 26 | + * Used for DER encoding of SET type. |
|
| 27 | + * |
|
| 28 | + * @return self |
|
| 29 | + */ |
|
| 30 | + public function sortedSet() |
|
| 31 | + { |
|
| 32 | + $obj = clone $this; |
|
| 33 | + usort($obj->_elements, |
|
| 34 | + function (Element $a, Element $b) { |
|
| 35 | + if ($a->typeClass() != $b->typeClass()) { |
|
| 36 | + return $a->typeClass() < $b->typeClass() ? -1 : 1; |
|
| 37 | + } |
|
| 38 | + if ($a->tag() == $b->tag()) { |
|
| 39 | + return 0; |
|
| 40 | + } |
|
| 41 | + return $a->tag() < $b->tag() ? -1 : 1; |
|
| 42 | + }); |
|
| 43 | + return $obj; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Sort by encoding ascending order. |
|
| 48 | - * Used for DER encoding of SET OF type. |
|
| 49 | - * |
|
| 50 | - * @return self |
|
| 51 | - */ |
|
| 52 | - public function sortedSetOf() |
|
| 53 | - { |
|
| 54 | - $obj = clone $this; |
|
| 55 | - usort($obj->_elements, |
|
| 56 | - function (Element $a, Element $b) { |
|
| 57 | - $a_der = $a->toDER(); |
|
| 58 | - $b_der = $b->toDER(); |
|
| 59 | - return strcmp($a_der, $b_der); |
|
| 60 | - }); |
|
| 61 | - return $obj; |
|
| 62 | - } |
|
| 46 | + /** |
|
| 47 | + * Sort by encoding ascending order. |
|
| 48 | + * Used for DER encoding of SET OF type. |
|
| 49 | + * |
|
| 50 | + * @return self |
|
| 51 | + */ |
|
| 52 | + public function sortedSetOf() |
|
| 53 | + { |
|
| 54 | + $obj = clone $this; |
|
| 55 | + usort($obj->_elements, |
|
| 56 | + function (Element $a, Element $b) { |
|
| 57 | + $a_der = $a->toDER(); |
|
| 58 | + $b_der = $b->toDER(); |
|
| 59 | + return strcmp($a_der, $b_der); |
|
| 60 | + }); |
|
| 61 | + return $obj; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -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); |
@@ -7,13 +7,13 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | trait PrimitiveType |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * |
|
| 12 | - * @see \ASN1\Element::isConstructed() |
|
| 13 | - * @return boolean |
|
| 14 | - */ |
|
| 15 | - public function isConstructed() |
|
| 16 | - { |
|
| 17 | - return false; |
|
| 18 | - } |
|
| 10 | + /** |
|
| 11 | + * |
|
| 12 | + * @see \ASN1\Element::isConstructed() |
|
| 13 | + * @return boolean |
|
| 14 | + */ |
|
| 15 | + public function isConstructed() |
|
| 16 | + { |
|
| 17 | + return false; |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -12,50 +12,50 @@ |
||
| 12 | 12 | * is not changed. |
| 13 | 13 | */ |
| 14 | 14 | class ExplicitlyTaggedType extends ContextSpecificTaggedType implements |
| 15 | - ExplicitTagging |
|
| 15 | + ExplicitTagging |
|
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param int $tag Tag number |
|
| 21 | - * @param Element $element Wrapped element |
|
| 22 | - */ |
|
| 23 | - public function __construct($tag, Element $element) |
|
| 24 | - { |
|
| 25 | - $this->_typeTag = $tag; |
|
| 26 | - $this->_element = $element; |
|
| 27 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param int $tag Tag number |
|
| 21 | + * @param Element $element Wrapped element |
|
| 22 | + */ |
|
| 23 | + public function __construct($tag, Element $element) |
|
| 24 | + { |
|
| 25 | + $this->_typeTag = $tag; |
|
| 26 | + $this->_element = $element; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * |
|
| 31 | - * @see \ASN1\Element::isConstructed() |
|
| 32 | - * @return bool |
|
| 33 | - */ |
|
| 34 | - public function isConstructed() |
|
| 35 | - { |
|
| 36 | - return true; |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * |
|
| 31 | + * @see \ASN1\Element::isConstructed() |
|
| 32 | + * @return bool |
|
| 33 | + */ |
|
| 34 | + public function isConstructed() |
|
| 35 | + { |
|
| 36 | + return true; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * |
|
| 41 | - * @see \ASN1\Element::_encodedContentDER() |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - protected function _encodedContentDER() |
|
| 45 | - { |
|
| 46 | - return $this->_element->toDER(); |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * |
|
| 41 | + * @see \ASN1\Element::_encodedContentDER() |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | + protected function _encodedContentDER() |
|
| 45 | + { |
|
| 46 | + return $this->_element->toDER(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * |
|
| 51 | - * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
| 52 | - * @return UnspecifiedType |
|
| 53 | - */ |
|
| 54 | - public function explicit($expectedTag = null) |
|
| 55 | - { |
|
| 56 | - if (isset($expectedTag)) { |
|
| 57 | - $this->_element->expectType($expectedTag); |
|
| 58 | - } |
|
| 59 | - return new UnspecifiedType($this->_element); |
|
| 60 | - } |
|
| 49 | + /** |
|
| 50 | + * |
|
| 51 | + * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
| 52 | + * @return UnspecifiedType |
|
| 53 | + */ |
|
| 54 | + public function explicit($expectedTag = null) |
|
| 55 | + { |
|
| 56 | + if (isset($expectedTag)) { |
|
| 57 | + $this->_element->expectType($expectedTag); |
|
| 58 | + } |
|
| 59 | + return new UnspecifiedType($this->_element); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -10,20 +10,20 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | abstract class ContextSpecificTaggedType extends TaggedType |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Wrapped element. |
|
| 15 | - * |
|
| 16 | - * @var \ASN1\Element $_element |
|
| 17 | - */ |
|
| 18 | - protected $_element; |
|
| 13 | + /** |
|
| 14 | + * Wrapped element. |
|
| 15 | + * |
|
| 16 | + * @var \ASN1\Element $_element |
|
| 17 | + */ |
|
| 18 | + protected $_element; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * |
|
| 22 | - * @see \ASN1\Element::typeClass() |
|
| 23 | - * @return int |
|
| 24 | - */ |
|
| 25 | - public function typeClass() |
|
| 26 | - { |
|
| 27 | - return Identifier::CLASS_CONTEXT_SPECIFIC; |
|
| 28 | - } |
|
| 20 | + /** |
|
| 21 | + * |
|
| 22 | + * @see \ASN1\Element::typeClass() |
|
| 23 | + * @return int |
|
| 24 | + */ |
|
| 25 | + public function typeClass() |
|
| 26 | + { |
|
| 27 | + return Identifier::CLASS_CONTEXT_SPECIFIC; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -14,55 +14,55 @@ |
||
| 14 | 14 | * decoding the data. |
| 15 | 15 | */ |
| 16 | 16 | class ImplicitlyTaggedType extends ContextSpecificTaggedType implements |
| 17 | - ImplicitTagging |
|
| 17 | + ImplicitTagging |
|
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param int $tag |
|
| 23 | - * @param Element $element |
|
| 24 | - */ |
|
| 25 | - public function __construct($tag, Element $element) |
|
| 26 | - { |
|
| 27 | - $this->_typeTag = $tag; |
|
| 28 | - $this->_element = $element; |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param int $tag |
|
| 23 | + * @param Element $element |
|
| 24 | + */ |
|
| 25 | + public function __construct($tag, Element $element) |
|
| 26 | + { |
|
| 27 | + $this->_typeTag = $tag; |
|
| 28 | + $this->_element = $element; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * |
|
| 33 | - * @see \ASN1\Element::isConstructed() |
|
| 34 | - * @return bool |
|
| 35 | - */ |
|
| 36 | - public function isConstructed() |
|
| 37 | - { |
|
| 38 | - // depends on the underlying type |
|
| 39 | - return $this->_element->isConstructed(); |
|
| 40 | - } |
|
| 31 | + /** |
|
| 32 | + * |
|
| 33 | + * @see \ASN1\Element::isConstructed() |
|
| 34 | + * @return bool |
|
| 35 | + */ |
|
| 36 | + public function isConstructed() |
|
| 37 | + { |
|
| 38 | + // depends on the underlying type |
|
| 39 | + return $this->_element->isConstructed(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * |
|
| 44 | - * @see \ASN1\Element::_encodedContentDER() |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 47 | - protected function _encodedContentDER() |
|
| 48 | - { |
|
| 49 | - return $this->_element->_encodedContentDER(); |
|
| 50 | - } |
|
| 42 | + /** |
|
| 43 | + * |
|
| 44 | + * @see \ASN1\Element::_encodedContentDER() |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | + protected function _encodedContentDER() |
|
| 48 | + { |
|
| 49 | + return $this->_element->_encodedContentDER(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * |
|
| 54 | - * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
| 55 | - * @return UnspecifiedType |
|
| 56 | - */ |
|
| 57 | - public function implicit($tag, $class = Identifier::CLASS_UNIVERSAL) |
|
| 58 | - { |
|
| 59 | - $this->_element->expectType($tag); |
|
| 60 | - if ($this->_element->typeClass() != $class) { |
|
| 61 | - throw new \UnexpectedValueException( |
|
| 62 | - sprintf("Type class %s expected, got %s.", |
|
| 63 | - Identifier::classToName($class), |
|
| 64 | - Identifier::classToName($this->_element->typeClass()))); |
|
| 65 | - } |
|
| 66 | - return new UnspecifiedType($this->_element); |
|
| 67 | - } |
|
| 52 | + /** |
|
| 53 | + * |
|
| 54 | + * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
| 55 | + * @return UnspecifiedType |
|
| 56 | + */ |
|
| 57 | + public function implicit($tag, $class = Identifier::CLASS_UNIVERSAL) |
|
| 58 | + { |
|
| 59 | + $this->_element->expectType($tag); |
|
| 60 | + if ($this->_element->typeClass() != $class) { |
|
| 61 | + throw new \UnexpectedValueException( |
|
| 62 | + sprintf("Type class %s expected, got %s.", |
|
| 63 | + Identifier::classToName($class), |
|
| 64 | + Identifier::classToName($this->_element->typeClass()))); |
|
| 65 | + } |
|
| 66 | + return new UnspecifiedType($this->_element); |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -9,15 +9,15 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | interface ExplicitTagging extends ElementBase |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Get explicitly tagged wrapped element. |
|
| 14 | - * |
|
| 15 | - * NOTE! Expectation checking is deprecated and shall be done |
|
| 16 | - * with UnspecifiedType. |
|
| 17 | - * |
|
| 18 | - * @param int|null $expectedTag Expected tag of the underlying type |
|
| 19 | - * @throws \UnexpectedValueException If expectation fails |
|
| 20 | - * @return \ASN1\Type\UnspecifiedType |
|
| 21 | - */ |
|
| 22 | - public function explicit($expectedTag = null); |
|
| 12 | + /** |
|
| 13 | + * Get explicitly tagged wrapped element. |
|
| 14 | + * |
|
| 15 | + * NOTE! Expectation checking is deprecated and shall be done |
|
| 16 | + * with UnspecifiedType. |
|
| 17 | + * |
|
| 18 | + * @param int|null $expectedTag Expected tag of the underlying type |
|
| 19 | + * @throws \UnexpectedValueException If expectation fails |
|
| 20 | + * @return \ASN1\Type\UnspecifiedType |
|
| 21 | + */ |
|
| 22 | + public function explicit($expectedTag = null); |
|
| 23 | 23 | } |