Skip to content

Commit 9d62a70

Browse files
committed
added CALL clause
1 parent 1d833ad commit 9d62a70

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/Clauses/CallClause.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace WikibaseSolutions\CypherDSL\Clauses;
4+
5+
use WikibaseSolutions\CypherDSL\Query;
6+
7+
/**
8+
* This class represents a CALL clause.
9+
*
10+
* @see https://neo4j.com/docs/cypher-manual/current/clauses/call-subquery/
11+
*/
12+
class CallClause extends Clause
13+
{
14+
/**
15+
* @var Query The query to call.
16+
*/
17+
private Query $query;
18+
19+
/**
20+
* @param Query $query The query to call.
21+
*/
22+
public function __construct(Query $query)
23+
{
24+
$this->query = $query;
25+
}
26+
27+
public function toQuery(): string
28+
{
29+
return sprintf('CALL { %s }', $this->getSubject());
30+
}
31+
32+
/**
33+
* Returns the query that is being called.
34+
*
35+
* @return Query
36+
*/
37+
public function getQuery(): Query
38+
{
39+
return $this->query;
40+
}
41+
42+
/**
43+
* @inheritDoc
44+
*/
45+
protected function getSubject(): string
46+
{
47+
return $this->query->toQuery();
48+
}
49+
50+
/**
51+
* @inheritDoc
52+
*/
53+
protected function getClause(): string
54+
{
55+
return 'CALL';
56+
}
57+
}

0 commit comments

Comments
 (0)