private function buildEdgeCondition(ComparatorInterface $specification, RelationshipEdge $edge, string $side) : SequenceInterface { $key = (new Str($side))->append('_')->append($edge->target())->append((string) $this->count); $value = $specification->value(); if ($value instanceof IdentityInterface) { $value = $value->value(); } return new Sequence(sprintf('%s.%s %s %s', $side, $edge->target(), $specification->sign(), $key->prepend('{')->append('}')), new Collection([(string) $key => $value])); }
private function buildEdgeMapping(ComparatorInterface $specification, RelationshipEdge $edge, string $side) : MapInterface { $key = (new Str($side))->append('_')->append($edge->target()); $value = $specification->value(); if ($value instanceof IdentityInterface) { $value = $value->value(); } return (new Map('string', SequenceInterface::class))->put($side, new Sequence(new Collection([$edge->target() => (string) $key->prepend('{')->append('}')]), new Collection([(string) $key => $value]))); }
/** * Add the clause to match the target node in case it's node that is not * persisted via the current query * * @param Str $name * @param RelationshipEdge $meta * @param mixed $value * @param Query $query * * @return Query */ private function matchEdge(Str $name, RelationshipEdge $meta, $value, Query $query) : Query { if ($this->variables->contains((string) $name)) { return $query; } $this->variables = $this->variables->add((string) $name); return $query->match((string) $name)->withProperty($meta->target(), (string) $name->prepend('{')->append('_props}.')->append($meta->target()))->withParameter((string) $name->append('_props'), [$meta->target() => $value]); }