@@ -88,7 +88,7 @@ public static function nodeLabelStorageToCypherLabelString(NodeLabelStorageInter
88
88
* ones.
89
89
* Return example: (:Label {property: 'value'}).
90
90
*/
91
- public static function nodeToCypherString (?NodeInterface $ node , bool $ identifying = false ): ?string
91
+ public static function nodeToCypherString (?NodeInterface $ node , bool $ identifying = false , ? string $ nodeVariable = null ): ?string
92
92
{
93
93
if (null === $ node ) {
94
94
return null ;
@@ -106,16 +106,19 @@ public static function nodeToCypherString(?NodeInterface $node, bool $identifyin
106
106
if ('' !== $ propertyString ) {
107
107
$ parts [] = '{ ' .$ propertyString .'} ' ;
108
108
}
109
+ if (!$ nodeVariable ) {
110
+ $ nodeVariable = '' ;
111
+ }
109
112
110
- return '( ' .implode (' ' , $ parts ).') ' ;
113
+ return '( ' .$ nodeVariable . implode (' ' , $ parts ).') ' ;
111
114
}
112
115
113
- public static function nodeToIdentifyingCypherString (?NodeInterface $ node ): ?string
116
+ public static function nodeToIdentifyingCypherString (?NodeInterface $ node, ? string $ nodeVariable = null ): ?string
114
117
{
115
- return self ::nodeToCypherString ($ node , true );
118
+ return self ::nodeToCypherString ($ node , true , $ nodeVariable );
116
119
}
117
120
118
- public static function relationToCypherString (RelationInterface $ relation , bool $ identifying = false , bool $ withNodes = true ): string
121
+ public static function relationToCypherString (RelationInterface $ relation , bool $ identifying = false , bool $ withNodes = true , ? string $ relationVariable = null ): string
119
122
{
120
123
$ parts = [];
121
124
if ($ withNodes ) {
@@ -124,8 +127,11 @@ public static function relationToCypherString(RelationInterface $relation, bool
124
127
125
128
$ relationParts = [];
126
129
if ($ relation ->getRelationType ()) {
130
+ if (!$ relationVariable ) {
131
+ $ relationVariable = '' ;
132
+ }
127
133
/** @psalm-suppress PossiblyNullReference */
128
- $ relationParts [] = ': ' .$ relation ->getRelationType ()->getRelationType ();
134
+ $ relationParts [] = $ relationVariable . ': ' .$ relation ->getRelationType ()->getRelationType ();
129
135
}
130
136
$ propertyStorage = $ relation ->getProperties ();
131
137
if ($ identifying ) {
@@ -148,9 +154,9 @@ public static function relationToCypherString(RelationInterface $relation, bool
148
154
return implode ('' , $ parts );
149
155
}
150
156
151
- public static function relationToIdentifyingCypherString (RelationInterface $ relation , bool $ withNodes = true ): string
157
+ public static function relationToIdentifyingCypherString (RelationInterface $ relation , bool $ withNodes = true , ? string $ relationVariable = null ): string
152
158
{
153
- return self ::relationToCypherString ($ relation , true , $ withNodes );
159
+ return self ::relationToCypherString ($ relation , true , $ withNodes, $ relationVariable );
154
160
}
155
161
156
162
/**
0 commit comments