File tree Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Original file line number Diff line number Diff line change 8
8
use JsonException ;
9
9
use Nejcc \PhpDatatypes \Interfaces \DecoderInterface ;
10
10
use Nejcc \PhpDatatypes \Interfaces \EncoderInterface ;
11
-
11
+ use Nejcc \ PhpDatatypes \ Abstract \ ArrayAbstraction ;
12
12
13
13
/**
14
14
* Class Json
15
15
* A strict and immutable type for handling JSON data with advanced features.
16
16
*/
17
- final class Json
17
+ final class Json extends ArrayAbstraction
18
18
{
19
19
/**
20
20
* @var string The JSON string.
@@ -43,24 +43,9 @@ public function __construct(string $json, ?string $schema = null)
43
43
$ this ->validateJson ($ json );
44
44
$ this ->schema = $ schema ;
45
45
$ this ->json = $ json ;
46
+ parent ::__construct ([]); // Not used, but required by ArrayAbstraction
46
47
}
47
48
48
- /**
49
- * Validates if a string is valid JSON.
50
- *
51
- * @param string $json
52
- * @throws InvalidArgumentException
53
- */
54
- private function validateJson (string $ json ): void
55
- {
56
- try {
57
- json_decode ($ json , true , 512 , JSON_THROW_ON_ERROR );
58
- } catch (JsonException $ e ) {
59
- throw new InvalidArgumentException ('Invalid JSON provided: ' . $ e ->getMessage ());
60
- }
61
- }
62
-
63
-
64
49
/**
65
50
* Serializes the JSON data to an array.
66
51
*
You can’t perform that action at this time.
0 commit comments