Add KeyValue expression
Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
parent
e0e69b4beb
commit
b2d1bd403c
7 changed files with 67 additions and 92 deletions
39
src/Expression/KeyValue.php
Normal file
39
src/Expression/KeyValue.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Arendsen\FluxQueryBuilder\Expression;
|
||||
|
||||
class KeyValue extends Base {
|
||||
|
||||
/**
|
||||
* @var array $expressions
|
||||
*/
|
||||
private $expressions;
|
||||
|
||||
public function __construct(string $key, string $value)
|
||||
{
|
||||
$this->expressions[] = 'r.' . $key . ' == "' . $value . '"';
|
||||
}
|
||||
|
||||
public static function set(string $key, string $value): KeyValue
|
||||
{
|
||||
return new self($key, $value);
|
||||
}
|
||||
|
||||
public function and(string $key, string $value): KeyValue
|
||||
{
|
||||
$this->expressions[] = 'and r.' . $key . ' == "' . $value . '"';
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function or(string $key, string $value): KeyValue
|
||||
{
|
||||
$this->expressions[] = 'or r.' . $key . ' == "' . $value . '"';
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return implode(' ', $this->expressions);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue