SimdjsonDecoder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
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
The function simdjson_decode was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return /** @scrutinizer ignore-call */ simdjson_decode($json, $this->decodesToArray, $this->depth);
Loading history...
31
    }
32
}
33