From e3f66ea87808e42124863b957dac53086e0095bb Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sun, 28 Feb 2021 00:43:59 +0800 Subject: [PATCH] modify --- Database/Condition/Condition.php | 67 ++++++++++++++++---------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/Database/Condition/Condition.php b/Database/Condition/Condition.php index 94895475..f7714f9c 100644 --- a/Database/Condition/Condition.php +++ b/Database/Condition/Condition.php @@ -14,45 +14,46 @@ use Snowflake\Core\Str; abstract class Condition extends BaseObject { - protected string $column = ''; - protected string $opera = '='; + protected string $column = ''; + protected string $opera = '='; - /** @var array|mixed */ - protected $value; + /** @var array|mixed */ + protected $value; - const INT_TYPE = ['bit', 'bool', 'tinyint', 'smallint', 'mediumint', 'int', 'bigint', 'float', 'double', 'decimal', 'timestamp']; + const INT_TYPE = ['bit', 'bool', 'tinyint', 'smallint', 'mediumint', 'int', 'bigint', 'float', 'double', 'decimal', 'timestamp']; - protected array $attributes = []; + protected array $attributes = []; - abstract public function builder(); + abstract public function builder(); - /** - * @param string $column - */ - public function setColumn(string $column): void - { - $this->column = $column; - } + /** + * @param string $column + */ + public function setColumn(string $column): void + { + $this->column = $column; + } - /** - * @param string $opera - */ - public function setOpera(string $opera): void - { - $this->opera = $opera; - } + /** + * @param string $opera + */ + public function setOpera(string $opera): void + { + $this->opera = $opera; + } - /** - * @param $value - */ - public function setValue($value): void - { - $this->value = is_numeric($value) ? $value : '\'' . $value . '\''; - if (is_array($this->value)) { - $this->value = array_map(function ($value) { - return is_numeric($value) ? $value : '\''.$value.'\''; - }, $this->value); - } - } + /** + * @param $value + */ + public function setValue($value): void + { + if (is_array($value)) { + $this->value = array_map(function ($_value) { + return is_numeric($_value) ? $_value : '\'' . $_value . '\''; + }, $value); + } else { + $this->value = is_numeric($value) ? $value : '\'' . $value . '\''; + } + } }