Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 2 | public function __invoke(string $json): CalculationResponse |
|
28 | { |
||
29 | /** @var array $array */ |
||
30 | 2 | json_decode($json, true); |
|
31 | |||
32 | 2 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
33 | 1 | throw new \InvalidArgumentException('Invalid or malformed JSON'); |
|
34 | } |
||
35 | |||
36 | 1 | $serializer = (new SerializerFactory())(); |
|
37 | |||
38 | /** @var CalculationResponse $response */ |
||
39 | 1 | return $serializer->deserialize($json, CalculationResponse::class, 'json'); |
|
40 | } |
||
42 |