| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | function readJson(string $service, string $file): array |
||
| 21 | { |
||
| 22 | $file = __DIR__ . '/responses/' . $service . '/' . $file . '.json'; |
||
| 23 | |||
| 24 | if (!file_exists($file)) { |
||
| 25 | throw new InvalidArgumentException('Invalid argument provided for json file.'); |
||
| 26 | } |
||
| 27 | |||
| 28 | try { |
||
| 29 | return json_decode( |
||
| 30 | file_get_contents($file), true, 512, JSON_THROW_ON_ERROR |
||
| 31 | ); |
||
| 32 | } catch (JsonException $exception) { |
||
| 33 | throw new \Exception('Invalid JSON provided.'); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |