Total Complexity | 6 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
15 | class DERData extends Element |
||
16 | { |
||
17 | /** |
||
18 | * DER encoded data. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $_der; |
||
23 | |||
24 | /** |
||
25 | * Identifier of the underlying type. |
||
26 | * |
||
27 | * @var Identifier |
||
28 | */ |
||
29 | protected $_identifier; |
||
30 | |||
31 | /** |
||
32 | * Offset to the content in DER data. |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | protected $_contentOffset = 0; |
||
37 | |||
38 | /** |
||
39 | * Constructor. |
||
40 | * |
||
41 | * @param string $data DER encoded data |
||
42 | * |
||
43 | * @throws \Sop\ASN1\Exception\DecodeException If data does not adhere to DER |
||
44 | */ |
||
45 | 6 | public function __construct(string $data) |
|
46 | { |
||
47 | 6 | $this->_identifier = Identifier::fromDER($data, $this->_contentOffset); |
|
48 | // check that length encoding is valid |
||
49 | 6 | Length::expectFromDER($data, $this->_contentOffset); |
|
50 | 6 | $this->_der = $data; |
|
51 | 6 | $this->_typeTag = $this->_identifier->intTag(); |
|
52 | 6 | } |
|
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | 2 | public function typeClass(): int |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 2 | public function isConstructed(): bool |
|
66 | { |
||
67 | 2 | return $this->_identifier->isConstructed(); |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | 3 | public function toDER(): string |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 2 | protected function _encodedContentDER(): string |
|
90 |