1 | <?php |
||
2 | |||
3 | namespace Cerbero\JsonParser\Decoders; |
||
4 | |||
5 | /** |
||
6 | * The decoder using the simdjson extension. |
||
7 | * |
||
8 | */ |
||
9 | final class SimdjsonDecoder extends AbstractDecoder |
||
10 | { |
||
11 | /** |
||
12 | * Instantiate the class. |
||
13 | * |
||
14 | * @param bool $decodesToArray |
||
15 | * @param int $depth |
||
16 | */ |
||
17 | 376 | public function __construct(private readonly bool $decodesToArray = true, private readonly int $depth = 512) |
|
18 | { |
||
19 | 376 | } |
|
20 | |||
21 | /** |
||
22 | * Retrieve the decoded value of the given JSON |
||
23 | * |
||
24 | * @param string $json |
||
25 | * @return mixed |
||
26 | * @throws \Throwable |
||
27 | */ |
||
28 | 263 | protected function decodeJson(string $json): mixed |
|
29 | { |
||
30 | 263 | return simdjson_decode($json, $this->decodesToArray, $this->depth); |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
31 | } |
||
32 | } |
||
33 |