Lines
0.00%
0 / 2
Methods
0.00%
0 / 2
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| encodeToJson | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| 10 | final class JsonEncoder | |
| 11 | { | |
| 12 | private const int ENCODE_FLAGS = \JSON_THROW_ON_ERROR | |
| 13 | | \JSON_PRESERVE_ZERO_FRACTION | |
| 14 | | \JSON_UNESCAPED_UNICODE | |
| 15 | | \JSON_UNESCAPED_SLASHES | |
| 16 | | \JSON_INVALID_UTF8_SUBSTITUTE; | |
| 17 | ||
| 18 | private function __construct() {} | |
| 19 | ||
| 20 | /** | |
| 21 | * @param int<1, max> $depth | |
| 22 | * @throws JsonException | |
| 23 | */ | |
| 24 | public static function encodeToJson(mixed $value, int $depth = 512): string | |
| 25 | { | |
| 26 | return json_encode($value, self::ENCODE_FLAGS, $depth); | |
| 27 | } | |
| 28 | } |