Files
kiri-core/Database/Condition/MathematicsCondition.php
T

79 lines
1.1 KiB
PHP
Raw Normal View History

2020-08-31 12:38:32 +08:00
<?php
2020-10-29 18:17:25 +08:00
declare(strict_types=1);
2020-08-31 12:38:32 +08:00
namespace Database\Condition;
/**
* Class MathematicsCondition
* @package Database\Condition
*/
class MathematicsCondition extends Condition
{
2020-10-29 18:17:25 +08:00
public string $type = '';
2020-08-31 12:38:32 +08:00
/**
* @return mixed
*/
2020-12-17 14:09:14 +08:00
public function builder(): mixed
2020-08-31 12:38:32 +08:00
{
2020-09-07 19:09:16 +08:00
return $this->{strtolower($this->type)}((float)$this->value);
2020-08-31 12:38:32 +08:00
}
/**
2020-09-07 19:09:16 +08:00
* @param $value
2020-08-31 12:38:32 +08:00
* @return string
*/
2020-12-17 14:09:14 +08:00
public function eq($value): string
2020-08-31 12:38:32 +08:00
{
2020-09-07 19:09:16 +08:00
return $this->column . ' = ' . $value;
2020-08-31 12:38:32 +08:00
}
/**
2020-09-07 19:09:16 +08:00
* @param $value
2020-08-31 12:38:32 +08:00
* @return string
*/
2020-12-17 14:09:14 +08:00
public function neq($value): string
2020-08-31 12:38:32 +08:00
{
2020-09-07 19:09:16 +08:00
return $this->column . ' <> ' . $value;
2020-08-31 12:38:32 +08:00
}
/**
2020-09-07 19:09:16 +08:00
* @param $value
2020-08-31 12:38:32 +08:00
* @return string
*/
2020-12-17 14:09:14 +08:00
public function gt($value): string
2020-08-31 12:38:32 +08:00
{
2020-09-07 19:09:16 +08:00
return $this->column . ' > ' . $value;
2020-08-31 12:38:32 +08:00
}
/**
2020-09-07 19:09:16 +08:00
* @param $value
2020-08-31 12:38:32 +08:00
* @return string
*/
2020-12-17 14:09:14 +08:00
public function egt($value): string
2020-08-31 12:38:32 +08:00
{
2020-09-07 19:09:16 +08:00
return $this->column . ' >= ' . $value;
2020-08-31 12:38:32 +08:00
}
/**
2020-09-07 19:09:16 +08:00
* @param $value
2020-08-31 12:38:32 +08:00
* @return string
*/
2020-12-17 14:09:14 +08:00
public function lt($value): string
2020-08-31 12:38:32 +08:00
{
2020-09-07 19:09:16 +08:00
return $this->column . ' < ' . $value;
2020-08-31 12:38:32 +08:00
}
/**
2020-09-07 19:09:16 +08:00
* @param $value
2020-08-31 12:38:32 +08:00
* @return string
*/
2020-12-17 14:09:14 +08:00
public function elt($value): string
2020-08-31 12:38:32 +08:00
{
2020-09-07 19:09:16 +08:00
return $this->column . ' <= ' . $value;
2020-08-31 12:38:32 +08:00
}
}