16
16
use WikibaseSolutions \CypherDSL \Types \CompositeTypes \MapType ;
17
17
18
18
/**
19
- * This class represents a map of properties . For example, this class can represent the following
19
+ * This class represents a CYPHER map . For example, this class can represent the following
20
20
* construct:
21
21
*
22
22
* {name: 'Andy', sport: 'Brazilian Ju-Jitsu'}
23
23
*
24
+ * @see https://neo4j.com/docs/cypher-manual/current/syntax/maps/
25
+ *
26
+ * For its use for properties, see
24
27
* @see https://neo4j.com/docs/cypher-manual/current/syntax/patterns/#cypher-pattern-properties
25
28
*/
26
29
final class Map implements MapType
@@ -30,12 +33,12 @@ final class Map implements MapType
30
33
use MapTypeTrait;
31
34
32
35
/**
33
- * @var AnyType[] The map of properties
36
+ * @var AnyType[] The map
34
37
*/
35
- private array $ properties ;
38
+ private array $ elements ;
36
39
37
40
/**
38
- * @param AnyType[] $properties The map of expression
41
+ * @param AnyType[] $elements Associative array of the elements that this map should have
39
42
* @internal This method is not covered by the backwards compatibility promise of php-cypher-dsl
40
43
*/
41
44
public function __construct (array $ properties = [])
@@ -45,19 +48,19 @@ public function __construct(array $properties = [])
45
48
}
46
49
47
50
/**
48
- * Adds a property for the given name with the given value. Overrides the property if it already exists.
51
+ * Adds an element for the given name with the given value. Overrides the element if the $key already exists.
49
52
*
50
- * @param string $key The name of the property
51
- * @param mixed $value The value of the property
53
+ * @param string $key The name/label for the element
54
+ * @param mixed $value The value of the element
52
55
* @return $this
53
56
*/
54
- public function addProperty (string $ key , $ value ): self
57
+ public function add (string $ key , $ value ): self
55
58
{
56
59
if (!$ value instanceof AnyType) {
57
60
$ value = Literal::literal ($ value );
58
61
}
59
62
60
- $ this ->properties [$ key ] = $ value ;
63
+ $ this ->elements [$ key ] = $ value ;
61
64
62
65
return $ this ;
63
66
}
@@ -70,19 +73,19 @@ public function addProperty(string $key, $value): self
70
73
*/
71
74
public function mergeWith (Map $ map ): self
72
75
{
73
- $ this ->properties = array_merge ($ this ->properties , $ map ->properties );
76
+ $ this ->elements = array_merge ($ this ->elements , $ map ->getElements () );
74
77
75
78
return $ this ;
76
79
}
77
80
78
81
/**
79
- * Returns the map of properties as a number of key-expression pairs.
82
+ * Returns the elements of this map as an associative array with key-value pairs.
80
83
*
81
84
* @return AnyType[]
82
85
*/
83
- public function getProperties (): array
86
+ public function getElements (): array
84
87
{
85
- return $ this ->properties ;
88
+ return $ this ->elements ;
86
89
}
87
90
88
91
/**
@@ -92,7 +95,7 @@ public function toQuery(): string
92
95
{
93
96
$ pairs = [];
94
97
95
- foreach ($ this ->properties as $ key => $ value ) {
98
+ foreach ($ this ->elements as $ key => $ value ) {
96
99
$ pairs [] = sprintf ("%s: %s " , $ this ->escape (strval ($ key )), $ value ->toQuery ());
97
100
}
98
101
0 commit comments