Conditions | 5 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | 8 | public function parse(string $rawBody) |
|
40 | { |
||
41 | 8 | if ($rawBody === '') { |
|
42 | 1 | return null; |
|
43 | } |
||
44 | |||
45 | try { |
||
46 | /** @var mixed $result */ |
||
47 | 7 | $result = json_decode($rawBody, $this->convertToAssociativeArray, $this->depth, $this->options); |
|
48 | 4 | if (is_array($result) || is_object($result)) { |
|
49 | 4 | return $result; |
|
50 | } |
||
51 | 3 | } catch (JsonException $e) { |
|
52 | 3 | throw new ParserException('Invalid JSON data in request body: ' . $e->getMessage()); |
|
53 | } |
||
54 | |||
55 | 2 | return null; |
|
56 | } |
||
58 |