Skip to content

Commit 161e5cc

Browse files
committed
added IsNull
1 parent 1d833ad commit 161e5cc

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

src/IsNotNotNull.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace WikibaseSolutions\CypherDSL;
4+
5+
use WikibaseSolutions\CypherDSL\Traits\BooleanTypeTrait;
6+
use WikibaseSolutions\CypherDSL\Types\AnyType;
7+
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\BooleanType;
8+
use function sprintf;
9+
10+
/**
11+
* Represents the IS NOT NULL comparison operator.
12+
*
13+
* @see https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison
14+
*/
15+
class IsNotNull implements BooleanType
16+
{
17+
use BooleanTypeTrait;
18+
19+
/**
20+
* @var AnyType The type to test against null
21+
*/
22+
private AnyType $expression;
23+
24+
/**
25+
* IS NOT NULL constructor.
26+
*
27+
* @param AnyType $expression The type to test against null.
28+
*/
29+
public function __construct(AnyType $expression)
30+
{
31+
$this->expression = $expression;
32+
}
33+
34+
/**
35+
* Returns the expression to test against null.
36+
*
37+
* @return AnyType
38+
*/
39+
public function getExpression(): AnyType
40+
{
41+
return $this->expression;
42+
}
43+
44+
/**
45+
* @inheritDoc
46+
*/
47+
public function toQuery(): string
48+
{
49+
return sprintf("(%s IS NOT NULL)", $this->expression->toQuery());
50+
}
51+
}

src/IsNull.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace WikibaseSolutions\CypherDSL;
4+
5+
use WikibaseSolutions\CypherDSL\Traits\BooleanTypeTrait;
6+
use WikibaseSolutions\CypherDSL\Types\AnyType;
7+
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\BooleanType;
8+
use function sprintf;
9+
10+
/**
11+
* Represents the IS NULL comparison operator.
12+
*
13+
* @see https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison
14+
*/
15+
class IsNull implements BooleanType
16+
{
17+
use BooleanTypeTrait;
18+
19+
/**
20+
* @var AnyType The type to test against null
21+
*/
22+
private AnyType $expression;
23+
24+
/**
25+
* IS NULL constructor.
26+
*
27+
* @param AnyType $expression The type to test against null.
28+
*/
29+
public function __construct(AnyType $expression)
30+
{
31+
$this->expression = $expression;
32+
}
33+
34+
/**
35+
* Returns the expression to test against null.
36+
*
37+
* @return AnyType
38+
*/
39+
public function getExpression(): AnyType
40+
{
41+
return $this->expression;
42+
}
43+
44+
/**
45+
* @inheritDoc
46+
*/
47+
public function toQuery(): string
48+
{
49+
return sprintf("(%s IS NULL)", $this->expression->toQuery());
50+
}
51+
}

0 commit comments

Comments
 (0)