Skip to content

Commit 651bdac

Browse files
committed
added UNION clause
1 parent 1d833ad commit 651bdac

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/Clauses/UnionClause.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace WikibaseSolutions\CypherDSL\Clauses;
4+
5+
/**
6+
* This class represents the union clause.
7+
*
8+
* @see https://neo4j.com/docs/cypher-manual/current/clauses/union/
9+
*/
10+
class UnionClause extends Clause
11+
{
12+
/** @var bool Whether the union should include all results or remove the duplicates instead. */
13+
private bool $all;
14+
15+
/**
16+
* @param bool $all Whether the union should include all results or remove the duplicates instead.
17+
*/
18+
public function __construct(bool $all = false)
19+
{
20+
$this->all = $all;
21+
}
22+
23+
/**
24+
* Returns whether the union includes all results or removes the duplicates instead.
25+
*
26+
* @return bool
27+
*/
28+
public function includesAll(): bool
29+
{
30+
return $this->all;
31+
}
32+
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function canBeEmpty(): bool
37+
{
38+
return true;
39+
}
40+
41+
/**
42+
* @inheritDoc
43+
*/
44+
protected function getSubject(): string
45+
{
46+
return 'UNION';
47+
}
48+
49+
/**
50+
* @inheritDoc
51+
*/
52+
protected function getClause(): string
53+
{
54+
return $this->all ? 'ALL' : '';
55+
}
56+
}

0 commit comments

Comments
 (0)