@@ -17,38 +17,38 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class NullType 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_NULL; |
|
| 29 | - } |
|
| 23 | + /** |
|
| 24 | + * Constructor. |
|
| 25 | + */ |
|
| 26 | + public function __construct() |
|
| 27 | + { |
|
| 28 | + $this->_typeTag = self::TYPE_NULL; |
|
| 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('Null value must be primitive.'); |
|
| 48 | - } |
|
| 49 | - // null 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('Null value must be primitive.'); |
|
| 48 | + } |
|
| 49 | + // null 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 | |
@@ -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,61 +17,61 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Boolean extends Element |
| 19 | 19 | { |
| 20 | - use UniversalClass; |
|
| 21 | - use PrimitiveType; |
|
| 20 | + use UniversalClass; |
|
| 21 | + use PrimitiveType; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Value. |
|
| 25 | - * |
|
| 26 | - * @var bool |
|
| 27 | - */ |
|
| 28 | - private $_bool; |
|
| 23 | + /** |
|
| 24 | + * Value. |
|
| 25 | + * |
|
| 26 | + * @var bool |
|
| 27 | + */ |
|
| 28 | + private $_bool; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Constructor. |
|
| 32 | - * |
|
| 33 | - * @param bool $bool |
|
| 34 | - */ |
|
| 35 | - public function __construct(bool $bool) |
|
| 36 | - { |
|
| 37 | - $this->_typeTag = self::TYPE_BOOLEAN; |
|
| 38 | - $this->_bool = $bool; |
|
| 39 | - } |
|
| 30 | + /** |
|
| 31 | + * Constructor. |
|
| 32 | + * |
|
| 33 | + * @param bool $bool |
|
| 34 | + */ |
|
| 35 | + public function __construct(bool $bool) |
|
| 36 | + { |
|
| 37 | + $this->_typeTag = self::TYPE_BOOLEAN; |
|
| 38 | + $this->_bool = $bool; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Get the value. |
|
| 43 | - * |
|
| 44 | - * @return bool |
|
| 45 | - */ |
|
| 46 | - public function value(): bool |
|
| 47 | - { |
|
| 48 | - return $this->_bool; |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * Get the value. |
|
| 43 | + * |
|
| 44 | + * @return bool |
|
| 45 | + */ |
|
| 46 | + public function value(): bool |
|
| 47 | + { |
|
| 48 | + return $this->_bool; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * {@inheritdoc} |
|
| 53 | - */ |
|
| 54 | - protected function _encodedContentDER(): string |
|
| 55 | - { |
|
| 56 | - return $this->_bool ? chr(0xff) : chr(0); |
|
| 57 | - } |
|
| 51 | + /** |
|
| 52 | + * {@inheritdoc} |
|
| 53 | + */ |
|
| 54 | + protected function _encodedContentDER(): string |
|
| 55 | + { |
|
| 56 | + return $this->_bool ? chr(0xff) : chr(0); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * {@inheritdoc} |
|
| 61 | - */ |
|
| 62 | - protected static function _decodeFromDER(Identifier $identifier, |
|
| 63 | - string $data, int &$offset): ElementBase |
|
| 64 | - { |
|
| 65 | - $idx = $offset; |
|
| 66 | - Length::expectFromDER($data, $idx, 1); |
|
| 67 | - $byte = ord($data[$idx++]); |
|
| 68 | - if (0 !== $byte) { |
|
| 69 | - if (0xff != $byte) { |
|
| 70 | - throw new DecodeException( |
|
| 71 | - 'DER encoded boolean true must have all bits set to 1.'); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - $offset = $idx; |
|
| 75 | - return new self(0 !== $byte); |
|
| 76 | - } |
|
| 59 | + /** |
|
| 60 | + * {@inheritdoc} |
|
| 61 | + */ |
|
| 62 | + protected static function _decodeFromDER(Identifier $identifier, |
|
| 63 | + string $data, int &$offset): ElementBase |
|
| 64 | + { |
|
| 65 | + $idx = $offset; |
|
| 66 | + Length::expectFromDER($data, $idx, 1); |
|
| 67 | + $byte = ord($data[$idx++]); |
|
| 68 | + if (0 !== $byte) { |
|
| 69 | + if (0xff != $byte) { |
|
| 70 | + throw new DecodeException( |
|
| 71 | + 'DER encoded boolean true must have all bits set to 1.'); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + $offset = $idx; |
|
| 75 | + return new self(0 !== $byte); |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -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,26 +12,26 @@ |
||
| 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 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _validateString(string $string): bool |
|
| 32 | - { |
|
| 33 | - // allow everything since there's literally |
|
| 34 | - // thousands of allowed characters (16 bit composed characters) |
|
| 35 | - return true; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _validateString(string $string): bool |
|
| 32 | + { |
|
| 33 | + // allow everything since there's literally |
|
| 34 | + // thousands of allowed characters (16 bit composed characters) |
|
| 35 | + return true; |
|
| 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 Sop\ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -17,110 +17,110 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class GeneralizedTime extends TimeType |
| 19 | 19 | { |
| 20 | - use UniversalClass; |
|
| 21 | - use PrimitiveType; |
|
| 20 | + use UniversalClass; |
|
| 21 | + use PrimitiveType; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Regular expression to parse date. |
|
| 25 | - * |
|
| 26 | - * DER restricts format to UTC timezone (Z suffix). |
|
| 27 | - * |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - const REGEX = '#^' . |
|
| 31 | - '(\d\d\d\d)' . // YYYY |
|
| 32 | - '(\d\d)' . // MM |
|
| 33 | - '(\d\d)' . // DD |
|
| 34 | - '(\d\d)' . // hh |
|
| 35 | - '(\d\d)' . // mm |
|
| 36 | - '(\d\d)' . // ss |
|
| 37 | - '(?:\.(\d+))?' . // frac |
|
| 38 | - 'Z' . // TZ |
|
| 39 | - '$#'; |
|
| 23 | + /** |
|
| 24 | + * Regular expression to parse date. |
|
| 25 | + * |
|
| 26 | + * DER restricts format to UTC timezone (Z suffix). |
|
| 27 | + * |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + const REGEX = '#^' . |
|
| 31 | + '(\d\d\d\d)' . // YYYY |
|
| 32 | + '(\d\d)' . // MM |
|
| 33 | + '(\d\d)' . // DD |
|
| 34 | + '(\d\d)' . // hh |
|
| 35 | + '(\d\d)' . // mm |
|
| 36 | + '(\d\d)' . // ss |
|
| 37 | + '(?:\.(\d+))?' . // frac |
|
| 38 | + 'Z' . // TZ |
|
| 39 | + '$#'; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Cached formatted date. |
|
| 43 | - * |
|
| 44 | - * @var null|string |
|
| 45 | - */ |
|
| 46 | - private $_formatted; |
|
| 41 | + /** |
|
| 42 | + * Cached formatted date. |
|
| 43 | + * |
|
| 44 | + * @var null|string |
|
| 45 | + */ |
|
| 46 | + private $_formatted; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Constructor. |
|
| 50 | - * |
|
| 51 | - * @param \DateTimeImmutable $dt |
|
| 52 | - */ |
|
| 53 | - public function __construct(\DateTimeImmutable $dt) |
|
| 54 | - { |
|
| 55 | - $this->_typeTag = self::TYPE_GENERALIZED_TIME; |
|
| 56 | - parent::__construct($dt); |
|
| 57 | - } |
|
| 48 | + /** |
|
| 49 | + * Constructor. |
|
| 50 | + * |
|
| 51 | + * @param \DateTimeImmutable $dt |
|
| 52 | + */ |
|
| 53 | + public function __construct(\DateTimeImmutable $dt) |
|
| 54 | + { |
|
| 55 | + $this->_typeTag = self::TYPE_GENERALIZED_TIME; |
|
| 56 | + parent::__construct($dt); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Clear cached variables on clone. |
|
| 61 | - */ |
|
| 62 | - public function __clone() |
|
| 63 | - { |
|
| 64 | - $this->_formatted = null; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * Clear cached variables on clone. |
|
| 61 | + */ |
|
| 62 | + public function __clone() |
|
| 63 | + { |
|
| 64 | + $this->_formatted = null; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * {@inheritdoc} |
|
| 69 | - */ |
|
| 70 | - protected function _encodedContentDER(): string |
|
| 71 | - { |
|
| 72 | - if (!isset($this->_formatted)) { |
|
| 73 | - $dt = $this->_dateTime->setTimezone( |
|
| 74 | - self::_createTimeZone(self::TZ_UTC)); |
|
| 75 | - $this->_formatted = $dt->format('YmdHis'); |
|
| 76 | - // if fractions were used |
|
| 77 | - $frac = $dt->format('u'); |
|
| 78 | - if (0 != $frac) { |
|
| 79 | - $frac = rtrim($frac, '0'); |
|
| 80 | - $this->_formatted .= ".${frac}"; |
|
| 81 | - } |
|
| 82 | - // timezone |
|
| 83 | - $this->_formatted .= 'Z'; |
|
| 84 | - } |
|
| 85 | - return $this->_formatted; |
|
| 86 | - } |
|
| 67 | + /** |
|
| 68 | + * {@inheritdoc} |
|
| 69 | + */ |
|
| 70 | + protected function _encodedContentDER(): string |
|
| 71 | + { |
|
| 72 | + if (!isset($this->_formatted)) { |
|
| 73 | + $dt = $this->_dateTime->setTimezone( |
|
| 74 | + self::_createTimeZone(self::TZ_UTC)); |
|
| 75 | + $this->_formatted = $dt->format('YmdHis'); |
|
| 76 | + // if fractions were used |
|
| 77 | + $frac = $dt->format('u'); |
|
| 78 | + if (0 != $frac) { |
|
| 79 | + $frac = rtrim($frac, '0'); |
|
| 80 | + $this->_formatted .= ".${frac}"; |
|
| 81 | + } |
|
| 82 | + // timezone |
|
| 83 | + $this->_formatted .= 'Z'; |
|
| 84 | + } |
|
| 85 | + return $this->_formatted; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * {@inheritdoc} |
|
| 90 | - */ |
|
| 91 | - protected static function _decodeFromDER(Identifier $identifier, |
|
| 92 | - string $data, int &$offset): ElementBase |
|
| 93 | - { |
|
| 94 | - $idx = $offset; |
|
| 95 | - $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 96 | - $str = substr($data, $idx, $length); |
|
| 97 | - $idx += $length; |
|
| 98 | - /** @var string[] $match */ |
|
| 99 | - if (!preg_match(self::REGEX, $str, $match)) { |
|
| 100 | - throw new DecodeException('Invalid GeneralizedTime format.'); |
|
| 101 | - } |
|
| 102 | - [, $year, $month, $day, $hour, $minute, $second] = $match; |
|
| 103 | - if (isset($match[7])) { |
|
| 104 | - $frac = $match[7]; |
|
| 105 | - // DER restricts trailing zeroes in fractional seconds component |
|
| 106 | - if ('0' === $frac[strlen($frac) - 1]) { |
|
| 107 | - throw new DecodeException( |
|
| 108 | - 'Fractional seconds must omit trailing zeroes.'); |
|
| 109 | - } |
|
| 110 | - $frac = (int) $frac; |
|
| 111 | - } else { |
|
| 112 | - $frac = 0; |
|
| 113 | - } |
|
| 114 | - $time = $year . $month . $day . $hour . $minute . $second . '.' . $frac . |
|
| 115 | - self::TZ_UTC; |
|
| 116 | - $dt = \DateTimeImmutable::createFromFormat('!YmdHis.uT', $time, |
|
| 117 | - self::_createTimeZone(self::TZ_UTC)); |
|
| 118 | - if (!$dt) { |
|
| 119 | - throw new DecodeException( |
|
| 120 | - 'Failed to decode GeneralizedTime: ' . |
|
| 121 | - self::_getLastDateTimeImmutableErrorsStr()); |
|
| 122 | - } |
|
| 123 | - $offset = $idx; |
|
| 124 | - return new self($dt); |
|
| 125 | - } |
|
| 88 | + /** |
|
| 89 | + * {@inheritdoc} |
|
| 90 | + */ |
|
| 91 | + protected static function _decodeFromDER(Identifier $identifier, |
|
| 92 | + string $data, int &$offset): ElementBase |
|
| 93 | + { |
|
| 94 | + $idx = $offset; |
|
| 95 | + $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 96 | + $str = substr($data, $idx, $length); |
|
| 97 | + $idx += $length; |
|
| 98 | + /** @var string[] $match */ |
|
| 99 | + if (!preg_match(self::REGEX, $str, $match)) { |
|
| 100 | + throw new DecodeException('Invalid GeneralizedTime format.'); |
|
| 101 | + } |
|
| 102 | + [, $year, $month, $day, $hour, $minute, $second] = $match; |
|
| 103 | + if (isset($match[7])) { |
|
| 104 | + $frac = $match[7]; |
|
| 105 | + // DER restricts trailing zeroes in fractional seconds component |
|
| 106 | + if ('0' === $frac[strlen($frac) - 1]) { |
|
| 107 | + throw new DecodeException( |
|
| 108 | + 'Fractional seconds must omit trailing zeroes.'); |
|
| 109 | + } |
|
| 110 | + $frac = (int) $frac; |
|
| 111 | + } else { |
|
| 112 | + $frac = 0; |
|
| 113 | + } |
|
| 114 | + $time = $year . $month . $day . $hour . $minute . $second . '.' . $frac . |
|
| 115 | + self::TZ_UTC; |
|
| 116 | + $dt = \DateTimeImmutable::createFromFormat('!YmdHis.uT', $time, |
|
| 117 | + self::_createTimeZone(self::TZ_UTC)); |
|
| 118 | + if (!$dt) { |
|
| 119 | + throw new DecodeException( |
|
| 120 | + 'Failed to decode GeneralizedTime: ' . |
|
| 121 | + self::_getLastDateTimeImmutableErrorsStr()); |
|
| 122 | + } |
|
| 123 | + $offset = $idx; |
|
| 124 | + return new self($dt); |
|
| 125 | + } |
|
| 126 | 126 | } |
@@ -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 | |
@@ -14,24 +14,24 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class UTF8String extends PrimitiveString |
| 16 | 16 | { |
| 17 | - use UniversalClass; |
|
| 17 | + use UniversalClass; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string $string |
|
| 23 | - */ |
|
| 24 | - public function __construct(string $string) |
|
| 25 | - { |
|
| 26 | - $this->_typeTag = self::TYPE_UTF8_STRING; |
|
| 27 | - parent::__construct($string); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string $string |
|
| 23 | + */ |
|
| 24 | + public function __construct(string $string) |
|
| 25 | + { |
|
| 26 | + $this->_typeTag = self::TYPE_UTF8_STRING; |
|
| 27 | + parent::__construct($string); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - protected function _validateString(string $string): bool |
|
| 34 | - { |
|
| 35 | - return mb_check_encoding($string, 'UTF-8'); |
|
| 36 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + protected function _validateString(string $string): bool |
|
| 34 | + { |
|
| 35 | + return mb_check_encoding($string, 'UTF-8'); |
|
| 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 Sop\ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -14,28 +14,28 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class UniversalString extends PrimitiveString |
| 16 | 16 | { |
| 17 | - use UniversalClass; |
|
| 17 | + use UniversalClass; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string $string |
|
| 23 | - */ |
|
| 24 | - public function __construct(string $string) |
|
| 25 | - { |
|
| 26 | - $this->_typeTag = self::TYPE_UNIVERSAL_STRING; |
|
| 27 | - parent::__construct($string); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string $string |
|
| 23 | + */ |
|
| 24 | + public function __construct(string $string) |
|
| 25 | + { |
|
| 26 | + $this->_typeTag = self::TYPE_UNIVERSAL_STRING; |
|
| 27 | + parent::__construct($string); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - protected function _validateString(string $string): bool |
|
| 34 | - { |
|
| 35 | - // UCS-4 has fixed with of 4 octets (32 bits) |
|
| 36 | - if (0 != strlen($string) % 4) { |
|
| 37 | - return false; |
|
| 38 | - } |
|
| 39 | - return true; |
|
| 40 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + protected function _validateString(string $string): bool |
|
| 34 | + { |
|
| 35 | + // UCS-4 has fixed with of 4 octets (32 bits) |
|
| 36 | + if (0 != strlen($string) % 4) { |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 39 | + return true; |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -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,195 +17,195 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class BitString extends StringType |
| 19 | 19 | { |
| 20 | - use UniversalClass; |
|
| 21 | - use PrimitiveType; |
|
| 20 | + use UniversalClass; |
|
| 21 | + use PrimitiveType; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Number of unused bits in the last octet. |
|
| 25 | - * |
|
| 26 | - * @var int |
|
| 27 | - */ |
|
| 28 | - protected $_unusedBits; |
|
| 23 | + /** |
|
| 24 | + * Number of unused bits in the last octet. |
|
| 25 | + * |
|
| 26 | + * @var int |
|
| 27 | + */ |
|
| 28 | + protected $_unusedBits; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Constructor. |
|
| 32 | - * |
|
| 33 | - * @param string $string Content octets |
|
| 34 | - * @param int $unused_bits Number of unused bits in the last octet |
|
| 35 | - */ |
|
| 36 | - public function __construct(string $string, int $unused_bits = 0) |
|
| 37 | - { |
|
| 38 | - $this->_typeTag = self::TYPE_BIT_STRING; |
|
| 39 | - parent::__construct($string); |
|
| 40 | - $this->_unusedBits = $unused_bits; |
|
| 41 | - } |
|
| 30 | + /** |
|
| 31 | + * Constructor. |
|
| 32 | + * |
|
| 33 | + * @param string $string Content octets |
|
| 34 | + * @param int $unused_bits Number of unused bits in the last octet |
|
| 35 | + */ |
|
| 36 | + public function __construct(string $string, int $unused_bits = 0) |
|
| 37 | + { |
|
| 38 | + $this->_typeTag = self::TYPE_BIT_STRING; |
|
| 39 | + parent::__construct($string); |
|
| 40 | + $this->_unusedBits = $unused_bits; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Get the number of bits in the string. |
|
| 45 | - * |
|
| 46 | - * @return int |
|
| 47 | - */ |
|
| 48 | - public function numBits(): int |
|
| 49 | - { |
|
| 50 | - return strlen($this->_string) * 8 - $this->_unusedBits; |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * Get the number of bits in the string. |
|
| 45 | + * |
|
| 46 | + * @return int |
|
| 47 | + */ |
|
| 48 | + public function numBits(): int |
|
| 49 | + { |
|
| 50 | + return strlen($this->_string) * 8 - $this->_unusedBits; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Get the number of unused bits in the last octet of the string. |
|
| 55 | - * |
|
| 56 | - * @return int |
|
| 57 | - */ |
|
| 58 | - public function unusedBits(): int |
|
| 59 | - { |
|
| 60 | - return $this->_unusedBits; |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Get the number of unused bits in the last octet of the string. |
|
| 55 | + * |
|
| 56 | + * @return int |
|
| 57 | + */ |
|
| 58 | + public function unusedBits(): int |
|
| 59 | + { |
|
| 60 | + return $this->_unusedBits; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Test whether bit is set. |
|
| 65 | - * |
|
| 66 | - * @param int $idx Bit index. |
|
| 67 | - * Most significant bit of the first octet is index 0. |
|
| 68 | - * |
|
| 69 | - * @return bool |
|
| 70 | - */ |
|
| 71 | - public function testBit(int $idx): bool |
|
| 72 | - { |
|
| 73 | - // octet index |
|
| 74 | - $oi = (int) floor($idx / 8); |
|
| 75 | - // if octet is outside range |
|
| 76 | - if ($oi < 0 || $oi >= strlen($this->_string)) { |
|
| 77 | - throw new \OutOfBoundsException('Index is out of bounds.'); |
|
| 78 | - } |
|
| 79 | - // bit index |
|
| 80 | - $bi = $idx % 8; |
|
| 81 | - // if tested bit is last octet's unused bit |
|
| 82 | - if ($oi == strlen($this->_string) - 1) { |
|
| 83 | - if ($bi >= 8 - $this->_unusedBits) { |
|
| 84 | - throw new \OutOfBoundsException( |
|
| 85 | - 'Index refers to an unused bit.'); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - $byte = $this->_string[$oi]; |
|
| 89 | - // index 0 is the most significant bit in byte |
|
| 90 | - $mask = 0x01 << (7 - $bi); |
|
| 91 | - return (ord($byte) & $mask) > 0; |
|
| 92 | - } |
|
| 63 | + /** |
|
| 64 | + * Test whether bit is set. |
|
| 65 | + * |
|
| 66 | + * @param int $idx Bit index. |
|
| 67 | + * Most significant bit of the first octet is index 0. |
|
| 68 | + * |
|
| 69 | + * @return bool |
|
| 70 | + */ |
|
| 71 | + public function testBit(int $idx): bool |
|
| 72 | + { |
|
| 73 | + // octet index |
|
| 74 | + $oi = (int) floor($idx / 8); |
|
| 75 | + // if octet is outside range |
|
| 76 | + if ($oi < 0 || $oi >= strlen($this->_string)) { |
|
| 77 | + throw new \OutOfBoundsException('Index is out of bounds.'); |
|
| 78 | + } |
|
| 79 | + // bit index |
|
| 80 | + $bi = $idx % 8; |
|
| 81 | + // if tested bit is last octet's unused bit |
|
| 82 | + if ($oi == strlen($this->_string) - 1) { |
|
| 83 | + if ($bi >= 8 - $this->_unusedBits) { |
|
| 84 | + throw new \OutOfBoundsException( |
|
| 85 | + 'Index refers to an unused bit.'); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + $byte = $this->_string[$oi]; |
|
| 89 | + // index 0 is the most significant bit in byte |
|
| 90 | + $mask = 0x01 << (7 - $bi); |
|
| 91 | + return (ord($byte) & $mask) > 0; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Get range of bits. |
|
| 96 | - * |
|
| 97 | - * @param int $start Index of first bit |
|
| 98 | - * @param int $length Number of bits in range |
|
| 99 | - * |
|
| 100 | - * @throws \OutOfBoundsException |
|
| 101 | - * |
|
| 102 | - * @return string Integer of $length bits |
|
| 103 | - */ |
|
| 104 | - public function range(int $start, int $length): string |
|
| 105 | - { |
|
| 106 | - if (!$length) { |
|
| 107 | - return '0'; |
|
| 108 | - } |
|
| 109 | - if ($start + $length > $this->numBits()) { |
|
| 110 | - throw new \OutOfBoundsException('Not enough bits.'); |
|
| 111 | - } |
|
| 112 | - $bits = gmp_init(0); |
|
| 113 | - $idx = $start; |
|
| 114 | - $end = $start + $length; |
|
| 115 | - while (true) { |
|
| 116 | - $bit = $this->testBit($idx) ? 1 : 0; |
|
| 117 | - $bits |= $bit; |
|
| 118 | - if (++$idx >= $end) { |
|
| 119 | - break; |
|
| 120 | - } |
|
| 121 | - $bits <<= 1; |
|
| 122 | - } |
|
| 123 | - return gmp_strval($bits, 10); |
|
| 124 | - } |
|
| 94 | + /** |
|
| 95 | + * Get range of bits. |
|
| 96 | + * |
|
| 97 | + * @param int $start Index of first bit |
|
| 98 | + * @param int $length Number of bits in range |
|
| 99 | + * |
|
| 100 | + * @throws \OutOfBoundsException |
|
| 101 | + * |
|
| 102 | + * @return string Integer of $length bits |
|
| 103 | + */ |
|
| 104 | + public function range(int $start, int $length): string |
|
| 105 | + { |
|
| 106 | + if (!$length) { |
|
| 107 | + return '0'; |
|
| 108 | + } |
|
| 109 | + if ($start + $length > $this->numBits()) { |
|
| 110 | + throw new \OutOfBoundsException('Not enough bits.'); |
|
| 111 | + } |
|
| 112 | + $bits = gmp_init(0); |
|
| 113 | + $idx = $start; |
|
| 114 | + $end = $start + $length; |
|
| 115 | + while (true) { |
|
| 116 | + $bit = $this->testBit($idx) ? 1 : 0; |
|
| 117 | + $bits |= $bit; |
|
| 118 | + if (++$idx >= $end) { |
|
| 119 | + break; |
|
| 120 | + } |
|
| 121 | + $bits <<= 1; |
|
| 122 | + } |
|
| 123 | + return gmp_strval($bits, 10); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Get a copy of the bit string with trailing zeroes removed. |
|
| 128 | - * |
|
| 129 | - * @return self |
|
| 130 | - */ |
|
| 131 | - public function withoutTrailingZeroes(): self |
|
| 132 | - { |
|
| 133 | - // if bit string was empty |
|
| 134 | - if (!strlen($this->_string)) { |
|
| 135 | - return new self(''); |
|
| 136 | - } |
|
| 137 | - $bits = $this->_string; |
|
| 138 | - // count number of empty trailing octets |
|
| 139 | - $unused_octets = 0; |
|
| 140 | - for ($idx = strlen($bits) - 1; $idx >= 0; --$idx, ++$unused_octets) { |
|
| 141 | - if ("\x0" != $bits[$idx]) { |
|
| 142 | - break; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - // strip trailing octets |
|
| 146 | - if ($unused_octets) { |
|
| 147 | - $bits = substr($bits, 0, -$unused_octets); |
|
| 148 | - } |
|
| 149 | - // if bit string was full of zeroes |
|
| 150 | - if (!strlen($bits)) { |
|
| 151 | - return new self(''); |
|
| 152 | - } |
|
| 153 | - // count number of trailing zeroes in the last octet |
|
| 154 | - $unused_bits = 0; |
|
| 155 | - $byte = ord($bits[strlen($bits) - 1]); |
|
| 156 | - while (!($byte & 0x01)) { |
|
| 157 | - ++$unused_bits; |
|
| 158 | - $byte >>= 1; |
|
| 159 | - } |
|
| 160 | - return new self($bits, $unused_bits); |
|
| 161 | - } |
|
| 126 | + /** |
|
| 127 | + * Get a copy of the bit string with trailing zeroes removed. |
|
| 128 | + * |
|
| 129 | + * @return self |
|
| 130 | + */ |
|
| 131 | + public function withoutTrailingZeroes(): self |
|
| 132 | + { |
|
| 133 | + // if bit string was empty |
|
| 134 | + if (!strlen($this->_string)) { |
|
| 135 | + return new self(''); |
|
| 136 | + } |
|
| 137 | + $bits = $this->_string; |
|
| 138 | + // count number of empty trailing octets |
|
| 139 | + $unused_octets = 0; |
|
| 140 | + for ($idx = strlen($bits) - 1; $idx >= 0; --$idx, ++$unused_octets) { |
|
| 141 | + if ("\x0" != $bits[$idx]) { |
|
| 142 | + break; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + // strip trailing octets |
|
| 146 | + if ($unused_octets) { |
|
| 147 | + $bits = substr($bits, 0, -$unused_octets); |
|
| 148 | + } |
|
| 149 | + // if bit string was full of zeroes |
|
| 150 | + if (!strlen($bits)) { |
|
| 151 | + return new self(''); |
|
| 152 | + } |
|
| 153 | + // count number of trailing zeroes in the last octet |
|
| 154 | + $unused_bits = 0; |
|
| 155 | + $byte = ord($bits[strlen($bits) - 1]); |
|
| 156 | + while (!($byte & 0x01)) { |
|
| 157 | + ++$unused_bits; |
|
| 158 | + $byte >>= 1; |
|
| 159 | + } |
|
| 160 | + return new self($bits, $unused_bits); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * {@inheritdoc} |
|
| 165 | - */ |
|
| 166 | - protected function _encodedContentDER(): string |
|
| 167 | - { |
|
| 168 | - $der = chr($this->_unusedBits); |
|
| 169 | - $der .= $this->_string; |
|
| 170 | - if ($this->_unusedBits) { |
|
| 171 | - $octet = $der[strlen($der) - 1]; |
|
| 172 | - // set unused bits to zero |
|
| 173 | - $octet &= chr(0xff & ~((1 << $this->_unusedBits) - 1)); |
|
| 174 | - $der[strlen($der) - 1] = $octet; |
|
| 175 | - } |
|
| 176 | - return $der; |
|
| 177 | - } |
|
| 163 | + /** |
|
| 164 | + * {@inheritdoc} |
|
| 165 | + */ |
|
| 166 | + protected function _encodedContentDER(): string |
|
| 167 | + { |
|
| 168 | + $der = chr($this->_unusedBits); |
|
| 169 | + $der .= $this->_string; |
|
| 170 | + if ($this->_unusedBits) { |
|
| 171 | + $octet = $der[strlen($der) - 1]; |
|
| 172 | + // set unused bits to zero |
|
| 173 | + $octet &= chr(0xff & ~((1 << $this->_unusedBits) - 1)); |
|
| 174 | + $der[strlen($der) - 1] = $octet; |
|
| 175 | + } |
|
| 176 | + return $der; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * {@inheritdoc} |
|
| 181 | - */ |
|
| 182 | - protected static function _decodeFromDER(Identifier $identifier, |
|
| 183 | - string $data, int &$offset): ElementBase |
|
| 184 | - { |
|
| 185 | - $idx = $offset; |
|
| 186 | - $length = Length::expectFromDER($data, $idx); |
|
| 187 | - if ($length->intLength() < 1) { |
|
| 188 | - throw new DecodeException('Bit string length must be at least 1.'); |
|
| 189 | - } |
|
| 190 | - $unused_bits = ord($data[$idx++]); |
|
| 191 | - if ($unused_bits > 7) { |
|
| 192 | - throw new DecodeException( |
|
| 193 | - 'Unused bits in a bit string must be less than 8.'); |
|
| 194 | - } |
|
| 195 | - $str_len = $length->intLength() - 1; |
|
| 196 | - if ($str_len) { |
|
| 197 | - $str = substr($data, $idx, $str_len); |
|
| 198 | - if ($unused_bits) { |
|
| 199 | - $mask = (1 << $unused_bits) - 1; |
|
| 200 | - if (ord($str[strlen($str) - 1]) & $mask) { |
|
| 201 | - throw new DecodeException( |
|
| 202 | - 'DER encoded bit string must have zero padding.'); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } else { |
|
| 206 | - $str = ''; |
|
| 207 | - } |
|
| 208 | - $offset = $idx + $str_len; |
|
| 209 | - return new self($str, $unused_bits); |
|
| 210 | - } |
|
| 179 | + /** |
|
| 180 | + * {@inheritdoc} |
|
| 181 | + */ |
|
| 182 | + protected static function _decodeFromDER(Identifier $identifier, |
|
| 183 | + string $data, int &$offset): ElementBase |
|
| 184 | + { |
|
| 185 | + $idx = $offset; |
|
| 186 | + $length = Length::expectFromDER($data, $idx); |
|
| 187 | + if ($length->intLength() < 1) { |
|
| 188 | + throw new DecodeException('Bit string length must be at least 1.'); |
|
| 189 | + } |
|
| 190 | + $unused_bits = ord($data[$idx++]); |
|
| 191 | + if ($unused_bits > 7) { |
|
| 192 | + throw new DecodeException( |
|
| 193 | + 'Unused bits in a bit string must be less than 8.'); |
|
| 194 | + } |
|
| 195 | + $str_len = $length->intLength() - 1; |
|
| 196 | + if ($str_len) { |
|
| 197 | + $str = substr($data, $idx, $str_len); |
|
| 198 | + if ($unused_bits) { |
|
| 199 | + $mask = (1 << $unused_bits) - 1; |
|
| 200 | + if (ord($str[strlen($str) - 1]) & $mask) { |
|
| 201 | + throw new DecodeException( |
|
| 202 | + 'DER encoded bit string must have zero padding.'); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } else { |
|
| 206 | + $str = ''; |
|
| 207 | + } |
|
| 208 | + $offset = $idx + $str_len; |
|
| 209 | + return new self($str, $unused_bits); |
|
| 210 | + } |
|
| 211 | 211 | } |
@@ -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,70 +17,70 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class UTCTime extends TimeType |
| 19 | 19 | { |
| 20 | - use UniversalClass; |
|
| 21 | - use PrimitiveType; |
|
| 20 | + use UniversalClass; |
|
| 21 | + use PrimitiveType; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Regular expression to parse date. |
|
| 25 | - * |
|
| 26 | - * DER restricts format to UTC timezone (Z suffix). |
|
| 27 | - * |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - const REGEX = '#^' . |
|
| 31 | - '(\d\d)' . // YY |
|
| 32 | - '(\d\d)' . // MM |
|
| 33 | - '(\d\d)' . // DD |
|
| 34 | - '(\d\d)' . // hh |
|
| 35 | - '(\d\d)' . // mm |
|
| 36 | - '(\d\d)' . // ss |
|
| 37 | - 'Z' . // TZ |
|
| 38 | - '$#'; |
|
| 23 | + /** |
|
| 24 | + * Regular expression to parse date. |
|
| 25 | + * |
|
| 26 | + * DER restricts format to UTC timezone (Z suffix). |
|
| 27 | + * |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + const REGEX = '#^' . |
|
| 31 | + '(\d\d)' . // YY |
|
| 32 | + '(\d\d)' . // MM |
|
| 33 | + '(\d\d)' . // DD |
|
| 34 | + '(\d\d)' . // hh |
|
| 35 | + '(\d\d)' . // mm |
|
| 36 | + '(\d\d)' . // ss |
|
| 37 | + 'Z' . // TZ |
|
| 38 | + '$#'; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Constructor. |
|
| 42 | - * |
|
| 43 | - * @param \DateTimeImmutable $dt |
|
| 44 | - */ |
|
| 45 | - public function __construct(\DateTimeImmutable $dt) |
|
| 46 | - { |
|
| 47 | - $this->_typeTag = self::TYPE_UTC_TIME; |
|
| 48 | - parent::__construct($dt); |
|
| 49 | - } |
|
| 40 | + /** |
|
| 41 | + * Constructor. |
|
| 42 | + * |
|
| 43 | + * @param \DateTimeImmutable $dt |
|
| 44 | + */ |
|
| 45 | + public function __construct(\DateTimeImmutable $dt) |
|
| 46 | + { |
|
| 47 | + $this->_typeTag = self::TYPE_UTC_TIME; |
|
| 48 | + parent::__construct($dt); |
|
| 49 | + } |
|
| 50 | 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 | - } |
|
| 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 | - * {@inheritdoc} |
|
| 62 | - */ |
|
| 63 | - protected static function _decodeFromDER(Identifier $identifier, |
|
| 64 | - string $data, int &$offset): ElementBase |
|
| 65 | - { |
|
| 66 | - $idx = $offset; |
|
| 67 | - $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 68 | - $str = substr($data, $idx, $length); |
|
| 69 | - $idx += $length; |
|
| 70 | - /** @var string[] $match */ |
|
| 71 | - if (!preg_match(self::REGEX, $str, $match)) { |
|
| 72 | - throw new DecodeException('Invalid UTCTime format.'); |
|
| 73 | - } |
|
| 74 | - [, $year, $month, $day, $hour, $minute, $second] = $match; |
|
| 75 | - $time = $year . $month . $day . $hour . $minute . $second . self::TZ_UTC; |
|
| 76 | - $dt = \DateTimeImmutable::createFromFormat('!ymdHisT', $time, |
|
| 77 | - self::_createTimeZone(self::TZ_UTC)); |
|
| 78 | - if (!$dt) { |
|
| 79 | - throw new DecodeException( |
|
| 80 | - 'Failed to decode UTCTime: ' . |
|
| 81 | - self::_getLastDateTimeImmutableErrorsStr()); |
|
| 82 | - } |
|
| 83 | - $offset = $idx; |
|
| 84 | - return new self($dt); |
|
| 85 | - } |
|
| 60 | + /** |
|
| 61 | + * {@inheritdoc} |
|
| 62 | + */ |
|
| 63 | + protected static function _decodeFromDER(Identifier $identifier, |
|
| 64 | + string $data, int &$offset): ElementBase |
|
| 65 | + { |
|
| 66 | + $idx = $offset; |
|
| 67 | + $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 68 | + $str = substr($data, $idx, $length); |
|
| 69 | + $idx += $length; |
|
| 70 | + /** @var string[] $match */ |
|
| 71 | + if (!preg_match(self::REGEX, $str, $match)) { |
|
| 72 | + throw new DecodeException('Invalid UTCTime format.'); |
|
| 73 | + } |
|
| 74 | + [, $year, $month, $day, $hour, $minute, $second] = $match; |
|
| 75 | + $time = $year . $month . $day . $hour . $minute . $second . self::TZ_UTC; |
|
| 76 | + $dt = \DateTimeImmutable::createFromFormat('!ymdHisT', $time, |
|
| 77 | + self::_createTimeZone(self::TZ_UTC)); |
|
| 78 | + if (!$dt) { |
|
| 79 | + throw new DecodeException( |
|
| 80 | + 'Failed to decode UTCTime: ' . |
|
| 81 | + self::_getLastDateTimeImmutableErrorsStr()); |
|
| 82 | + } |
|
| 83 | + $offset = $idx; |
|
| 84 | + return new self($dt); |
|
| 85 | + } |
|
| 86 | 86 | } |
@@ -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 | |