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