Conditions | 3 |
Paths | 6 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
37 | 35 | public static function parse(ByteBuffer $buffer) |
|
38 | { |
||
39 | try { |
||
40 | 35 | $data = CborDecoder::decode($buffer); |
|
41 | 34 | if (!is_array($data)) { |
|
42 | 1 | throw new WebAuthnException('Expecting attestation object to be a CBOR map.'); |
|
43 | } |
||
44 | |||
45 | 33 | DataValidator::checkTypes( |
|
46 | 33 | $data, |
|
47 | [ |
||
48 | 33 | 'fmt' => 'string', |
|
49 | 'attStmt' => 'array', |
||
50 | 'authData' => ByteBuffer::class, |
||
51 | ] |
||
52 | ); |
||
53 | 30 | return new self($data['fmt'], $data['attStmt'], $data['authData']); |
|
54 | 5 | } catch (CborException $e) { |
|
55 | 1 | throw new ParseException('Failed to parse CBOR attestation object.', 0, $e); |
|
56 | } |
||
74 |