@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | public static function fromASN1(UnspecifiedType $el) |
| 54 | 54 | { |
| 55 | 55 | switch ($el->tag()) { |
| 56 | - case Element::TYPE_OCTET_STRING: |
|
| 57 | - case Element::TYPE_UTF8_STRING: |
|
| 58 | - return new self($el->asString()->string(), $el->tag()); |
|
| 59 | - case Element::TYPE_OBJECT_IDENTIFIER: |
|
| 60 | - return new self($el->asObjectIdentifier()->oid(), $el->tag()); |
|
| 56 | + case Element::TYPE_OCTET_STRING: |
|
| 57 | + case Element::TYPE_UTF8_STRING: |
|
| 58 | + return new self($el->asString()->string(), $el->tag()); |
|
| 59 | + case Element::TYPE_OBJECT_IDENTIFIER: |
|
| 60 | + return new self($el->asObjectIdentifier()->oid(), $el->tag()); |
|
| 61 | 61 | } |
| 62 | 62 | throw new \UnexpectedValueException( |
| 63 | 63 | "Type " . Element::tagToName($el->tag()) . " not supported."); |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | public function toASN1(): Element |
| 156 | 156 | { |
| 157 | 157 | switch ($this->_type) { |
| 158 | - case Element::TYPE_OCTET_STRING: |
|
| 159 | - return new OctetString($this->_value); |
|
| 160 | - case Element::TYPE_UTF8_STRING: |
|
| 161 | - return new UTF8String($this->_value); |
|
| 162 | - case Element::TYPE_OBJECT_IDENTIFIER: |
|
| 163 | - return new ObjectIdentifier($this->_value); |
|
| 158 | + case Element::TYPE_OCTET_STRING: |
|
| 159 | + return new OctetString($this->_value); |
|
| 160 | + case Element::TYPE_UTF8_STRING: |
|
| 161 | + return new UTF8String($this->_value); |
|
| 162 | + case Element::TYPE_OBJECT_IDENTIFIER: |
|
| 163 | + return new ObjectIdentifier($this->_value); |
|
| 164 | 164 | } |
| 165 | 165 | throw new \LogicException( |
| 166 | 166 | "Type " . Element::tagToName($this->_type) . " not supported."); |
@@ -89,16 +89,16 @@ |
||
| 89 | 89 | { |
| 90 | 90 | $dt = $this->_dt; |
| 91 | 91 | switch ($this->_type) { |
| 92 | - case Element::TYPE_UTC_TIME: |
|
| 93 | - return new UTCTime($dt); |
|
| 94 | - case Element::TYPE_GENERALIZED_TIME: |
|
| 95 | - // GeneralizedTime must not contain fractional seconds |
|
| 96 | - // (rfc5280 4.1.2.5.2) |
|
| 97 | - if ($dt->format("u") != 0) { |
|
| 98 | - // remove fractional seconds (round down) |
|
| 99 | - $dt = self::_roundDownFractionalSeconds($dt); |
|
| 100 | - } |
|
| 101 | - return new GeneralizedTime($dt); |
|
| 92 | + case Element::TYPE_UTC_TIME: |
|
| 93 | + return new UTCTime($dt); |
|
| 94 | + case Element::TYPE_GENERALIZED_TIME: |
|
| 95 | + // GeneralizedTime must not contain fractional seconds |
|
| 96 | + // (rfc5280 4.1.2.5.2) |
|
| 97 | + if ($dt->format("u") != 0) { |
|
| 98 | + // remove fractional seconds (round down) |
|
| 99 | + $dt = self::_roundDownFractionalSeconds($dt); |
|
| 100 | + } |
|
| 101 | + return new GeneralizedTime($dt); |
|
| 102 | 102 | } |
| 103 | 103 | throw new \UnexpectedValueException( |
| 104 | 104 | "Time type " . Element::tagToName($this->_type) . " not supported."); |