| @@ 199-212 (lines=14) @@ | ||
| 196 | * @throws \UnexpectedValueException |
|
| 197 | * @return string |
|
| 198 | */ |
|
| 199 | private function _parseAttrType(&$offset) { |
|
| 200 | $idx = $offset; |
|
| 201 | // dotted OID |
|
| 202 | $type = $this->_regexMatch('/^(?:oid\.)?([0-9]+(?:\.[0-9]+)*)/i', $idx); |
|
| 203 | if (null === $type) { |
|
| 204 | // name |
|
| 205 | $type = $this->_regexMatch('/^[a-z][a-z0-9\-]*/i', $idx); |
|
| 206 | if (null === $type) { |
|
| 207 | throw new \UnexpectedValueException("Invalid attribute type."); |
|
| 208 | } |
|
| 209 | } |
|
| 210 | $offset = $idx; |
|
| 211 | return $type; |
|
| 212 | } |
|
| 213 | ||
| 214 | /** |
|
| 215 | * Parse 'attributeValue' of string type. |
|
| @@ 313-322 (lines=10) @@ | ||
| 310 | * @throws \UnexpectedValueException |
|
| 311 | * @return string |
|
| 312 | */ |
|
| 313 | private function _parseAttrHexValue(&$offset) { |
|
| 314 | $idx = $offset; |
|
| 315 | $hexstr = $this->_regexMatch('/^(?:[0-9a-f]{2})+/i', $idx); |
|
| 316 | if (null === $hexstr) { |
|
| 317 | throw new \UnexpectedValueException("Invalid hexstring."); |
|
| 318 | } |
|
| 319 | $data = hex2bin($hexstr); |
|
| 320 | $offset = $idx; |
|
| 321 | return $data; |
|
| 322 | } |
|
| 323 | ||
| 324 | /** |
|
| 325 | * Parse 'pair' after leading slash. |
|