Repository navigation
Expand file tree
/
Copy pathIsNull.php
More file actions
64 lines (52 loc) · 1.53 KB
/
Copy pathIsNull.php
File metadata and controls
64 lines (52 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
namespace PhpDb\Sql\Predicate;
use Override;
use PhpDb\Sql\AbstractExpression;
use PhpDb\Sql\Argument\Identifier;
use PhpDb\Sql\ArgumentInterface;
use PhpDb\Sql\Exception\InvalidArgumentException;
class IsNull extends AbstractExpression implements PredicateInterface
{
protected string $operator = 'IS NULL';
protected ?ArgumentInterface $identifier = null;
/**
* Constructor
*/
public function __construct(null|string|ArgumentInterface $identifier = null)
{
if ($identifier !== null) {
$this->setIdentifier($identifier);
}
}
/**
* Set identifier for comparison
*/
public function setIdentifier(string|ArgumentInterface $identifier): static
{
$this->identifier = $identifier instanceof ArgumentInterface
? $identifier
: new Identifier($identifier);
return $this;
}
/**
* Get identifier of comparison
*/
public function getIdentifier(): ?ArgumentInterface
{
return $this->identifier;
}
/** @inheritDoc */
#[Override]
public function getExpressionData(): array
{
if (! $this->identifier instanceof ArgumentInterface) {
throw new InvalidArgumentException('Identifier must be specified');
}
$identifierSpec = $this->identifier->getSpecification();
return [
'spec' => $this->specification ?? "{$identifierSpec} {$this->operator}",
'values' => [$this->identifier],
];
}
}