Skip to content

Commit 7f0cb00

Browse files
Minor code changes and add additional tests
1 parent 27633fa commit 7f0cb00

File tree

5 files changed

+359
-136
lines changed

5 files changed

+359
-136
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ To construct a query to find all of Tom Hanks' co-actors, you can use the
3333
following code:
3434

3535
```php
36-
$tom = Query::node("Person")->withProperties(["name" => "Tom Hanks"]);
37-
$coActors = Query::node();
36+
use function WikibaseSolutions\CypherDSL\node;
37+
use function WikibaseSolutions\CypherDSL\query;
3838

39-
$statement = Query::new()
39+
$tom = node("Person")->withProperties(["name" => "Tom Hanks"]);
40+
$coActors = node();
41+
42+
$statement = query()
4043
->match($tom->relationshipTo(Query::node(), "ACTED_IN")->relationshipFrom($coActors, "ACTED_IN"))
4144
->returning($coActors->property("name"))
4245
->build();
43-
44-
$this->assertStringMatchesFormat("MATCH (:Person {name: 'Tom Hanks'})-[:ACTED_IN]->()<-[:ACTED_IN]-(%s) RETURN %s.name", $statement);
4546
```

src/Clauses/ReturnClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function addColumn(...$columns): self
6161
}
6262

6363
/**
64-
* Sets this query to only retrieve unique rows.
64+
* Sets this query to only return unique rows.
6565
*
6666
* @return $this
6767
*

src/Clauses/UnionClause.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,6 @@ final class UnionClause extends Clause
2727
*/
2828
private bool $all = false;
2929

30-
/**
31-
* Combines two queries with a union.
32-
*
33-
* @param Query $left the query preceding the union clause
34-
* @param Query $right the query after the union clause
35-
* @param bool $all Whether the union should include all results or remove the duplicates instead.
36-
*
37-
* TODO: Move this function somewhere else.
38-
*/
39-
public static function union(Query $left, Query $right, bool $all = false): Query
40-
{
41-
$tbr = Query::new();
42-
43-
foreach ($left->getClauses() as $clause) {
44-
$tbr->addClause($clause);
45-
}
46-
47-
$unionClause = new self();
48-
$unionClause->setAll($all);
49-
50-
$tbr->addClause($unionClause);
51-
52-
foreach ($right->getClauses() as $clause) {
53-
$tbr->addClause($clause);
54-
}
55-
56-
return $tbr;
57-
}
58-
5930
/**
6031
* Sets that the union should include all results, instead of removing duplicates.
6132
*

0 commit comments

Comments
 (0)