| Conditions | 4 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 67 | protected static function _decodeFromDER(Identifier $identifier, |
|
| 35 | string $data, int &$offset): ElementBase |
||
| 36 | { |
||
| 37 | 67 | $idx = $offset; |
|
| 38 | 67 | if (!$identifier->isPrimitive()) { |
|
| 39 | 1 | throw new DecodeException('DER encoded string must be primitive.'); |
|
| 40 | } |
||
| 41 | 66 | $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 42 | 66 | $str = $length ? substr($data, $idx, $length) : ''; |
|
| 43 | // substr should never return false, since length is |
||
| 44 | // checked by Length::expectFromDER. |
||
| 45 | 66 | assert(is_string($str), new DecodeException('substr')); |
|
| 46 | 66 | $offset = $idx + $length; |
|
| 47 | try { |
||
| 48 | 66 | return new static($str); |
|
| 49 | 7 | } catch (\InvalidArgumentException $e) { |
|
| 50 | 7 | throw new DecodeException($e->getMessage(), 0, $e); |
|
| 51 | } |
||
| 54 |