| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | function json_validate(string $json, int $depth = 512, int $flags = 0): bool |
||
| 6 | { |
||
| 7 | if (0 !== $flags && \JSON_INVALID_UTF8_IGNORE !== $flags) { |
||
| 8 | throw new \ValueError('json_validate(): Argument #3 ($flags) must be a |
||
| 9 | valid flag (allowed flags: JSON_INVALID_UTF8_IGNORE)'); |
||
| 10 | } |
||
| 11 | |||
| 12 | if ($depth <= 0) { |
||
| 13 | throw new \ValueError('json_validate(): Argument #2 ($depth) must be greater than 0'); |
||
| 14 | } |
||
| 15 | |||
| 16 | \json_decode($json, null, $depth, $flags); |
||
| 17 | |||
| 18 | return \JSON_ERROR_NONE === \json_last_error(); |
||
| 19 | } |
||
| 22 |