Skip to content

Commit e795845

Browse files
author
Wout Gevaert
committed
Voeg support voor minimale hoeveelheid hops zonder maximum toe
1 parent bc4716c commit e795845

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/Patterns/Path.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,21 @@ public function withMaxHops(int $maxHops): self
147147
return $this;
148148
}
149149

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+
150165
/**
151166
* @param string $type
152167
* @return Path
@@ -200,9 +215,13 @@ private function conditionToString(): string
200215
$conditionInner .= $this->minHops;
201216
}
202217

218+
$conditionInner .= '..';
219+
203220
if (isset($this->maxHops)) {
204-
$conditionInner .= sprintf("..%s", $this->maxHops);
221+
$conditionInner .= $this->maxHops;
205222
}
223+
} elseif (isset($this->exactHops)) {
224+
$conditionInner .= '*' . $this->exactHops;
206225
}
207226

208227
if (isset($this->properties)) {
@@ -216,4 +235,4 @@ private function conditionToString(): string
216235

217236
return sprintf("[%s]", $conditionInner);
218237
}
219-
}
238+
}

0 commit comments

Comments
 (0)