@@ -17,21 +17,23 @@ public function map(array $object): mixed
17
17
{
18
18
return match ($ object ['$type ' ]) {
19
19
'Integer ' => $ object ['_value ' ],
20
- 'float ' => $ object ['_value ' ],
20
+ 'Float ' => $ object ['_value ' ],
21
21
'String ' => $ object ['_value ' ],
22
22
'Boolean ' => $ object ['_value ' ],
23
23
'Null ' => $ object ['_value ' ],
24
- 'Array ' => $ object ['_value ' ],
24
+ 'Array ' => $ object ['_value ' ], // Handle generic arrays
25
+ 'List ' => array_map ([$ this , 'map ' ], $ object ['_value ' ]), // Recursively map lists
25
26
'Duration ' => $ object ['_value ' ],
26
27
'OffsetDateTime ' => $ object ['_value ' ],
28
+ 'Node ' => $ this ->mapNode ($ object ['_value ' ]),
27
29
'Map ' => $ this ->mapProperties ($ object ['_value ' ]),
28
30
'Point ' => $ this ->parseWKT ($ object ['_value ' ]),
29
- 'Node ' => $ this ->mapNode ($ object ['_value ' ]),
30
31
'Relationship ' => $ this ->mapRelationship ($ object ['_value ' ]),
31
32
'Path ' => $ this ->mapPath ($ object ['_value ' ]),
32
33
default => throw new \InvalidArgumentException ('Unknown type: ' . $ object ['$type ' ]),
33
34
};
34
35
}
36
+
35
37
public static function parseWKT (string $ wkt ): Point
36
38
{
37
39
$ sridPart = substr ($ wkt , 0 , strpos ($ wkt , '; ' ));
@@ -62,11 +64,12 @@ public static function parseWKT(string $wkt): Point
62
64
private function mapNode (array $ nodeData ): Node
63
65
{
64
66
return new Node (
65
- $ nodeData ['_labels ' ],
66
- $ this ->mapProperties ($ nodeData ['_properties ' ])
67
+ $ nodeData ['_labels ' ], // Labels of the node
68
+ $ this ->mapProperties ($ nodeData ['_properties ' ]) // Mapped properties
67
69
);
68
70
}
69
71
72
+
70
73
private function mapRelationship (array $ relationshipData ): Relationship
71
74
{
72
75
return new Relationship (
0 commit comments