Add KeyValue expression

Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
davidarendsen 2022-08-05 18:51:35 +00:00
commit b2d1bd403c
7 changed files with 67 additions and 92 deletions

View 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);
}
}