File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,21 @@ public function withMaxHops(int $maxHops): self
147
147
return $ this ;
148
148
}
149
149
150
+ /**
151
+ * Set the exact number of `relationship->node` hops away to search.
152
+ *
153
+ * @see https://neo4j.com/docs/cypher-manual/current/clauses/match/#varlength-rels
154
+ *
155
+ * @param int $exactHops
156
+ * @return Path
157
+ */
158
+ public function withExactHops (int $ exactHops ) : self
159
+ {
160
+ $ this ->exactHops = $ exactHops ;
161
+
162
+ return $ this ;
163
+ }
164
+
150
165
/**
151
166
* @param string $type
152
167
* @return Path
@@ -200,9 +215,13 @@ private function conditionToString(): string
200
215
$ conditionInner .= $ this ->minHops ;
201
216
}
202
217
218
+ $ conditionInner .= '.. ' ;
219
+
203
220
if (isset ($ this ->maxHops )) {
204
- $ conditionInner .= sprintf ( " ..%s " , $ this ->maxHops ) ;
221
+ $ conditionInner .= $ this ->maxHops ;
205
222
}
223
+ } elseif (isset ($ this ->exactHops )) {
224
+ $ conditionInner .= '* ' . $ this ->exactHops ;
206
225
}
207
226
208
227
if (isset ($ this ->properties )) {
@@ -216,4 +235,4 @@ private function conditionToString(): string
216
235
217
236
return sprintf ("[%s] " , $ conditionInner );
218
237
}
219
- }
238
+ }
You can’t perform that action at this time.
0 commit comments