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