1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\kw_mapper\Storage\Shared\QueryBuilder; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class Condition |
7
|
|
|
{ |
8
|
|
|
/** @var string|string[]|callable|null */ |
9
|
|
|
protected $raw = null; // can be either column name or full query |
10
|
|
|
protected string $tableName = ''; |
11
|
|
|
/** @var string|int */ |
12
|
|
|
protected $columnName = ''; |
13
|
|
|
protected string $operation = ''; |
14
|
|
|
/** @var string|string[] */ |
15
|
|
|
protected $columnKey = ''; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param string $tableName |
19
|
|
|
* @param string|int $columnName |
20
|
|
|
* @param string $operation |
21
|
|
|
* @param string|string[] $columnKey |
22
|
|
|
* @return $this |
23
|
|
|
*/ |
24
|
73 |
|
public function setData(string $tableName, $columnName, string $operation, $columnKey): self |
25
|
|
|
{ |
26
|
73 |
|
$this->tableName = $tableName; |
27
|
73 |
|
$this->columnName = $columnName; |
28
|
73 |
|
$this->operation = $operation; |
29
|
73 |
|
$this->columnKey = $columnKey; |
30
|
73 |
|
$this->raw = null; |
31
|
73 |
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string|string[]|callable $operation |
36
|
|
|
* @param string|string[] $columnKey |
37
|
|
|
* @return $this |
38
|
|
|
*/ |
39
|
8 |
|
public function setRaw($operation, $columnKey = ''): self |
40
|
|
|
{ |
41
|
8 |
|
$this->tableName = ''; |
42
|
8 |
|
$this->columnName = ''; |
43
|
8 |
|
$this->operation = ''; |
44
|
8 |
|
$this->columnKey = $columnKey; |
45
|
8 |
|
$this->raw = $operation; |
46
|
8 |
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
66 |
|
public function isRaw(): bool |
50
|
|
|
{ |
51
|
66 |
|
return !is_null($this->raw); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return callable|string|string[]|null |
56
|
|
|
*/ |
57
|
10 |
|
public function getRaw() |
58
|
|
|
{ |
59
|
10 |
|
return $this->raw; |
60
|
|
|
} |
61
|
|
|
|
62
|
28 |
|
public function getTableName(): string |
63
|
|
|
{ |
64
|
28 |
|
return $this->tableName; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string|int |
69
|
|
|
*/ |
70
|
73 |
|
public function getColumnName() |
71
|
|
|
{ |
72
|
73 |
|
return $this->columnName; |
73
|
|
|
} |
74
|
|
|
|
75
|
73 |
|
public function getOperation(): string |
76
|
|
|
{ |
77
|
73 |
|
return $this->operation; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return string|string[] |
82
|
|
|
*/ |
83
|
74 |
|
public function getColumnKey() |
84
|
|
|
{ |
85
|
74 |
|
return $this->columnKey; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|