public function buildStatement($fromId, $direction, $type, $identifier)
{
switch ($direction) {
case 'INCOMING':
$pattern = '<-[%s:%s]-';
break;
case 'OUTGOING':
$pattern = '-[%s:%s]->';
break;
case 'BOTH':
$pattern = '-[%s:%s]->';
break;
default:
throw new \LogicException(sprintf('Unsupported relationship direction "%s"', $direction));
}
$relationshipPattern = sprintf($pattern, $identifier, $type);
$query = 'MATCH (start) WHERE id(start) = {id}
MATCH (start)' . $relationshipPattern . '(end)';
if ($this->relationshipMetadata->hasOrderBy()) {
$query .= ' WITH end ORDER BY end.' . $this->relationshipMetadata->getOrderByPropery() . ' ' . $this->relationshipMetadata->getOrder();
}
$query .= ' RETURN end';
//print_r($query);
return Statement::create($query, ['id' => $fromId]);
}